Xander
Getting Started
- Install Ruby (ruby 2.2.3p173)
- Install Bundler with
gem install bundler
cd ruby-app
to swap to the main directorybundle install
in the root directory of the project to install the required gemstouch .testbot
to create a blank API token file (you don't need a token unless you are running new tests)rake
to run the tests!
Structure of the project
ruby-app/
Contains the main logic of Xander.
bot.rb
Initiates one instance of Xander
, the Slack::RealTime::Client
(web and rtm)
and establishes the connection to the team.
Make sure you have a valid Slack API token.
SLACK_API_TOKEN=xoxb-7776-LIVE-AM-MICROPHON ruby bot.rb
xander.rb
In get_response_for
we decide which Response
Xander returns for a certain
message. Currently we rely on Regexe's to do that job. We simply iterate over
all Responses
and the first response which is triggered_by?
by the message
wins.
rubular.com is pretty handy for testing regexes.
responses/
The directory containing all responses.
If you want to add a new response, drop it in here. Your Response
should
inherit from Base
and implement triggered_by?
, help
and text
.
config/
Contains deployment/docker-related configuration files.
Adding a new response
So in summary, if you want to add a new response:
- Create a new test
test/responses/my_new_response_test.rb
- Create a new response
lib/responses/
- Run tests
rake test
or a single test (ruby -I lib -I test/ test/responses/help_test.rb
) - Commit
- Push
Other notes
I've not included the dictionaries for the markov chains, since they contain some team specific data I'm not comfortable sharing atm.
As far as deployment goes, I'm hosting this on a VPS of mine atm. You can have a
look at the Dockerfile
to see what's included. (In case you want timing/cron
related libs).
Resources
- Community Wiki for API
- Bungie Dev Group
- Append
/help
to any service endpoint to view docs - Slack API docs
- CircleCI
- How to Read the Manifest (Reference)