mirror of
https://git.wownero.com/wownero/tippero.git
synced 2024-08-15 00:33:14 +00:00
Move module specific help to modules
This commit is contained in:
parent
ce3c69b339
commit
44d6f01378
4 changed files with 45 additions and 26 deletions
26
tipbot.py
26
tipbot.py
|
@ -80,21 +80,6 @@ for modulename in modulenames:
|
|||
|
||||
|
||||
|
||||
def GetTipbotAddress():
|
||||
try:
|
||||
j = SendWalletJSONRPCCommand("getaddress",None)
|
||||
if not "result" in j:
|
||||
log_error('GetTipbotAddress: No result found in getaddress reply')
|
||||
return ERROR
|
||||
result = j["result"]
|
||||
if not "address" in result:
|
||||
log_error('GetTipbotAddress: No address found in getaddress reply')
|
||||
return ERROR
|
||||
return result["address"]
|
||||
except Exception,e:
|
||||
log_error("GetTipbotAddress: Error retrieving %s's address: %s" % (config.tipbot_name, str(e)))
|
||||
return "ERROR"
|
||||
|
||||
def GetBalance(nick,chan,cmd):
|
||||
sendto=GetSendTo(nick,chan)
|
||||
log_log("GetBalance: checking %s" % nick)
|
||||
|
@ -179,16 +164,7 @@ def DumpUsers(nick,chan,cmd):
|
|||
|
||||
def Help(nick,chan,cmd):
|
||||
SendTo(nick, "See available commands with !commands or !commands <modulename>")
|
||||
if 'payment' in modulenames:
|
||||
SendTo(nick, "You can send %s to your account:" % coinspecs.name);
|
||||
SendTo(nick, " Address: %s" % GetTipbotAddress())
|
||||
SendTo(nick, " Payment ID: %s" % GetPaymentID(nick))
|
||||
SendTo(nick, "NO WARRANTY, YOU MAY LOSE YOUR COINS")
|
||||
if 'withdraw' in modulenames:
|
||||
fee = config.withdrawal_fee or coinspecs.min_withdrawal_fee
|
||||
min_amount = config.min_withdraw_amount or fee
|
||||
SendTo(nick, "Minimum withdrawal: %s" % AmountToString(min_amount))
|
||||
SendTo(nick, "Withdrawal fee: %s" % AmountToString(fee))
|
||||
RunHelpFunctions(nick)
|
||||
if coinspecs.web_wallet_url:
|
||||
SendTo(nick, "No %s address ? You can use %s" % (coinspecs.name, coinspecs.web_wallet_url))
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ commands = dict()
|
|||
calltable=dict()
|
||||
idles = []
|
||||
cleanup = dict()
|
||||
helps = dict()
|
||||
|
||||
def RunRegisteredCommand(nick,chan,ifyes,yesdata,ifno,nodata):
|
||||
if nick not in calltable:
|
||||
|
@ -101,6 +102,9 @@ def RegisterIdleFunction(module,function):
|
|||
def RegisterCleanupFunction(module,function):
|
||||
cleanup.append((module,function))
|
||||
|
||||
def RegisterHelpFunction(module,function):
|
||||
helps[module]=function
|
||||
|
||||
def OnCommand(cmd,chan,who,check_admin,check_registered):
|
||||
if cmd[0] in commands:
|
||||
c = commands[cmd[0]]
|
||||
|
@ -120,9 +124,17 @@ def RunIdleFunctions(param):
|
|||
except Exception,e:
|
||||
log_error("Exception running idle function %s from module %s: %s" % (str(f[1]),str(f[2]),str(e)))
|
||||
|
||||
def RunHelpFunctions(param):
|
||||
for f in helps:
|
||||
try:
|
||||
helps[f](param)
|
||||
except Exception,e:
|
||||
log_error("Exception running help function %s from module %s: %s" % (str(helps[f]),str(f),str(e)))
|
||||
|
||||
def UnregisterCommands(module):
|
||||
global commands
|
||||
global idles
|
||||
global helps
|
||||
|
||||
if module in cleanup:
|
||||
cleanup[module]()
|
||||
|
@ -134,6 +146,9 @@ def UnregisterCommands(module):
|
|||
new_idles.append(f)
|
||||
idles = new_idles
|
||||
|
||||
if module in helps:
|
||||
del helps[module]
|
||||
|
||||
new_commands = dict()
|
||||
for cmd in commands:
|
||||
c = commands[cmd]
|
||||
|
|
|
@ -20,6 +20,21 @@ from tipbot.command_manager import *
|
|||
|
||||
last_wallet_update_time = None
|
||||
|
||||
def GetTipbotAddress():
|
||||
try:
|
||||
j = SendWalletJSONRPCCommand("getaddress",None)
|
||||
if not "result" in j:
|
||||
log_error('GetTipbotAddress: No result found in getaddress reply')
|
||||
return ERROR
|
||||
result = j["result"]
|
||||
if not "address" in result:
|
||||
log_error('GetTipbotAddress: No address found in getaddress reply')
|
||||
return ERROR
|
||||
return result["address"]
|
||||
except Exception,e:
|
||||
log_error("GetTipbotAddress: Error retrieving %s's address: %s" % (config.tipbot_name, str(e)))
|
||||
return "ERROR"
|
||||
|
||||
def UpdateCoin(param):
|
||||
irc = param[0]
|
||||
redisdb = param[1]
|
||||
|
@ -89,5 +104,11 @@ def UpdateCoin(param):
|
|||
log_error('UpdateCoin: Failed to get bulk payments: %s' % str(e))
|
||||
last_wallet_update_time = time.time()
|
||||
|
||||
RegisterIdleFunction(__name__,UpdateCoin)
|
||||
def Help(nick):
|
||||
SendTo(nick, "You can send %s to your account:" % coinspecs.name);
|
||||
SendTo(nick, " Address: %s" % GetTipbotAddress())
|
||||
SendTo(nick, " Payment ID: %s" % GetPaymentID(nick))
|
||||
|
||||
RegisterIdleFunction(__name__,UpdateCoin)
|
||||
RegisterHelpFunction(__name__,Help)
|
||||
|
||||
|
|
|
@ -144,6 +144,12 @@ def Withdraw(nick,chan,cmd):
|
|||
log_error('Withdraw: FAILED TO SUBTRACT BALANCE: exception: %s' % str(e))
|
||||
CheckDisableWithdraw()
|
||||
|
||||
def Help(nick):
|
||||
fee = config.withdrawal_fee or coinspecs.min_withdrawal_fee
|
||||
min_amount = config.min_withdraw_amount or fee
|
||||
SendTo(nick, "Minimum withdrawal: %s" % AmountToString(min_amount))
|
||||
SendTo(nick, "Withdrawal fee: %s" % AmountToString(fee))
|
||||
|
||||
|
||||
|
||||
RegisterCommand({
|
||||
|
@ -168,3 +174,4 @@ RegisterCommand({
|
|||
'admin': True,
|
||||
'help': "Disable withdrawals"
|
||||
})
|
||||
RegisterHelpFunction(__name__,Help)
|
||||
|
|
Loading…
Reference in a new issue