mirror of
https://git.wownero.com/wownero/tippero.git
synced 2024-08-15 00:33:14 +00:00
More robust field splitting
In particular, this should be resistant against shortened IPv6 addresses
This commit is contained in:
parent
2028230f82
commit
8dbb075a4a
1 changed files with 17 additions and 15 deletions
|
@ -313,21 +313,21 @@ def IRCLoop(on_idle,on_identified,on_command):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
try:
|
try:
|
||||||
cparts = data.split(':')
|
cparts = data.lstrip(':').split(' :')
|
||||||
if len(cparts) < 2:
|
if len(cparts) == 0:
|
||||||
continue
|
continue
|
||||||
if len(cparts) >= 9:
|
#if len(cparts) >= 9:
|
||||||
idx_colon = data.find(':',1)
|
# idx_colon = data.find(':',1)
|
||||||
idx_space = data.find(' ')
|
# 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):
|
# 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')
|
# log_info('Found IPv6 address in non-text, restructuring')
|
||||||
idx = data.rfind(':')
|
# idx = data.rfind(':')
|
||||||
cparts = [ cparts[0], "".join(cparts[1:]) ]
|
# cparts = [ cparts[0], "".join(cparts[1:]) ]
|
||||||
if len(cparts) >= 3:
|
if len(cparts) >= 2:
|
||||||
text = cparts[2]
|
text = cparts[1]
|
||||||
else:
|
else:
|
||||||
text = ""
|
text = ""
|
||||||
parts = cparts[1].split(' ')
|
parts = cparts[0].split(' ')
|
||||||
who = parts[0]
|
who = parts[0]
|
||||||
action = parts[1]
|
action = parts[1]
|
||||||
chan = parts[2]
|
chan = parts[2]
|
||||||
|
@ -406,12 +406,14 @@ def IRCLoop(on_idle,on_identified,on_command):
|
||||||
userstable[who_chan][who_chan_user] = None
|
userstable[who_chan][who_chan_user] = None
|
||||||
log_log("New list of users in %s: %s" % (who_chan, str(userstable[who_chan].keys())))
|
log_log("New list of users in %s: %s" % (who_chan, str(userstable[who_chan].keys())))
|
||||||
except Exception,e:
|
except Exception,e:
|
||||||
log_error('Failed to parse "who" line: %s: %s' % (data, str(e)))
|
log_error('Failed to parse "352" line: %s: %s' % (data, str(e)))
|
||||||
|
|
||||||
elif action == '353':
|
elif action == '353':
|
||||||
try:
|
try:
|
||||||
who_chan = parts[4]
|
who_chan = parts[4]
|
||||||
who_chan_users = cparts[2].split(" ")
|
who_chan_users = cparts[1].split(" ")
|
||||||
|
log_info('who_chan: %s' % str(who_chan))
|
||||||
|
log_info('who_chan_users: %s' % str(who_chan_users))
|
||||||
for who_chan_user in who_chan_users:
|
for who_chan_user in who_chan_users:
|
||||||
if not who_chan_user in userstable[who_chan]:
|
if not who_chan_user in userstable[who_chan]:
|
||||||
if who_chan_user[0] == "@":
|
if who_chan_user[0] == "@":
|
||||||
|
@ -419,7 +421,7 @@ def IRCLoop(on_idle,on_identified,on_command):
|
||||||
userstable[who_chan][who_chan_user] = None
|
userstable[who_chan][who_chan_user] = None
|
||||||
log_log("New list of users in %s: %s" % (who_chan, str(userstable[who_chan].keys())))
|
log_log("New list of users in %s: %s" % (who_chan, str(userstable[who_chan].keys())))
|
||||||
except Exception,e:
|
except Exception,e:
|
||||||
log_error('Failed to parse "who" line: %s: %s' % (data, str(e)))
|
log_error('Failed to parse "353" line: %s: %s' % (data, str(e)))
|
||||||
|
|
||||||
elif action == 'PRIVMSG':
|
elif action == 'PRIVMSG':
|
||||||
UpdateLastActiveTime(chan,GetNick(who))
|
UpdateLastActiveTime(chan,GetNick(who))
|
||||||
|
|
Loading…
Reference in a new issue