mirror of
https://github.com/Syncplay/syncplay
synced 2025-02-09 07:27:01 +00:00
[irc] print traceback on exceptions
This commit is contained in:
parent
76186bc17b
commit
ac02d581b7
@ -6,6 +6,7 @@ import socket
|
|||||||
import threading
|
import threading
|
||||||
from syncplay import utils
|
from syncplay import utils
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
import traceback
|
||||||
|
|
||||||
class Bot(object):
|
class Bot(object):
|
||||||
def __init__(self, server='irc.rizon.net', serverPassword='', port=6667, nick='SyncBot', nickservPass='', channel='', channelPassword='', functions=[]):
|
def __init__(self, server='irc.rizon.net', serverPassword='', port=6667, nick='SyncBot', nickservPass='', channel='', channelPassword='', functions=[]):
|
||||||
@ -172,36 +173,39 @@ def handlingThread(sock, bot):
|
|||||||
while bot.active:
|
while bot.active:
|
||||||
rcvd = sock.recv(4096).split('\n')
|
rcvd = sock.recv(4096).split('\n')
|
||||||
for line in rcvd:
|
for line in rcvd:
|
||||||
line = line.replace('\r', '')
|
try:
|
||||||
|
line = line.replace('\r', '')
|
||||||
|
|
||||||
if line.split(' ')[0] == 'PING':
|
if line.split(' ')[0] == 'PING':
|
||||||
try:
|
try:
|
||||||
sock.send('\r\nPONG ' + line.split(' ')[1].replace(':', '') + '\r\n')
|
sock.send('\r\nPONG ' + line.split(' ')[1].replace(':', '') + '\r\n')
|
||||||
except: #if we were fooled by the server :C
|
except: #if we were fooled by the server :C
|
||||||
sock.send('\r\nPONG\r\n')
|
sock.send('\r\nPONG\r\n')
|
||||||
#\r\n on the beggining too because if we send two things too fast, the IRC server can discern
|
#\r\n on the beggining too because if we send two things too fast, the IRC server can discern
|
||||||
|
|
||||||
lsplit = line.split(':')
|
lsplit = line.split(':')
|
||||||
if len(lsplit) >= 2:
|
if len(lsplit) >= 2:
|
||||||
if len(lsplit[1].split(' ')) >= 2:
|
if len(lsplit[1].split(' ')) >= 2:
|
||||||
if lsplit[1].split(' ')[1] == '404':
|
if lsplit[1].split(' ')[1] == '404':
|
||||||
bot.join(bot.channel, bot.channelPassword)
|
bot.join(bot.channel, bot.channelPassword)
|
||||||
|
|
||||||
if 'PRIVMSG' in lsplit[1] or 'NOTICE' in lsplit[1]:
|
if 'PRIVMSG' in lsplit[1] or 'NOTICE' in lsplit[1]:
|
||||||
# ---BEGIN WTF BLOCK---
|
# ---BEGIN WTF BLOCK---
|
||||||
lsplit = line.split(':')
|
lsplit = line.split(':')
|
||||||
addrnfrom = ''
|
addrnfrom = ''
|
||||||
if '~' in lsplit[1]:
|
if '~' in lsplit[1]:
|
||||||
addrnfrom = lsplit[1].split('~')[1].split(' ')[0]
|
addrnfrom = lsplit[1].split('~')[1].split(' ')[0]
|
||||||
nfrom = lsplit[1].split('!')[0]
|
nfrom = lsplit[1].split('!')[0]
|
||||||
else:
|
else:
|
||||||
nfrom = lsplit[1].split('!')[0]
|
nfrom = lsplit[1].split('!')[0]
|
||||||
|
|
||||||
if len(lsplit[1].split()) >= 3:
|
if len(lsplit[1].split()) >= 3:
|
||||||
to = lsplit[1].split()[2]
|
to = lsplit[1].split()[2]
|
||||||
msg = ''
|
msg = ''
|
||||||
for brks in lsplit[2:]:
|
for brks in lsplit[2:]:
|
||||||
msg += brks + ':'
|
msg += brks + ':'
|
||||||
msg = msg[:-1].lstrip()
|
msg = msg[:-1].lstrip()
|
||||||
# ---END WTF BLOCK- --
|
# ---END WTF BLOCK- --
|
||||||
bot.irc_onMsg(nfrom, addrnfrom, to, msg)
|
bot.irc_onMsg(nfrom, addrnfrom, to, msg)
|
||||||
|
except:
|
||||||
|
print traceback.format_exc()
|
Loading…
Reference in New Issue
Block a user