Permalink
Browse files

Merge branch 'master' of github.com:raggi/talker_bot

* 'master' of github.com:raggi/talker_bot:
  Evil knows how to dance now, and back to being able to stop the Evil
  Recursive flood implemented
  • Loading branch information...
2 parents 3aefe4d + 1458404 commit 8f7f265f21b4d8d4325c05aefc5fb32b8782f04e @raggi committed Nov 17, 2009
Showing with 43 additions and 4 deletions.
  1. +43 −4 examples/evil.bot
View
@@ -2,7 +2,7 @@
require 'talker_bot/autorun'
class Evil
- attr_accessor :client
+ attr_accessor :client, :recursing
COMMANDS = {
:help => "Print out this help message",
@@ -12,11 +12,27 @@ class Evil
"Flood the channel with :count messages with :delay second(s) delay between messages"],
:recurse => [:really,
"Do a recursive flood on the channel. This gets out of hand really quick. Set :really as a confirmation"],
- :stop_flood => "End a currently running flood test"
+ :stop_recurse => "Attempt to halt the recurse flood",
+ :stop_flood => "End a currently running flood test",
+ :boogie => "Do the boogie, duh"
}
+ DANCE_STEPS = [
+ ":D|-<",
+ ":D\\-<",
+ ":D/-<",
+ ":D>-<",
+ ":D<-<",
+ ":D|-|",
+ ]
+
def on_message(sender, content, event)
puts event.inspect
+
+ if self.recursing
+ client.send_message content
+ end
+
case content
when /^evil: (.*)/
puts "Message: #{event.inspect}"
@@ -40,6 +56,10 @@ class Evil
end
end
+ def die
+ EM.stop
+ end
+
def help
<<END
This is Evil Bot. I'm here to cause pain and destruction.
@@ -77,7 +97,7 @@ END
@count += 1
client.send_message "FLOOD: Message # #{@count}"
else
- timer.cancel
+ @timer.cancel
end
}
"Starting flood of #{times} messages, one every #{delay} seconds"
@@ -90,8 +110,27 @@ END
"Flood stopped"
end
- def rescurse(really = false)
+ def recurse(really = false)
return "You don't really want to do this." unless really
+ @recursing = true
+
+ "Starting recurse, you asked for it"
+ end
+
+ def stop_recurse
+ @recursing = false
+
+ "Recurse finished, good day"
+ end
+
+ def boogie
+ @step_count = 0
+ @timer = EM::PeriodicTimer.new(1) do
+ client.send_message DANCE_STEPS[@step_count]
+ @step_count = (@step_count + 1) % DANCE_STEPS.length
+ end
+
+ "DANCE! Once you start, YOU CAN'T STOP!"
end
end

0 comments on commit 8f7f265

Please sign in to comment.