Added IPv6 support, rejoice!

This commit is contained in:
Juhani Haverinen 2013-08-09 11:08:18 +03:00
parent 9d416892a9
commit ff4281eedc
4 changed files with 32 additions and 3 deletions

View File

@ -109,10 +109,24 @@ def parse((line,irc)):
else:
if line[3][1:] in authcmds:
authcmds.pop(line[3][1:])
if line[5]=='0':
irc.send('PRIVMSG %s :Register account with NickServ'%line[3][1:])
elif line[5]=='1':
irc.send('PRIVMSG %s :Identify with NickServ'%line[3][1:])
else:
irc.send('PRIVMSG %s :WTF, NickServ returned %s'%(line[3][1:],line[5]))
trustedlock.release()
authcmdlock.release()
elif line[1]=='482':
irc.send('PRIVMSG %s :Not op'%line[3])
#elif line[1]=='332' or line[1]=='TOPIC':
# if line[1]=='332':
# ch=line[3]
# tp=' '.join(line[4:])[1:]
# elif line[1]=='TOPIC':
# ch=line[2]
# tp=' '.join(line[3:])[1:]
# #Do the magic here
msglock.acquire()
if (line[1]=='PRIVMSG' or line[1]=='JOIN') and nick in msgs:
@ -133,7 +147,7 @@ def execcmd(cmdline):
def help(cmd):
if cmd=='':
return '#echo #op #deop #kick #src #msg #readmsg #help'
return '#echo #op #deop #voice #devoice #kick #src #msg #readmsg #help'
elif cmd=='#echo':
return '#echo text echo text back'
elif cmd=='#op':

Binary file not shown.

BIN
eliza.pyc

Binary file not shown.

View File

@ -48,8 +48,23 @@ class Connhandler(threading.Thread):
self.logc.send(line+'\n')
Threadwrapper(botcmd.parse,(line,self.inpc)).start()
def run(self):
self.sock=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.sock.connect((self.server,self.port))
self.sock=None
for af, socktype, proto, canonname, sa in socket.getaddrinfo(self.server,self.port,socket.AF_UNSPEC,socket.SOCK_STREAM):
try:
self.sock=socket.socket(af, socktype, proto)
except socket.error:
self.sock=None
conntinue
try:
self.sock.connect(sa)
except socket.error:
self.sock.close()
self.sock=None
continue
break
if self.sock is None:
self.logc.send('QUIT');
sys.exit(1);
self.sock.settimeout(0.1)
self.send('NICK %s'%self.nick)