From 49a9923fa0599216400a063e24606b8a1ea1302c Mon Sep 17 00:00:00 2001 From: lza_menace Date: Mon, 20 Jul 2020 09:41:46 -0700 Subject: [PATCH] adding some rudimentary logging for now just to see basic activity --- tipbot/commands.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tipbot/commands.py b/tipbot/commands.py index 01412dd..8462f5c 100644 --- a/tipbot/commands.py +++ b/tipbot/commands.py @@ -7,6 +7,13 @@ from functools import wraps from decimal import Decimal +def log_event(f): + @wraps(f) + def decorated_function(*args, **kwargs): + logging.info(f'"{f.__name__}" called by {args[0].effective_chat.username}') + return f(*args, **kwargs) + return decorated_function + def wallet_rpc_required(f): @wraps(f) def decorated_function(*args, **kwargs): @@ -41,6 +48,7 @@ def help(update, context): update.message.reply_text('Here are the available commands for this bot:\n\n' + '\n\n'.join(commands)) @wallet_rpc_required +@log_event def register(update, context): uid = update.effective_chat.id un = update.effective_chat.username @@ -73,6 +81,7 @@ def register(update, context): @wallet_rpc_required @registration_required +@log_event def tip(update, context): if len(context.args) < 2: update.message.reply_text('Not enough arguments passed.') @@ -134,6 +143,7 @@ def tip(update, context): @wallet_rpc_required @registration_required +@log_event def send(update, context): if len(context.args) < 2: update.message.reply_text('Not enough arguments passed.') @@ -174,6 +184,7 @@ def send(update, context): @wallet_rpc_required @registration_required +@log_event def balance(update, context): u = db.User.get(telegram_id=update.effective_chat.id) balances = wownero.Wallet().balances(account=u.account_index) @@ -181,12 +192,14 @@ def balance(update, context): @wallet_rpc_required @registration_required +@log_event def deposit(update, context): u = db.User.get(telegram_id=update.effective_chat.id) address = wownero.Wallet().addresses(account=u.account_index)[0] update.message.reply_text(f'Deposit address for {update.effective_chat.username}: {address}') @wallet_rpc_required +@log_event def debug(update, context): if is_tg_admin(update.effective_chat.id): # tx = wownero.Wallet().transfer(