From 6964bcd7022c368a8fc87088c8541619fedb2381 Mon Sep 17 00:00:00 2001 From: nyanloutre Date: Sun, 8 Oct 2017 16:47:59 +0200 Subject: [PATCH] Gestion erreurs --- run.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/run.py b/run.py index 2a8ad46..079ccf6 100644 --- a/run.py +++ b/run.py @@ -92,12 +92,15 @@ def dogetip(bot, update, args): if unit == "doge": response = transaction(update.message.from_user.username, destinataire, montant) - txid = response['data']['txid'] - - message = '🚀 Transaction effectuée 🚀\n\n' \ - + str(montant) + ' ' + NETWORK + '\n' \ - + '@' + update.message.from_user.username + ' → @' + destinataire + '\n\n' \ - + 'Voir la transaction' + try: + txid = response['data']['txid'] + except TypeError: + message = response + else: + message = '🚀 Transaction effectuée 🚀\n\n' \ + + str(montant) + ' ' + NETWORK + '\n' \ + + '@' + update.message.from_user.username + ' → @' + destinataire + '\n\n' \ + + 'Voir la transaction' bot.send_message(chat_id=update.message.chat_id, parse_mode=ParseMode.HTML, text=message)