From a8c5e5ea59095fb569519caa6b84424c15f2c290 Mon Sep 17 00:00:00 2001 From: lza_menace Date: Mon, 20 Jul 2020 13:26:38 -0700 Subject: [PATCH] use message construct instead of `effective_chat` --- tipbot/commands.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tipbot/commands.py b/tipbot/commands.py index 8462f5c..4c81ac0 100644 --- a/tipbot/commands.py +++ b/tipbot/commands.py @@ -10,7 +10,7 @@ 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}') + logging.info(f'"{f.__name__}" called by {args[0].message.from_user["username"]}') return f(*args, **kwargs) return decorated_function @@ -50,8 +50,8 @@ def help(update, context): @wallet_rpc_required @log_event def register(update, context): - uid = update.effective_chat.id - un = update.effective_chat.username + uid = update.message.from_user['id'] + un = update.message.from_user['username'] if db.User.filter(telegram_id=uid): update.message.reply_text('You are already registered.') else: @@ -120,7 +120,7 @@ def tip(update, context): update.message.reply_text('Bad Wownero amount specified. Provide only positive integers or decimals greater than or equal to 1.') return False - tipper = db.User.get(telegram_id=update.effective_chat.id) + tipper = db.User.get(telegram_id=update.message.from_user['id']) tipper_balances = wownero.Wallet().balances(account=tipper.account_index) if amount > tipper_balances[1]: update.message.reply_text(f'You do not have sufficient funds to send {amount} WOW. Check your /balance') @@ -167,7 +167,7 @@ def send(update, context): update.message.reply_text('Bad Wownero amount specified. Provide only positive integers or decimals greater than or equal to 1.') return False - tipper = db.User.get(telegram_id=update.effective_chat.id) + tipper = db.User.get(telegram_id=update.message.from_user['id']) tipper_balances = wownero.Wallet().balances(account=tipper.account_index) if amount > tipper_balances[1]: update.message.reply_text(f'You do not have sufficient funds to send {amount} WOW. Check your /balance') @@ -186,7 +186,7 @@ def send(update, context): @registration_required @log_event def balance(update, context): - u = db.User.get(telegram_id=update.effective_chat.id) + u = db.User.get(telegram_id=update.message.from_user['id']) balances = wownero.Wallet().balances(account=u.account_index) update.message.reply_text(f'Available balance for {update.effective_chat.username}: {balances[1]} ({balances[0]} locked)') @@ -194,14 +194,14 @@ def balance(update, context): @registration_required @log_event def deposit(update, context): - u = db.User.get(telegram_id=update.effective_chat.id) + u = db.User.get(telegram_id=update.message.from_user['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): + if is_tg_admin(update.message.from_user['id']): # tx = wownero.Wallet().transfer( # dest_address='WW2vmEGV68ZFeQWwPEJda3UcdWCPfWBnDK1Y6MB9Uojx9adBhCxfx9F51TomRjmD3z7Gyogie3mfVQEkRQjLxqbs1KMzaozDw', # amount=Decimal(2), @@ -215,7 +215,7 @@ def debug(update, context): # a = [] # for i in accounts: # a.append(str(wownero.Wallet().balances(account=i)[1])) - update.message.reply_text("sup") + update.message.reply_text('sup lza') else: update.message.reply_text('you cant do that.')