Permalink
Browse files

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

* 'master' of github.com:raggi/talker_bot:
  Change to instance_eval, lets one define commands without needing the client passed in
  Fix the double-connect issue

Conflicts:
	bin/talker_bot
  • Loading branch information...
2 parents 5dd0b39 + 980c818 commit e4c0058e60480ec68678185a93ba48488f1c4640 @raggi committed Nov 13, 2009
Showing with 7 additions and 7 deletions.
  1. +1 −1 bin/talker_bot
  2. +6 −6 examples/evil.bot
View
@@ -16,5 +16,5 @@ require 'talker_bot'
bot = TalkerBot.new :room => ARGV.first
bot.instance_eval(File.read(config), config, 0)
-trap(:INT) { EM.stop if EM.reactor_running?; exit }
+trap('INT') { EM.stop if EM.reactor_running?; exit}
EM.run { bot.run }
View
@@ -8,19 +8,19 @@ class Evil
COMMANDS = {
:help =>
- lambda { |client| client.help_message },
+ lambda { help_message },
:commands =>
- lambda { |client| client.commands_help },
+ lambda { commands_help },
:die =>
- lambda { |client| client.die },
+ lambda { die },
:flood =>
- lambda { |client, times, delay| client.do_flood(times, delay) },
+ lambda { |times, delay| do_flood(times, delay) },
:recurse =>
- lambda { |client, really| client.do_recursive_flood(really) }
+ lambda { |really| do_recursive_flood(really) }
}
def on_message(sender, content, event)
@@ -38,7 +38,7 @@ class Evil
if command
puts "Found command for: #{input[0]}"
- message = command.call(self)
+ message = instance_eval(&command)
else
message = "I'm sorry #{sender['name']}, but I'm afraid I can't do that."
end

0 comments on commit e4c0058

Please sign in to comment.