/Gilda

A simple bot for the Bluegrass Developers guild

Primary LanguagePythonMIT LicenseMIT

Gilda

Build

A simple bot for the Bluegrass Developers guild .... Gilda. or should it be Guilda? 🤷‍♂️

Please feel free to submit PRs for any issues, errors, and/or additional functionality. Before doing so see the code of conduct.

Libraries and tools we use

build new functions

  • fn init --runtime python --trigger http <function name>
  • fn list triggers gilda should list the http trigger for the new event

Running locally

  1. start the local server fn start --log-level debug

  2. Make sure you have a local app fn list apps

    • if not create one fn create app gilda
  3. set up environment variables

    • if you don't want to use Slack or OCI endpoints (everything stays local) fn cf a gilda is_local True to delete fn cf a gilda is_local ""
    • to use OCI local config fn cf a gilda local_oci_config True to delete fn cf a gilda local_oci_config ""
    • fn cf a gilda random_channel_id <some_id>
    • fn cf a gilda slack_bot_token <some token>
    • fn cf a gilda compartment_id <oracle OCID>
    • fn cf a gilda web_auth_token auth_1234
    • fn cf a gilda local_oci_config True
  4. deploy locally fn --verbose deploy --app gilda --all --local --no-bump

  5. List functions fn list functions gilda

  6. Grab local url fn inspect function gilda events

Deploy

  1. create context fn create context gilda --provider oracle --registry yyz.ocir.io/<id>/gilda --api-url https://functions.ca-toronto-1.oraclecloud.com
  2. fn use context gilda
  3. fn update context oracle.compartment-id
  4. fn --verbose deploy --app Gilda --all

invoke

use the fn command echo -n '{"name":"Bob"}' | fn invoke gilda events

or simply good old fashioned curl, like your mother taught you:

curl -X "POST" -H "Content-Type: application/json" -d '{ "type": "url_verification","token": "JRoGaO6sIgohYqywBlT3Q0vz","challenge": "wnxwuwy1LjvmMB7HWTV3M2KRiYDhQgeLqlxhT2064MIvVFtOYTN1", "event": {"type": "member_joined_channel", "channel":"<some_id>", "user": "<some_url>"} }'  http://localhost:8080/t/gilda/events

curl -X "POST" -H "Content-Type: application/json" -d '{"token": "auth_1234"}' http://localhost:8080/t/gilda/learning

Or use Insomnia Core and import the insomnia_export.json