forked from flosspa/FlossBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
47 lines (35 loc) · 912 Bytes
/
main.py
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
import sys, socket, string, random, os, time
from Events import *
from Irc import *
irc = None
running = True
def restartIRCHook(event):
global irc
time.sleep(5)
irc.connect()
def main(args):
global irc
listener = Listener(IRC_RESTART, restartIRCHook)
getEventManager().addListener(listener)
host = args[1]
port = int(args[2])
channel = args[3]
if channel[0] != '#':
channel = '#' + channel
getEventManager().start()
irc = Irc(host, port, channel)
while running:
try:
i = raw_input()
if i == "quit" or i == "exit":
irc.disconnect()
getEventManager().stop()
break
except KeyboardInterrupt:
irc.disconnect()
getEventManager().stop()
break
time.sleep(1)
sys.exit()
if __name__ == '__main__':
main(sys.argv)