Redid that last commit.
This commit is contained in:
parent
de3ab7cfab
commit
00d80f0122
2 changed files with 12 additions and 1 deletions
|
@ -185,7 +185,6 @@ class IRC(object):
|
||||||
|
|
||||||
def set_nick(self, nick):
|
def set_nick(self, nick):
|
||||||
self.cmd("NICK", [nick])
|
self.cmd("NICK", [nick])
|
||||||
self.nick = nick
|
|
||||||
|
|
||||||
def join(self, channel):
|
def join(self, channel):
|
||||||
""" makes the bot join a channel """
|
""" makes the bot join a channel """
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
import socket
|
import socket
|
||||||
import time
|
import time
|
||||||
|
import re
|
||||||
|
|
||||||
from util import hook
|
from util import hook
|
||||||
|
|
||||||
socket.setdefaulttimeout(10)
|
socket.setdefaulttimeout(10)
|
||||||
|
|
||||||
|
nick_re = re.compile(":(.+?)!")
|
||||||
|
|
||||||
|
|
||||||
# Auto-join on Invite (Configurable, defaults to True)
|
# Auto-join on Invite (Configurable, defaults to True)
|
||||||
@hook.event('INVITE')
|
@hook.event('INVITE')
|
||||||
|
@ -50,6 +53,15 @@ def onkick(paraml, conn=None, chan=None):
|
||||||
conn.join(paraml[0])
|
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.singlethread
|
||||||
@hook.event('004')
|
@hook.event('004')
|
||||||
def keep_alive(paraml, conn=None):
|
def keep_alive(paraml, conn=None):
|
||||||
|
|
Reference in a new issue