-
Notifications
You must be signed in to change notification settings - Fork 0
/
evil.bot
68 lines (52 loc) · 1.35 KB
/
evil.bot
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
class Evil
attr_accessor :client
def initialize(*args)
puts "Initializing!"
super
end
COMMANDS = {
:help =>
lambda { |client| client.help_message },
:commands =>
lambda { |client| client.commands_help },
:die =>
lambda { |client| client.die },
:flood =>
lambda { |client, times, delay| client.do_flood(times, delay) },
:recurse =>
lambda { |client, really| client.do_recursive_flood(really) }
}
def on_message(sender, content, event)
puts event.inspect
case content
when /^evil: (.*)/
puts "Someone talking to me?! #{sender['name']}: #{content.inspect}"
puts sender.inspect
puts event.inspect
input = $1.split(" ")
message = nil
command = COMMANDS[input[0].to_sym]
if command
puts "Found command for: #{input[0]}"
message = command.call(self)
else
message = "I'm sorry #{sender['name']}, but I'm afraid I can't do that."
end
client.send_message message if message
end
end
def help_message
<<END
This is Evil Bot. I'm here to cause pain and destruction.
To see a list of commands, ask me for 'commands'
END
end
def commands_help
<<END
The commands I currently support are:
#{COMMANDS.map { |key, value| key }.join(", ")}
END
end
end
trap('INT') { EM.shutdown }
use Evil.new