From 0e3d8d3d4bd5e4d0a57544e8a31844f5285213f9 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Wed, 1 Jun 2016 13:39:41 +0200 Subject: [PATCH] fatto #19 --- main.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/main.py b/main.py index a490b44..534363d 100644 --- a/main.py +++ b/main.py @@ -677,6 +677,26 @@ def kill(bot, update): bot.sendMessage(update.message.chat['id'], s.error_no_games_found, parse_mode=ParseMode.MARKDOWN) +def delete(bot, update): + """Elimina una partita in corso.""" + if update.message.chat['type'] == 'private': + if update.message.from_user['username'] == "Steffo": + cmd = update.message.text.split(' ', 2) + game = findgamebyname(cmd[1]) + # Se non lo trovi con il nome, prova con l'id + if game is None: + game = findgamebyid(int(cmd[1])) + if game is not None: + game.message(bot, g.owner_ended) + game.endgame() + else: + game.message(bot, s.error_no_games_found) + else: + bot.sendMessage(update.message.chat['id'], s.error_not_owner, parse_mode=ParseMode.MARKDOWN) + else: + bot.sendMessage(update.message.chat['id'], s.error_chat_type, parse_mode=ParseMode.MARKDOWN) + + def fakerole(bot, update): """Manda un finto messaggio di ruolo.""" if update.message.chat['type'] == 'private': @@ -759,6 +779,7 @@ updater.dispatcher.addHandler(CommandHandler('config', config)) updater.dispatcher.addHandler(CommandHandler('fakerole', fakerole)) updater.dispatcher.addHandler(CommandHandler('save', save)) updater.dispatcher.addHandler(CommandHandler('load', load)) +updater.dispatcher.addHandler(CommandHandler('delete', delete)) updater.start_polling() print("Bot avviato!") if __name__ == "__main__":