Log everything send to IRC

This commit is contained in:
moneromooo 2014-12-25 22:03:51 +00:00
parent 159528d7f7
commit 345234ded0

View file

@ -79,6 +79,13 @@ def log_log(msg):
def log_IRCRECV(msg): def log_IRCRECV(msg):
log("IRCRECV",msg) log("IRCRECV",msg)
def log_IRCSEND(msg):
log("IRCSEND",msg)
def SendIRC(msg):
log_IRCSEND(msg)
irc.send(msg + '\r\n')
def connect_to_irc(network,port): def connect_to_irc(network,port):
global irc global irc
try: try:
@ -88,9 +95,9 @@ def connect_to_irc(network,port):
log_error( 'Error initializing IRC: %s' % str(e)) log_error( 'Error initializing IRC: %s' % str(e))
exit() exit()
log_IRCRECV(irc.recv ( 4096 )) log_IRCRECV(irc.recv ( 4096 ))
irc.send ( 'PASS *********\r\n') SendIRC ( 'PASS *********')
irc.send ( 'NICK %s\r\n' % tipbot_name) SendIRC ( 'NICK %s' % tipbot_name)
irc.send ( 'USER %s %s %s :%s\r\n' % (tipbot_name, tipbot_name, tipbot_name, tipbot_name)) SendIRC ( 'USER %s %s %s :%s' % (tipbot_name, tipbot_name, tipbot_name, tipbot_name))
def connect_to_redis(host,port): def connect_to_redis(host,port):
try: try:
@ -131,19 +138,19 @@ def GetPassword():
return "xxx" return "xxx"
def Send(msg): def Send(msg):
irc.send('PRIVMSG ' + irc_homechan + ' : ' + msg + '\r\n') SendIRC ('PRIVMSG ' + irc_homechan + ' : ' + msg)
def SendTo(where,msg): def SendTo(where,msg):
irc.send('PRIVMSG ' + where + ' : ' + msg + '\r\n') SendIRC ('PRIVMSG ' + where + ' : ' + msg)
def Join(chan): def Join(chan):
irc.send ( 'JOIN ' + chan + '\r\n' ) SendIRC ( 'JOIN ' + chan)
def Part(chan): def Part(chan):
irc.send ( 'PART ' + chan + '\r\n' ) SendIRC ( 'PART ' + chan)
def Who(chan): def Who(chan):
irc.send ( 'WHO ' + chan + '\r\n' ) SendIRC ( 'WHO ' + chan)
def CheckRegistered(nick,ifyes,yesdata,ifno,nodata): def CheckRegistered(nick,ifyes,yesdata,ifno,nodata):
if nick not in calltable: if nick not in calltable:
@ -703,16 +710,16 @@ def UpdateCoin():
last_wallet_update_time = time.time() last_wallet_update_time = time.time()
#def Op(to_op, chan): #def Op(to_op, chan):
# irc.send( 'MODE ' + chan + ' +o: ' + to_op + '\r\n') # SendIRC( 'MODE ' + chan + ' +o: ' + to_op)
# #
#def DeOp(to_deop, chan): #def DeOp(to_deop, chan):
# irc.send( 'MODE ' + chan + ' -o: ' + to_deop + '\r\n') # SendIRC( 'MODE ' + chan + ' -o: ' + to_deop)
# #
#def Voice(to_v, chan): #def Voice(to_v, chan):
# irc.send( 'MODE ' + chan + ' +v: ' + to_v + '\r\n') # SendIRC( 'MODE ' + chan + ' +v: ' + to_v)
# #
#def DeVoice(to_dv, chan): #def DeVoice(to_dv, chan):
# irc.send( 'MODE ' + chan + ' -v: ' + to_dv + '\r\n') # SendIRC( 'MODE ' + chan + ' -v: ' + to_dv)
#------------------------------------------------------------------------------# #------------------------------------------------------------------------------#
buffered_data = "" buffered_data = ""
@ -791,7 +798,7 @@ while True:
if data.find ( 'PING' ) == 0: if data.find ( 'PING' ) == 0:
log_log('Got PING, replying PONG') log_log('Got PING, replying PONG')
last_ping_time = time.time() last_ping_time = time.time()
irc.send ( 'PONG ' + data.split() [ 1 ] + '\r\n' ) SendIRC ( 'PONG ' + data.split() [ 1 ])
continue continue
if data.find('ERROR :Closing Link:') == 0: if data.find('ERROR :Closing Link:') == 0: