-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcore.class.rb
More file actions
47 lines (40 loc) · 968 Bytes
/
core.class.rb
File metadata and controls
47 lines (40 loc) · 968 Bytes
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
# core.class.rb
# part of the bridge irc bot
class Core
def init
@sock = TCPSocket.open($server_host,$server_port)
$socks = $socks + [@sock]
$mainsock = @sock
put "USER #{$bot_ident} * * :#{$bot_realname}"
put "NICK #{$bot_nick}"
@online = true
end
def online
return @online
end
def say str
puts "#{Time.new.to_s}: #{str}"
end
def put str
say("[\e[1mMAIN\e[0m]\t[\e[1;31m>>>\e[0m]: #{str}")
@sock.send("#{str}\r\n",16000)
end
def get
line = @sock.recv(16000).strip
return line
end
def getBridgeBySock sock
$bridges.each do |tmp|
if tmp.getSock == sock
return tmp
end
end
end
def getBridgeByName name
$bridges.each do |tmp|
if tmp.getName == name
return tmp
end
end
end
end