-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathirctest.py
77 lines (64 loc) · 1.96 KB
/
irctest.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
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
import irc.client
import sys
class IRCCat(irc.client.SimpleIRCClient):
def __init__(self, target):
irc.client.SimpleIRCClient.__init__(self)
self.target = target
def on_welcome(self, connection, event):
print("welcomed")
print(event);
if irc.client.is_channel(self.target):
connection.join(self.target)
# else:
# self.send_it()
def _dispatcher(self, connection, event):
"""
Dispatch events to on_<event.type> method, if present.
"""
print("_dispatcher: %s", event.type)
do_nothing = lambda c, e: None
method = getattr(self, "on_" + event.type, do_nothing)
method(connection, event)
def on_all_raw_messages(self, connection, event):
print("got here")
def on_join(self, connection, event):
pass
#self.send_it()
def on_disconnect(self, connection, event):
sys.exit(0)
def on_pubmsg(self, c, e):
print("got in here")
# def send_it(self):
# while 1:
# print("oh shit I got in here yes")
# break
# self.connection.quit("Using irc.client.py")
def main():
if len(sys.argv) != 4:
print("Usage: irccat2 <server[:port]> <nickname> <target>")
print("\ntarget is a nickname or a channel.")
sys.exit(1)
s = sys.argv[1].split(":", 1)
server = s[0]
if len(s) == 2:
try:
port = int(s[1])
except ValueError:
print("Error: Erroneous port.")
sys.exit(1)
else:
port = 6667
nickname = sys.argv[2]
target = sys.argv[3]
c = IRCCat(target)
try:
print("About to connect")
c.connect(server, port, nickname, "oauth:v9h7fnm6uh7a8zy9v32gqivpt34mo6")
print("Success?")
except irc.client.ServerConnectionError as x:
print(x)
sys.exit(1)
c.start()
print("Reached end of file")
if __name__ == "__main__":
main()