|
|
|
@ -43,13 +43,13 @@ class IRC:
|
|
|
|
|
self.connect(self.server, self.bot_nick)
|
|
|
|
|
self.join_channels(self.channels)
|
|
|
|
|
while 1:
|
|
|
|
|
sleep(2)
|
|
|
|
|
data = self.receive()
|
|
|
|
|
self.keepalive(data)
|
|
|
|
|
self.msg = self.parse(data, self.req_prefix)
|
|
|
|
|
for c in self.channels:
|
|
|
|
|
# Pass in a context dict for handlers
|
|
|
|
|
listen_hook({"msg": self.msg, "listen_chan": c})
|
|
|
|
|
sleep(1)
|
|
|
|
|
|
|
|
|
|
def connect(self, server, bot_nick):
|
|
|
|
|
"""Connect to the server and sends user/nick information."""
|
|
|
|
@ -72,9 +72,10 @@ class IRC:
|
|
|
|
|
|
|
|
|
|
def keepalive(self, line):
|
|
|
|
|
"""Stay connected to a server by responding to server pings."""
|
|
|
|
|
resp = line.split(" ", 1)[1]
|
|
|
|
|
if ("PING " + resp) in line:
|
|
|
|
|
self.send("PONG", resp)
|
|
|
|
|
if resp != []:
|
|
|
|
|
resp = line.split(" ", 1)[1]
|
|
|
|
|
if ("PING " + resp) in line:
|
|
|
|
|
self.send("PONG", resp)
|
|
|
|
|
|
|
|
|
|
def join_channels(self, channels):
|
|
|
|
|
"""Join channels given a list of channel names."""
|
|
|
|
|