aboutsummaryrefslogtreecommitdiff
path: root/module
diff options
context:
space:
mode:
Diffstat (limited to 'module')
-rw-r--r--module/admin.rb54
-rw-r--r--module/base.rb16
-rw-r--r--module/config.rb20
-rw-r--r--module/test.rb32
4 files changed, 58 insertions, 64 deletions
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
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
diff --git a/module/config.rb b/module/config.rb
index 2bf8b0b..fa3c151 100644
--- a/module/config.rb
+++ b/module/config.rb
@@ -12,23 +12,21 @@ module Dinobot
@commands << :get << :set
end
- def get(user, channel, argument)
- return unless @bot.modules[:admin].is_admin?(user)
+ def get(m, args)
+ return unless @bot.modules[:admin].is_admin?(m.user)
- case argument
+ case args
when 'trigger'
- [[:say, channel, @config.data[:trigger][:global]]]
+ m.response << [:say, m.channel, @config.data[:trigger][:global]]
when 'debug'
- [[:say, channel, @config.data[:debug].to_s]]
- else
- nil
+ m.response << [:say, m.channel, @config.data[:debug].to_s]
end
end
- def set(user, channel, argument)
- return unless @bot.modules[:admin].is_admin?(user)
+ def set(m, args)
+ return unless @bot.modules[:admin].is_admin?(m.user)
- key, val = argument.split(' ')
+ key, val = args.split(' ')
return unless val
case key
@@ -45,8 +43,6 @@ module Dinobot
@config.save
end
end
-
- nil
end
end
end
diff --git a/module/test.rb b/module/test.rb
index f728930..cfc929b 100644
--- a/module/test.rb
+++ b/module/test.rb
@@ -7,39 +7,37 @@ module Dinobot
super
@commands << :echo << :ping << :x3 << :fooify
- @commands << :error << :timeout << :wrongreturn << :invalidmethods
+ @commands << :error << :timeout << :invalidresponse
end
- def echo(user, channel, argument)
- [[:say, channel, argument]]
+ def echo(m, args)
+ m.response << [:say, m.channel, args]
end
- def ping(user, channel, argument)
- [[:say, channel, 'pong']]
+ def ping(m, args)
+ m.response << [:say, m.channel, 'pong']
end
- def x3(user, channel, argument)
- [[:say, channel, argument]] * 3
+ def x3(m, args)
+ 3.times do
+ m.response << [:say, m.channel, args]
+ end
end
- def fooify(user, channel, argument)
- [[:say, channel, 'foo' + argument]]
+ def fooify(m, args)
+ m.response << [:say, m.channel, "foo#{args}"]
end
- def error(user, channel, argument)
+ def error(m, args)
x
end
- def timeout(user, channel, argument)
+ def timeout(m, args)
sleep 60
end
- def wrongreturn(user, channel, argument)
- 0
- end
-
- def invalidmethods(user, channel, argument)
- [[:say, channel]]
+ def invalidresponse(m, args)
+ m.response << [:say, m.channel]
end
end
end