-
Notifications
You must be signed in to change notification settings - Fork 0
/
rob-ot.rb
38 lines (26 loc) · 869 Bytes
/
rob-ot.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
require "socket"
server = "chat.freenode.net"
port = "6667"
nick = "HelloBot"
channel = "#bitmaker"
greeting_prefix = "privmsg #bitmaker :"
greetings = ['hello', 'hi', 'hola', 'yo', 'wazup', 'guten tag', 'howdy', 'salutations', 'who the hell are you?']
irc_server = TCPSocket.open(server, port)
# You need to talk to the server by using IRC protocol.
irc_server.puts "USER historybot 0 * HistoryBot"
irc_server.puts "NICK #{nick}"
irc_server.puts "JOIN #{channel}"
irc_server.puts "PRIVMSG #{channel} :"
# priv is a msg to only the channel that you've joined
until irc_server.eof? do
msg = irc_server.gets.downcase
puts msg
was_greeted = false
greetings.each do |g|
was_greeted = true if msg.include? greetings[0]
end
if msg.include? command
response = "w00t! Someone talked to me!!!!"
irc_server.puts "PRIVMSG #{channel} :#{response}"
end
end