aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2014-04-20 05:13:39 -0700
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2014-04-20 05:13:39 -0700
commitd439860ebd6915fdd2f52f66cb032106e55c4777 (patch)
treef7f181c0c9518bc0fabdfc88db4f2bbe2705459c
parent912090fbaf4db492458f0e2aedc0181d3f39ccb3 (diff)
downloaddinobot-d439860ebd6915fdd2f52f66cb032106e55c4777.tar.gz
dinobot-d439860ebd6915fdd2f52f66cb032106e55c4777.tar.xz
Add quit command and fix PONG message.
-rw-r--r--core/irc.rb4
-rw-r--r--dinobot.rb8
-rw-r--r--module/admin.rb8
3 files changed, 17 insertions, 3 deletions
diff --git a/core/irc.rb b/core/irc.rb
index 779b37b..0cde75d 100644
--- a/core/irc.rb
+++ b/core/irc.rb
@@ -62,6 +62,10 @@ module Dinobot
def privmsg(channel, message)
puts "PRIVMSG #{channel} :#{message}"
end
+
+ def quit(message)
+ puts "QUIT :#{message}"
+ end
end
end
end
diff --git a/dinobot.rb b/dinobot.rb
index 7eb47f1..a00517f 100644
--- a/dinobot.rb
+++ b/dinobot.rb
@@ -56,6 +56,10 @@ module Dinobot
@irc.part(channel)
end
+ def quit(message)
+ @irc.quit(message)
+ end
+
def load_module(mod)
mod = mod.downcase.intern
@logger.info "Loading module: #{mod}"
@@ -106,7 +110,7 @@ module Dinobot
end
def parse_line(str)
- @irc.pong str.sub(/\APING /, 'PONG') if str =~ /\APING /
+ @irc.pong str.sub(/\APING /, '') if str =~ /\APING /
if str =~ /(\S+) PRIVMSG (\S+) :(.*)/
user, channel, message = str.scan(/(\S+) PRIVMSG (\S+) :(.*)/).first
@@ -163,7 +167,7 @@ module Dinobot
case m.first
when :say
raise "wrong number of arguments -- #{m}" unless m.length == 3
- when :join, :part
+ when :join, :part, :quit
raise "wrong number of arguments -- #{m}" unless m.length == 2
else
raise "unknown method name -- #{m}"
diff --git a/module/admin.rb b/module/admin.rb
index d59fd49..dd52cab 100644
--- a/module/admin.rb
+++ b/module/admin.rb
@@ -6,7 +6,7 @@ module Dinobot
def initialize(bot)
super
- @commands << :join << :part << :load << :unload
+ @commands << :join << :part << :quit << :load << :unload
@commands << :listadmins << :listmodules << :listchannels
@admins = Array.new
@@ -37,6 +37,12 @@ module Dinobot
[[:part, argument.strip]]
end
+ def quit(user, channel, argument)
+ return unless is_admin?(user)
+
+ [[:quit, argument ? argument.strip : 'Quitting.']]
+ end
+
def listadmins(user, channel, argument)
return unless is_admin?(user)