From 844b1dddfc60f8501b20aba70a8b882fafabbdd8 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 9 Apr 2018 23:02:24 +0200 Subject: [PATCH] More fixes? Or bugs? --- telegrambot.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/telegrambot.py b/telegrambot.py index adb41d26..694f9644 100644 --- a/telegrambot.py +++ b/telegrambot.py @@ -6,9 +6,11 @@ import errors import stagismo from telegram import Bot, Update, InlineKeyboardMarkup, InlineKeyboardButton from telegram.ext import Updater, CommandHandler, CallbackQueryHandler +import telegram.error from discord import Status as DiscordStatus import subprocess import os +import time # Init the config reader import configparser @@ -371,8 +373,14 @@ def process(arg_discord_connection): u.dispatcher.add_handler(CommandHandler("ban", cmd_ban)) u.dispatcher.add_handler(CallbackQueryHandler(on_callback_query)) u.bot.send_message(config["Telegram"]["main_group"], f"ℹ Royal Bot {version} avviato e pronto a ricevere comandi!") - u.start_polling() - u.idle() + while True: + try: + u.start_polling() + u.idle() + except telegram.error.TimedOut: + print("Telegrambot timed out.") + time.sleep(60) + print("Telegrambot restarting...") if __name__ == "__main__": process(None) \ No newline at end of file