SlackBot example using botkit but with ES6 syntax (compiled to ES5 ondemand by using Babel).
You need Node installed with npm.
You will also need to have a bot setup in your Slack integrations (use https://my.slack.com/services/new/bot) and export the API TOKEN in your shell environment before you start the bot.
npm install
export slackbotapitoken=<YOUR-BOTS-API-TOKEN-HERE>
# either
npm run start
# or
node server.js
Enjoy.
There are no admins in the database by default. However, there is a super admin password that can be used to add users to the admin list.
You can set superadmin password via the superadminpassword
environment variable. If you do not set it, it will take the default from the configuration.es6
file, which sets it to friend
.
You add users to the admin list via (direct) messages to your bot, like so
@botname admin add @username
You can remove users from the admin list in the same way
@botname admin rm @username
You can also see the complete list of admins with this command
@botname admin list
Admin users can add, edit and remove Facts from the fact database. The fact database can be queried via the fact
command.
@botname fact list # list all facts
@botname fact random # list a random fact from the list
@botname fact add <new fact text> # add a fact to the list, needs admin user
@botname fact delete <factid> # remove a fact from the list, needs admin user
@botname fact update <factid> <updated fact text> # edit a fact in the list, needs admin user
You can get a random number (range 0 to 100) via this command
@botname rndnum
You can see the latest commit message for the current active branch that the bot is run on.
@botname git info
Try help karma
to see what's available. And have a look at the configuration.es6
file to get an idea on how it works. If you want to see the details, please look at src/commands/KarmaCommand.es6
.
The help
command will display a help text for all available commands (if they provide a help text that is).
-
add a catch all command that catches all direct messages that are not actively handled by an assigned/specialized command and return a message ala "sorry, command unknown - try again" message (or use fuzzy logic to suggest a more sutable command)
-
...
Copyright (c) 2015-2016 by Daniel Kurashige-Gollub, [email protected]
MIT
See LICENSE file.