From 63a1939fd05a5ab947da28bea8e3023e580f707f Mon Sep 17 00:00:00 2001 From: lza_menace Date: Thu, 6 Aug 2020 01:24:39 -0700 Subject: [PATCH] fix markdown syntax and include more debug msg for user --- tipbot/commands/tip.py | 7 +++++-- tipbot/commands/withdraw.py | 9 ++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/tipbot/commands/tip.py b/tipbot/commands/tip.py index b125bb8..191508b 100644 --- a/tipbot/commands/tip.py +++ b/tipbot/commands/tip.py @@ -1,5 +1,6 @@ import logging from decimal import Decimal +from telegram import ParseMode from tipbot import wownero from tipbot import db from tipbot.helpers.decorators import wallet_rpc_required, log_event, registration_required @@ -61,9 +62,11 @@ def tip(update, context): tx = wownero.Wallet().transfer(dest_address=address, amount=wownero.as_wownero(amount), priority=2, account=tipper.account_index) if 'tx_hash' in tx: h = tx['tx_hash'] - update.message.reply_text(f'Tipped @{target_un} {amount} WOW! TX ID: [{h}](https://wownero.xmrauctions.com/transaction/{h})') + msg = f'Tipped @{target_un} {amount} WOW! TX ID: [{h}](https://wownero.xmrauctions.com/transaction/{h})' + update.message.reply_text(msg, parse_mode=ParseMode.MARKDOWN_V2) else: - update.message.reply_text('Failed to send a tip. Ask for help.') + logging.error(f'Transaction failure details for {tipper.telegram_user} ({tipper.telegram_id}): {tx}') + update.message.reply_text(f'Failed to send a tip. Reason: "{tx["message"]}"') except Exception as e: logging.error(f'Unable to send transfer: {e}. Debug: {update.message}') update.message.reply_text('Failed to send a tip. Ask for help.') diff --git a/tipbot/commands/withdraw.py b/tipbot/commands/withdraw.py index 7202afd..7f2633f 100644 --- a/tipbot/commands/withdraw.py +++ b/tipbot/commands/withdraw.py @@ -1,5 +1,6 @@ import logging from decimal import Decimal +from telegram import ParseMode from tipbot import wownero from tipbot import db from tipbot.helpers.decorators import wallet_rpc_required, log_event, registration_required @@ -42,9 +43,11 @@ def withdraw(update, context): tx = wownero.Wallet().transfer(dest_address=address, amount=wownero.as_wownero(amount), priority=2, account=sender.account_index) if 'tx_hash' in tx: h = tx['tx_hash'] - update.message.reply_text(f'Sent {amount} WOW! TX ID: [{h}](https://wownero.xmrauctions.com/transaction/{h})') + msg = f'Sent {amount} WOW! TX ID: [{h}](https://wownero.xmrauctions.com/transaction/{h})' + update.message.reply_text(msg, parse_mode=ParseMode.MARKDOWN_V2) else: - update.message.reply_text('Failed to send Wownero. Ask for help.') + logging.error(f'Transaction failure details for {sender.telegram_user} ({sender.telegram_id}): {tx}') + update.message.reply_text(f'Failed to withdraw Wownero. Reason: "{tx["message"]}"') except Exception as e: logging.error(f'Unable to send transfer: {e}. Debug: {update.message}') - update.message.reply_text('Failed to send Wownero. Ask for help.') + update.message.reply_text('Failed to withdraw Wownero. Ask for help.')