Redid that last commit.

This commit is contained in:
Luke Rogers 2012-10-12 21:56:09 +13:00
parent de3ab7cfab
commit 00d80f0122
2 changed files with 12 additions and 1 deletions

View file

@ -185,7 +185,6 @@ class IRC(object):
def set_nick(self, nick):
self.cmd("NICK", [nick])
self.nick = nick
def join(self, channel):
""" makes the bot join a channel """

View file

@ -1,10 +1,13 @@
import socket
import time
import re
from util import hook
socket.setdefaulttimeout(10)
nick_re = re.compile(":(.+?)!")
# Auto-join on Invite (Configurable, defaults to True)
@hook.event('INVITE')
@ -50,6 +53,15 @@ def onkick(paraml, conn=None, chan=None):
conn.join(paraml[0])
@hook.event("NICK")
def onnick(paraml, conn=None, raw=None):
old_nick = nick_re.search(raw).group(1)
new_nick = str(paraml[0])
if old_nick == conn.nick:
conn.nick = new_nick
print "Bot nick changed from '{}' to '{}'.".format(old_nick, new_nick)
@hook.singlethread
@hook.event('004')
def keep_alive(paraml, conn=None):