Added IPv6 support, rejoice!
This commit is contained in:
parent
9d416892a9
commit
ff4281eedc
4 changed files with 32 additions and 3 deletions
16
botcmd.py
16
botcmd.py
|
@ -109,10 +109,24 @@ def parse((line,irc)):
|
||||||
else:
|
else:
|
||||||
if line[3][1:] in authcmds:
|
if line[3][1:] in authcmds:
|
||||||
authcmds.pop(line[3][1:])
|
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()
|
trustedlock.release()
|
||||||
authcmdlock.release()
|
authcmdlock.release()
|
||||||
elif line[1]=='482':
|
elif line[1]=='482':
|
||||||
irc.send('PRIVMSG %s :Not op'%line[3])
|
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()
|
msglock.acquire()
|
||||||
if (line[1]=='PRIVMSG' or line[1]=='JOIN') and nick in msgs:
|
if (line[1]=='PRIVMSG' or line[1]=='JOIN') and nick in msgs:
|
||||||
|
@ -133,7 +147,7 @@ def execcmd(cmdline):
|
||||||
|
|
||||||
def help(cmd):
|
def help(cmd):
|
||||||
if 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':
|
elif cmd=='#echo':
|
||||||
return '#echo text echo text back'
|
return '#echo text echo text back'
|
||||||
elif cmd=='#op':
|
elif cmd=='#op':
|
||||||
|
|
BIN
botcmd.pyc
BIN
botcmd.pyc
Binary file not shown.
BIN
eliza.pyc
BIN
eliza.pyc
Binary file not shown.
19
ircbot.py
19
ircbot.py
|
@ -48,8 +48,23 @@ class Connhandler(threading.Thread):
|
||||||
self.logc.send(line+'\n')
|
self.logc.send(line+'\n')
|
||||||
Threadwrapper(botcmd.parse,(line,self.inpc)).start()
|
Threadwrapper(botcmd.parse,(line,self.inpc)).start()
|
||||||
def run(self):
|
def run(self):
|
||||||
self.sock=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
self.sock=None
|
||||||
self.sock.connect((self.server,self.port))
|
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.sock.settimeout(0.1)
|
||||||
|
|
||||||
self.send('NICK %s'%self.nick)
|
self.send('NICK %s'%self.nick)
|
||||||
|
|
Loading…
Reference in a new issue