Utilisation des exception pour vérifier les arguments
This commit is contained in:
parent
08655dfde4
commit
ad54b68c07
9
run.py
9
run.py
@ -81,14 +81,13 @@ def start(bot, update):
|
|||||||
bot.send_message(chat_id=update.message.chat_id, text="Bark ! Je suis un tipbot Dogecoin ! \n\n Pour commencer envoyez moi /register")
|
bot.send_message(chat_id=update.message.chat_id, text="Bark ! Je suis un tipbot Dogecoin ! \n\n Pour commencer envoyez moi /register")
|
||||||
|
|
||||||
def dogetip(bot, update, args):
|
def dogetip(bot, update, args):
|
||||||
|
try:
|
||||||
if len(args != 3):
|
|
||||||
bot.send_message(chat_id=update.message.chat_id, text="Syntaxe : /dogetip xxx doge @destinataire")
|
|
||||||
else:
|
|
||||||
montant = int(args[0])
|
montant = int(args[0])
|
||||||
unit = args[1]
|
unit = args[1]
|
||||||
destinataire = args[2][1:]
|
destinataire = args[2][1:]
|
||||||
|
except (IndexError, ValueError):
|
||||||
|
bot.send_message(chat_id=update.message.chat_id, text="Syntaxe : /dogetip xxx doge @destinataire")
|
||||||
|
else:
|
||||||
try:
|
try:
|
||||||
if unit == "doge":
|
if unit == "doge":
|
||||||
response = transaction(update.message.from_user.username, destinataire, montant)
|
response = transaction(update.message.from_user.username, destinataire, montant)
|
||||||
|
Loading…
Reference in New Issue
Block a user