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/admin.rb | 54 ++++++++++++++++++++++++++---------------------------- 1 file changed, 26 insertions(+), 28 deletions(-) (limited to 'module/admin.rb') diff --git a/module/admin.rb b/module/admin.rb index 1a081df..72c2a14 100644 --- a/module/admin.rb +++ b/module/admin.rb @@ -35,60 +35,58 @@ module Dinobot @admins.include?(user.sub(/.+@/, '')) end - def join(user, channel, argument) - return unless is_admin?(user) + def join(m, args) + return unless is_admin?(m.user) - [[:join, argument.strip]] + m.response << [:join, args.strip] end - def part(user, channel, argument) - return unless is_admin?(user) + def part(m, args) + return unless is_admin?(m.user) - [[:part, argument.strip]] + m.response << [:part, args.strip] end - def quit(user, channel, argument) - return unless is_admin?(user) + def quit(m, args) + return unless is_admin?(m.user) - [[:quit, argument ? argument.strip : 'Quitting.']] + m.response << [:quit, args ? args.strip : 'Quitting.'] end - def load(user, channel, argument) - return unless is_admin?(user) + def load(m, args) + return unless is_admin?(m.user) - argument.split.each do |x| + args.split.each do |x| @bot.load_module x.intern end - - nil end - def unload(user, channel, argument) - return unless is_admin?(user) + def unload(m, args) + return unless is_admin?(m.user) - argument.split.each do |x| + args.split.each do |x| @bot.unload_module x.intern end - - nil end - def listadmins(user, channel, argument) - return unless is_admin?(user) + def listadmins(m, args) + return unless is_admin?(m.user) - [[:say, channel, "Admins: #{@admins.join(' ')}"]] + m.response << [:say, m.channel, "Admins: #{@admins.join(' ')}"] end - def listmodules(user, channel, argument) - return unless is_admin?(user) + def listmodules(m, args) + return unless is_admin?(m.user) - [[:say, channel, "Modules: #{@bot.modules.keys.sort.join(' ')}"]] + m.response << [:say, m.channel, + "Modules: #{@bot.modules.keys.sort.join(' ')}"] end - def listchannels(user, channel, argument) - return unless is_admin?(user) + def listchannels(m, args) + return unless is_admin?(m.user) - [[:say, channel, "Channels: #{@bot.channels.sort.join(' ')}"]] + m.response << [:say, m.channel, + "Channels: #{@bot.channels.sort.join(' ')}"] end end end -- cgit v1.2.3-70-g09d2