From d5ab3b88f52c79d762d651d50989c8661dba24b7 Mon Sep 17 00:00:00 2001 From: moneromooo Date: Sat, 24 Jan 2015 11:31:53 +0000 Subject: [PATCH] Split GetBalance to a core RetrieveBalance and the user command --- tipbot.py | 6 +----- tipbot/utils.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/tipbot.py b/tipbot.py index 1da0c41..2e6d618 100644 --- a/tipbot.py +++ b/tipbot.py @@ -89,12 +89,8 @@ for modulename in modulenames: def GetBalance(link,cmd): nick=link.user.nick - log_log("GetBalance: checking %s (%s)" % (link.identity(),str(link))) try: - balance = redis_hget("balances",link.identity()) - if balance == None: - balance = 0 - balance = long(balance) + balance = RetrieveBalance(link) sbalance = AmountToString(balance) if balance < coinspecs.atomic_units: if balance == 0: diff --git a/tipbot/utils.py b/tipbot/utils.py index 0321af0..f9ca431 100644 --- a/tipbot/utils.py +++ b/tipbot/utils.py @@ -212,6 +212,16 @@ def RetrieveTipbotBalance(): return return balance, unlocked_balance +def RetrieveBalance(link): + try: + balance = redis_hget("balances",link.identity()) + if balance == None: + balance = 0 + return long(balance) + except Exception, e: + log_error('RetrieveBalance: exception: %s' % str(e)) + raise + def IdentityFromString(link,s): if s.find(':') == -1: network = link.network.name