Skip to content

theodi/odi-slackbot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Dependency Status Coverage Status Code Climate Badges

ODI Slackbot

This is the ODI's Slackbot. It generally hangs around on the #random channel. At the moment, it only does a few things, but feel free to add any new scripts!

Adding a script

Scripts live in the lib/scripts folder. Create a .rb file in that folder and give it an appropriate name.

Here's an example script:

hear /dispense crisps/i do
  "Get your own damn crisps, yo"
end

The script conists of a listener (the regex up top), and the response, which is always returned at the end.

If you want to capture anything from the user's input, add a matcher to the regex and do something like the following"

hear /echo (.*)/i do |regex|
  "You said #{regex[0]}"
end

Also, make sure you add tests. Add your tests in the spec directory and call your bot like so:

result = eval_script("your_script_name.rb", "input the bot is expecting")

If you have more than one script in a script file, you can add an optional index as the third argument:

result = eval_script("your_script_name.rb", "input the bot is expecting", 1)

If there is any Ruby code you want to share across your bot, add it to the lib/scripts/helpers/ directory, and require it in lib/odi-slackbot.rb

About

Your friendly neigbourhood Slackbot

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages