-
Notifications
You must be signed in to change notification settings - Fork 1
/
commands.rb
132 lines (81 loc) · 2.74 KB
/
commands.rb
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
class BotCommands
def initialize(stream, channel, nick)
@stream = stream
@nick = nick
@channel = channel
end
def beer(*args)
if args[0] == "" || args[0] == "me"
@stream.puts("PRIVMSG #{@channel} :\001ACTION gives #{@nick} a beer\001")
else
@stream.puts("PRIVMSG #{@channel} :\001ACTION gives #{args[0]} a beer\001")
end
end
def hug(*args)
if args[0] == "" || args[0] == "me"
@stream.puts("PRIVMSG #{@channel} :\001ACTION gives #{@nick} a big hug.\001")
else
@stream.puts("PRIVMSG #{@channel} :\001ACTION gives #{args[0]} a big hug.\001")
end
end
def quit(*args)
users = ["Plazma", "Plazma-Rooolz"]
users.each { |x|
if x == @nick
puts "QUITTING!"
@stream.puts("QUIT :FFFFFFUUUUUUUU")
@stream.close
exit
end
}
#looks like we aren't a authorized user...
@stream.puts("PRIVMSG #{@channel} :Sorry #{@nick}, you are not authorized to do that")
end
def date(*args)
timeNow = Time.now
currdate = timeNow.strftime("%a %m/%d/%y")
@stream.puts("PRIVMSG #{@channel} :Today's Date: #{currdate}")
end
def time(*args)
timeNow = Time.now
currtime = timeNow.strftime("%I:%M%p")
@stream.puts("PRIVMSG #{@channel} :Current time: #{currtime}")
end
def ping(server)
puts("PONG #{server}")
@stream.puts("PONG #{server}")
end
def help(*args)
case args[0]
when ""
@stream.puts("PRIVMSG #{@channel} :Current commands: !beer , !date , !time, !help, !say, !hug")
when "!beer" , "beer"
@stream.puts("PRIVMSG #{@channel} :Give beer to user. Usage: !beer or !beer <nick>")
when "!hug", "hug"
@stream.puts("PRIVMSG #{@channel} :Spread some love with a hug! Usage: !hug or !hug <nick>")
when "!time", "time"
@stream.puts("PRIVMSG #{@channel} :Checkin' the time. Usage: !time")
when "!date", "date"
@stream.puts("PRIVMSG #{@channel} :What's the date? Usage: !date")
when "!say", "say"
@stream.puts("PRIVMSG #{@channel} :Tell me to say things. Usage: !say <message>")
when "!help", "help"
@stream.puts("PRIVMSG #{@channel} :Tells you what I can do. Usage: !say <message>")
else
@stream.puts("PRIVMSG #{@channel} :Help for command '#{args[0]}' not found")
end
end
def say(message)
if message == ""
@stream.puts("PRIVMSG #{@channel} :This command requires a message to send")
else
@stream.puts("PRIVMSG #{@channel} :#{message}")
end
end
def join(*channel)
@stream.puts("JOIN #{channel[0]}")
end
def part(*channel)
@stream.puts("PART #{channel[0]}")
end
end