Leonel is a bot we use to make our life easier for our colombia-dev community
Make a bot integration, or have a bot token handy
Create a slack.env
file:
$ cp slack.env.example slack.env
The only token that needs to be valid is SLACK_TOKEN
, the rest can be placeholder unless you want to test the invitation or onboarding flows.
After setting the right SLACK_TOKEN
in your slack.env
file, use docker-compose
to bring up leonel:
$ docker-compose up
Go to your Slack, and send a DM to leonel saying coqueto
. He'll respond if he's up. You can run docker in a detached state by using docker-compose up -d
instead.
The docker-compose setup is configured to reboot the bot when any local file changes, using nodemon
to make development easier.
Leonel uses MongoDB to store specific information about users, you can create the user accounts by running:
$ docker-compose run bot yarn db:seed
This will execute the script db:seed in a container to create all the users from Slack's API.
You can run ava
tests in a container, by running:
$ docker-compose run bot yarn test
If you want for tests to watch your files, you can run:
$ docker-compose run bot yarn test -- -w
If you want to modify the DEBUG
env var, you can run:
$ docker-compose run -e DEBUG="" bot yarn test -- -w
When you're done, you can use docker-compose to clean up your environment:
$ docker-compose down
All environment variables in example env file should be set before running Leonel.
Other requirements:
Install dependencies:
$ yarn
Start leonel:
$ yarn start
Things are looking good if the console prints something like:
** API CALL: https://slack.com/api/rtm.start
** BOT ID: leonel ...attempting to connect to RTM!
** API CALL: https://slack.com/api/chat.postMessage
bot:main Estamos coneptados al Eslá
We have added yarn start:watch
script which uses Nodemon for convenience during development. This restarts the bot after any change done to source files.
Leonel uses MongoDB to store specific information about users, you can create the user accounts by running:
$ yarn db:seed
This will execute the script db:seed to create all the users from Slack's API.
note: make sure the proper environment vars in example env file are set before running tests
We use ava for unit and integration testing, you can run tests by typing:
$ yarn test
You can watch files and run tests when any changes are detected by using:
$ yarn test -- -w
In order to minimize code style differences, we have adopted the StandardJS style. Please make sure your changes are compatible with the guide.
note: you can check compatibility by running tests
$ yarn test
note: you may also be able to automatically fix any style issues with the standard
tool
$ node_modules/.bin/standard --fix
Please see the documentation at StandardJS for more information.
This code uses the botkit npm module by the fine folks at Howdy.ai.
See the LICENSE file (MIT).