Handle IPv6 addresses in message origin

This commit is contained in:
moneromooo 2015-01-09 22:33:45 +00:00
parent 13f68a1760
commit 3c363ea084

View file

@ -17,6 +17,7 @@ import select
import time import time
import string import string
import base64 import base64
import re
import tipbot.config as config import tipbot.config as config
from tipbot.log import log, log_error, log_warn, log_info, log_log from tipbot.log import log, log_error, log_warn, log_info, log_log
@ -325,6 +326,13 @@ def IRCLoop(on_idle,on_identified,on_command):
cparts = data.split(':') cparts = data.split(':')
if len(cparts) < 2: if len(cparts) < 2:
continue continue
if len(cparts) >= 9:
idx_colon = data.find(':',1)
idx_space = data.find(' ')
if idx_space and idx_colon < idx_space and re.search("@([0-9a-fA-F]+:){7}[0-9a-fA-F]+", data):
log_info('Found IPv6 address in non-text, restructuring')
idx = data.rfind(':')
cparts = [ cparts[0], "".join(cparts[1:]) ]
if len(cparts) >= 3: if len(cparts) >= 3:
text = cparts[2] text = cparts[2]
else: else:
@ -340,6 +348,8 @@ def IRCLoop(on_idle,on_identified,on_command):
if action == None: if action == None:
continue continue
#print 'cparts: ', str(cparts)
#print 'parts: ', str(parts)
#print 'text: ', text #print 'text: ', text
#print 'who: ', who #print 'who: ', who
#print 'action: ', action #print 'action: ', action