From f35ae6761d9656ec51bd9176a83320c5dcf44278 Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Mon, 14 Apr 2014 02:06:53 -0700 Subject: Add support for modules. --- module.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 module.rb (limited to 'module.rb') diff --git a/module.rb b/module.rb new file mode 100644 index 0000000..f0c415a --- /dev/null +++ b/module.rb @@ -0,0 +1,22 @@ +module Dinobot + class Module + attr_accessor :commands + + def initialize + @commands = [:commands] + end + + def call(user, channel, message) + message = message.split(' ', 2).last + command = message.split.first + + if @commands.include?(command.intern) + send(command, user, channel, message) + end + end + + def commands(user, channel, message) + [[:say, channel, "Commands: #{@commands.sort.join(' ')}"]] + end + end +end -- cgit v1.2.3-70-g09d2