mirror of
https://git.wownero.com/wownero/tippero.git
synced 2024-08-15 00:33:14 +00:00
Misc fixes
User tracking fixes Ensure scan_block_height is correctly set at start Switch to fluffypony's testnet bitmonerod Regard any IRC input as a ping for reconnect timeout purposes
This commit is contained in:
parent
f8cf06c197
commit
df5fe49c82
1 changed files with 44 additions and 11 deletions
55
tipbot.py
55
tipbot.py
|
@ -23,8 +23,8 @@ irc_homechan = '#txtptest000'
|
||||||
redis_host="127.0.0.1"
|
redis_host="127.0.0.1"
|
||||||
redis_port=7777
|
redis_port=7777
|
||||||
|
|
||||||
bitmonerod_host = '127.0.0.1'
|
bitmonerod_host = 'testfull.monero.cc' # '127.0.0.1'
|
||||||
bitmonerod_port = 6060
|
bitmonerod_port = 28081 # 6060
|
||||||
wallet_host = '127.0.0.1'
|
wallet_host = '127.0.0.1'
|
||||||
wallet_port = 6061
|
wallet_port = 6061
|
||||||
wallet_update_time = 30 # seconds
|
wallet_update_time = 30 # seconds
|
||||||
|
@ -72,7 +72,7 @@ def connect_to_irc(network,port):
|
||||||
|
|
||||||
def connect_to_redis(host,port):
|
def connect_to_redis(host,port):
|
||||||
try:
|
try:
|
||||||
redis = redis.Redis(host=host,port=port)
|
return redis.Redis(host=host,port=port)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
log_error( 'Error initializing redis: %s' % str(e))
|
log_error( 'Error initializing redis: %s' % str(e))
|
||||||
exit()
|
exit()
|
||||||
|
@ -544,6 +544,9 @@ def EnableWithdraw(nick,data):
|
||||||
log_info('EnableWithdraw: enabled by %s' % nick)
|
log_info('EnableWithdraw: enabled by %s' % nick)
|
||||||
withdraw_disabled = False
|
withdraw_disabled = False
|
||||||
|
|
||||||
|
def DumpUsers(nick,data):
|
||||||
|
log_info(str(userstable))
|
||||||
|
|
||||||
def Help(nick):
|
def Help(nick):
|
||||||
SendTo(nick, "Help for the monero tipbot:")
|
SendTo(nick, "Help for the monero tipbot:")
|
||||||
SendTo(nick, "!isregistered - show whether you are currently registered with freenode")
|
SendTo(nick, "!isregistered - show whether you are currently registered with freenode")
|
||||||
|
@ -572,6 +575,16 @@ def Info(nick):
|
||||||
SendTo(nick, "return of any monero. Use at your own risk.")
|
SendTo(nick, "return of any monero. Use at your own risk.")
|
||||||
SendTo(nick, "That being said, I hope you enjoy using it :)")
|
SendTo(nick, "That being said, I hope you enjoy using it :)")
|
||||||
|
|
||||||
|
def InitScanBlockHeight():
|
||||||
|
try:
|
||||||
|
scan_block_height = redis.get("scan_block_height")
|
||||||
|
scan_block_height = long(scan_block_height)
|
||||||
|
except Exception,e:
|
||||||
|
try:
|
||||||
|
redis.set("scan_block_height",0)
|
||||||
|
except Exception,e:
|
||||||
|
log_error('Failed to initialize scan_block_height: %s' % str(e))
|
||||||
|
|
||||||
def UpdateCoin():
|
def UpdateCoin():
|
||||||
global last_wallet_update_time
|
global last_wallet_update_time
|
||||||
if last_wallet_update_time == None:
|
if last_wallet_update_time == None:
|
||||||
|
@ -683,7 +696,8 @@ def getline(s):
|
||||||
|
|
||||||
|
|
||||||
connect_to_irc(irc_network,irc_port)
|
connect_to_irc(irc_network,irc_port)
|
||||||
connect_to_redis(irc_network,irc_port)
|
redis = connect_to_redis(redis_host,redis_port)
|
||||||
|
InitScanBlockHeight()
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
action = None
|
action = None
|
||||||
|
@ -693,8 +707,8 @@ while True:
|
||||||
UpdateCoin()
|
UpdateCoin()
|
||||||
|
|
||||||
if data == None:
|
if data == None:
|
||||||
if time.time() - last_ping_time > 60:
|
if time.time() - last_ping_time > 600:
|
||||||
log_warn('60 seconds without PING, reconnecting')
|
log_warn('600 seconds without PING, reconnecting')
|
||||||
last_ping_time = time.time()
|
last_ping_time = time.time()
|
||||||
connect_to_irc(irc_network,irc_port)
|
connect_to_irc(irc_network,irc_port)
|
||||||
continue
|
continue
|
||||||
|
@ -702,6 +716,9 @@ while True:
|
||||||
data = data.strip("\r\n")
|
data = data.strip("\r\n")
|
||||||
log_IRCRECV(data)
|
log_IRCRECV(data)
|
||||||
|
|
||||||
|
# consider any IRC data as a ping
|
||||||
|
last_ping_time = time.time()
|
||||||
|
|
||||||
if data.find ( 'Welcome to the freenode Internet Relay Chat Network' ) != -1:
|
if data.find ( 'Welcome to the freenode Internet Relay Chat Network' ) != -1:
|
||||||
SendTo("nickserv", "IDENTIFY %s" % GetPassword())
|
SendTo("nickserv", "IDENTIFY %s" % GetPassword())
|
||||||
Join(irc_homechan)
|
Join(irc_homechan)
|
||||||
|
@ -718,14 +735,14 @@ while True:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
try:
|
try:
|
||||||
parts = data.split(':')
|
cparts = data.split(':')
|
||||||
if len(parts) < 2:
|
if len(cparts) < 2:
|
||||||
continue
|
continue
|
||||||
if len(parts) >= 3:
|
if len(cparts) >= 3:
|
||||||
text = parts[2]
|
text = cparts[2]
|
||||||
else:
|
else:
|
||||||
text = ""
|
text = ""
|
||||||
parts = parts[1].split(' ')
|
parts = cparts[1].split(' ')
|
||||||
who = parts[0]
|
who = parts[0]
|
||||||
action = parts[1]
|
action = parts[1]
|
||||||
chan = parts[2]
|
chan = parts[2]
|
||||||
|
@ -786,6 +803,20 @@ while True:
|
||||||
except Exception,e:
|
except Exception,e:
|
||||||
log_error('Failed to parse "who" line: %s: %s' % (data, str(e)))
|
log_error('Failed to parse "who" line: %s: %s' % (data, str(e)))
|
||||||
|
|
||||||
|
elif action == '353':
|
||||||
|
try:
|
||||||
|
log_log("parts: %s" % str(parts))
|
||||||
|
who_chan = parts[4]
|
||||||
|
who_chan_users = cparts[2].split(" ")
|
||||||
|
for who_chan_user in who_chan_users:
|
||||||
|
if not who_chan_user in userstable[who_chan]:
|
||||||
|
if who_chan_user[0] == "@":
|
||||||
|
who_chan_user = who_chan_user[1:]
|
||||||
|
userstable[who_chan].append(who_chan_user)
|
||||||
|
log_log("New list of users in %s: %s" % (who_chan, str(userstable[who_chan])))
|
||||||
|
except Exception,e:
|
||||||
|
log_error('Failed to parse "who" line: %s: %s' % (data, str(e)))
|
||||||
|
|
||||||
elif action == 'PRIVMSG':
|
elif action == 'PRIVMSG':
|
||||||
if text.find('!') != -1:
|
if text.find('!') != -1:
|
||||||
cmd = text.split('!')[1]
|
cmd = text.split('!')[1]
|
||||||
|
@ -842,6 +873,8 @@ while True:
|
||||||
CheckAdmin(GetNick(who),ScanWho,[chan],SendTo,"You must be admin")
|
CheckAdmin(GetNick(who),ScanWho,[chan],SendTo,"You must be admin")
|
||||||
elif cmd[0] == 'enable_withdraw':
|
elif cmd[0] == 'enable_withdraw':
|
||||||
CheckAdmin(GetNick(who),EnableWithdraw,None,SendTo,"You must be admin")
|
CheckAdmin(GetNick(who),EnableWithdraw,None,SendTo,"You must be admin")
|
||||||
|
elif cmd[0] == 'dump_users':
|
||||||
|
CheckAdmin(GetNick(who),DumpUsers,None,SendTo,"You must be admin")
|
||||||
else:
|
else:
|
||||||
SendTo(GetNick(who), "Invalid command, try !help")
|
SendTo(GetNick(who), "Invalid command, try !help")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue