def editMessage(text: str, message: Message, reply_markup=None): try: bot.edit_message_text(text=text, message_id=message.message_id, chat_id=message.chat.id,reply_markup=reply_markup, parse_mode='HTMl') except Exception as e: LOGGER.error(str(e))
def main(): fs_utils.start_cleanup() # Check if the bot is restarting if os.path.isfile(".restartmsg"): with open(".restartmsg") as f: chat_id, msg_id = map(int, f) bot.edit_message_text("Restarted successfully!", chat_id, msg_id) os.remove(".restartmsg") start_handler = CommandHandler(BotCommands.StartCommand, start, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user, run_async=True) ping_handler = CommandHandler(BotCommands.PingCommand, ping, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user, run_async=True) restart_handler = CommandHandler(BotCommands.RestartCommand, restart, filters=CustomFilters.owner_filter, run_async=True) help_handler = CommandHandler(BotCommands.HelpCommand, bot_help, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user, run_async=True) stats_handler = CommandHandler(BotCommands.StatsCommand, stats, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user, run_async=True) log_handler = CommandHandler(BotCommands.LogCommand, log, filters=CustomFilters.owner_filter, run_async=True) repo_handler = CommandHandler(BotCommands.RepoCommand, repo, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user, run_async=True) authlist_handler = CommandHandler(BotCommands.AuthListCommand, chat_list, filters=CustomFilters.owner_filter, run_async=True) config_handler = editor.handler dispatcher.add_handler(start_handler) dispatcher.add_handler(ping_handler) dispatcher.add_handler(restart_handler) dispatcher.add_handler(help_handler) dispatcher.add_handler(stats_handler) dispatcher.add_handler(log_handler) dispatcher.add_handler(repo_handler) dispatcher.add_handler(authlist_handler) dispatcher.add_handler(config_handler) updater.start_polling() LOGGER.info("Bot Started!") signal.signal(signal.SIGINT, fs_utils.exit_clean_up)