From 6ff901dfe723b58ad13a2e3693473d934f5751b2 Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Mon, 21 Apr 2014 12:17:58 -0700 Subject: Modify modules to accept MessageInfo objects. --- module/base.rb | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'module/base.rb') diff --git a/module/base.rb b/module/base.rb index b8be306..3f4d9cd 100644 --- a/module/base.rb +++ b/module/base.rb @@ -9,16 +9,18 @@ module Dinobot @commands = [:commands] end - def call(user, channel, message) - command, argument = message.split(' ', 3)[1..2] + def call(m, command) + command, args = command.split(' ', 3)[1..2] + args ||= '' - if @commands.map { |x| x.to_s }.include?(command) - send(command, user, channel, argument) - end + return unless @commands.map { |x| x.to_s }.include?(command) + + send(command, m, args) end - def commands(user, channel, argument) - [[:say, channel, "Commands: #{@commands.sort.join(' ')}"]] + def commands(m, args) + m.response << [:say, m.channel, + "Commands: #{@commands.sort.join(' ')}"] end end end -- cgit v1.2.3-70-g09d2