use message construct instead of `effective_chat`

master
lza_menace 4 years ago
parent 49a9923fa0
commit a8c5e5ea59

@ -10,7 +10,7 @@ from decimal import Decimal
def log_event(f): def log_event(f):
@wraps(f) @wraps(f)
def decorated_function(*args, **kwargs): 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 f(*args, **kwargs)
return decorated_function return decorated_function
@ -50,8 +50,8 @@ def help(update, context):
@wallet_rpc_required @wallet_rpc_required
@log_event @log_event
def register(update, context): def register(update, context):
uid = update.effective_chat.id uid = update.message.from_user['id']
un = update.effective_chat.username un = update.message.from_user['username']
if db.User.filter(telegram_id=uid): if db.User.filter(telegram_id=uid):
update.message.reply_text('You are already registered.') update.message.reply_text('You are already registered.')
else: 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.') update.message.reply_text('Bad Wownero amount specified. Provide only positive integers or decimals greater than or equal to 1.')
return False 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) tipper_balances = wownero.Wallet().balances(account=tipper.account_index)
if amount > tipper_balances[1]: if amount > tipper_balances[1]:
update.message.reply_text(f'You do not have sufficient funds to send {amount} WOW. Check your /balance') 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.') update.message.reply_text('Bad Wownero amount specified. Provide only positive integers or decimals greater than or equal to 1.')
return False 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) tipper_balances = wownero.Wallet().balances(account=tipper.account_index)
if amount > tipper_balances[1]: if amount > tipper_balances[1]:
update.message.reply_text(f'You do not have sufficient funds to send {amount} WOW. Check your /balance') 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 @registration_required
@log_event @log_event
def balance(update, context): 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) 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)') 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 @registration_required
@log_event @log_event
def deposit(update, context): 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] address = wownero.Wallet().addresses(account=u.account_index)[0]
update.message.reply_text(f'Deposit address for {update.effective_chat.username}: {address}') update.message.reply_text(f'Deposit address for {update.effective_chat.username}: {address}')
@wallet_rpc_required @wallet_rpc_required
@log_event @log_event
def debug(update, context): 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( # tx = wownero.Wallet().transfer(
# dest_address='WW2vmEGV68ZFeQWwPEJda3UcdWCPfWBnDK1Y6MB9Uojx9adBhCxfx9F51TomRjmD3z7Gyogie3mfVQEkRQjLxqbs1KMzaozDw', # dest_address='WW2vmEGV68ZFeQWwPEJda3UcdWCPfWBnDK1Y6MB9Uojx9adBhCxfx9F51TomRjmD3z7Gyogie3mfVQEkRQjLxqbs1KMzaozDw',
# amount=Decimal(2), # amount=Decimal(2),
@ -215,7 +215,7 @@ def debug(update, context):
# a = [] # a = []
# for i in accounts: # for i in accounts:
# a.append(str(wownero.Wallet().balances(account=i)[1])) # a.append(str(wownero.Wallet().balances(account=i)[1]))
update.message.reply_text("sup") update.message.reply_text('sup lza')
else: else:
update.message.reply_text('you cant do that.') update.message.reply_text('you cant do that.')

Loading…
Cancel
Save