def main(): fs_utils.start_cleanup() # Check if the bot is restarting if path.exists('restart.pickle'): with open('restart.pickle', 'rb') as status: restart_message = pickle.load(status) restart_message.edit_text("Restarted Successfully!") LOGGER.info('Restarted Successfully!') remove('restart.pickle') start_handler = CommandHandler(BotCommands.StartCommand, start, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user) ping_handler = CommandHandler(BotCommands.PingCommand, ping, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user) restart_handler = CommandHandler(BotCommands.RestartCommand, restart, filters=CustomFilters.owner_filter | CustomFilters.authorized_user) help_handler = CommandHandler(BotCommands.HelpCommand, bot_help, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user) stats_handler = CommandHandler(BotCommands.StatsCommand, stats, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user) log_handler = CommandHandler(BotCommands.LogCommand, log, filters=CustomFilters.owner_filter) repo_handler = CommandHandler(BotCommands.RepoCommand, repo, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user) authlist_handler = CommandHandler(BotCommands.AuthListCommand, chat_list, filters=CustomFilters.owner_filter) 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) updater.start_polling() LOGGER.info("Bot Started!") signal.signal(signal.SIGINT, fs_utils.exit_clean_up)
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") bot.set_my_commands(botcmds) start_handler = CommandHandler(BotCommands.StartCommand, start, 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 | CustomFilters.sudo_user, 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 | CustomFilters.sudo_user, run_async=True) 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) updater.start_polling() LOGGER.info("Bot Started!") signal.signal(signal.SIGINT, fs_utils.exit_clean_up)
def main(): fs_utils.start_cleanup() # Check if the bot is restarting if path.exists('restart.pickle'): with open('restart.pickle', 'rb') as status: restart_message = pickle.load(status) restart_message.edit_text("⛽ 𝐌𝐲 𝐒𝐞𝐫𝐯𝐢𝐜𝐞𝐬 𝐑𝐞𝐬𝐭𝐚𝐫𝐭𝐞𝐝 𝐒𝐮𝐜𝐜𝐞𝐬𝐬𝐟𝐮𝐥𝐥𝐲!") remove('restart.pickle') start_handler = CommandHandler(BotCommands.StartCommand, start) ping_handler = CommandHandler(BotCommands.PingCommand, ping, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user) restart_handler = CommandHandler(BotCommands.RestartCommand, restart, filters=CustomFilters.owner_filter | CustomFilters.sudo_user) help_handler = CommandHandler(BotCommands.HelpCommand, bot_help, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user) stats_handler = CommandHandler(BotCommands.StatsCommand, stats, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user) log_handler = CommandHandler(BotCommands.LogCommand, log, filters=CustomFilters.owner_filter | CustomFilters.sudo_user) 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) updater.start_polling() LOGGER.info("Yeah I'm running!") signal.signal(signal.SIGINT, fs_utils.exit_clean_up)
def main(): fs_utils.start_cleanup() # Check if the bot is restarting if path.exists('restart.pickle'): with open('restart.pickle', 'rb') as status: restart_message = pickle.load(status) restart_message.edit_text("РЏйЮљЊЮљАЮљъ ЮљЂЮљеЮљГ ЮљЉЮљъЮљгЮљГЮљџЮљФЮљГЮљъЮљЮ ЮљњЮљ«ЮљюЮљюЮљъЮљгЮљгЮљЪЮљ«ЮљЦЮљЦЮљ▓!") remove('restart.pickle') start_handler = CommandHandler(BotCommands.StartCommand, start, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user) ping_handler = CommandHandler(BotCommands.PingCommand, ping, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user) restart_handler = CommandHandler(BotCommands.RestartCommand, restart, filters=CustomFilters.owner_filter) help_handler = CommandHandler(BotCommands.HelpCommand, bot_help, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user) stats_handler = CommandHandler(BotCommands.StatsCommand, stats, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user) log_handler = CommandHandler(BotCommands.LogCommand, log, filters=CustomFilters.owner_filter) 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) updater.start_polling() LOGGER.info("Bot Started!") signal.signal(signal.SIGINT, fs_utils.exit_clean_up)
def main(): fs_utils.start_cleanup() start_handler = CommandHandler(BotCommands.StartCommand, start, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user) ping_handler = CommandHandler(BotCommands.PingCommand, ping, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user) help_handler = CommandHandler(BotCommands.HelpCommand, bot_help, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user) stats_handler = CommandHandler(BotCommands.StatsCommand, stats, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user) log_handler = CommandHandler(BotCommands.LogCommand, log, filters=CustomFilters.owner_filter) dispatcher.add_handler(start_handler) dispatcher.add_handler(ping_handler) dispatcher.add_handler(help_handler) dispatcher.add_handler(stats_handler) dispatcher.add_handler(log_handler) updater.start_polling() LOGGER.info("Bot Started!") signal.signal(signal.SIGINT, fs_utils.exit_clean_up)
def main(): fs_utils.start_cleanup() # Check if the bot is restarting SUPPORT_GROUP = "tgelkayb0ts" if SUPPORT_GROUP is not None and isinstance(SUPPORT_GROUP, str): try: dispatcher.bot.sendMessage(f"@{SUPPORT_GROUP}", "Bot Restarted!") except Unauthorized: LOGGER.warning( "Bot isnt able to send message to support_chat, go and check!") except BadRequest as e: LOGGER.warning(e.message) 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") bot.set_my_commands(botcmds) start_handler = CommandHandler(BotCommands.StartCommand, start, 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 | CustomFilters.sudo_user, 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 | CustomFilters.sudo_user, run_async=True) 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) updater.start_polling(drop_pending_updates=IGNORE_PENDING_REQUESTS) LOGGER.info("Bot Started!") signal.signal(signal.SIGINT, fs_utils.exit_clean_up)
def main(): #AutoRestart Print now = datetime.now(pytz.timezone('Asia/Kolkata')) current = now.strftime('%Y/%m/%d %I:%M:%P') f"Im Back!: {current}" fs_utils.start_cleanup() # Check if the bot is restarting if path.exists('restart.pickle'): with open('restart.pickle', 'rb') as status: restart_message = pickle.load(status) restart_message.edit_text("Restarted Successfully!") LOGGER.info('Restarted Successfully!') remove('restart.pickle') start_handler = CommandHandler(BotCommands.StartCommand, start, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user) ping_handler = CommandHandler(BotCommands.PingCommand, ping, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user) restart_handler = CommandHandler(BotCommands.RestartCommand, restart, filters=CustomFilters.owner_filter) help_handler = CommandHandler(BotCommands.HelpCommand, bot_help, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user) stats_handler = CommandHandler(BotCommands.StatsCommand, stats, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user) log_handler = CommandHandler(BotCommands.LogCommand, log, filters=CustomFilters.owner_filter) repo_handler = CommandHandler(BotCommands.RepoCommand, repo, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user) authlist_handler = CommandHandler(BotCommands.AuthListCommand, chat_list, filters=CustomFilters.owner_filter) 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) updater.start_polling() LOGGER.info("Bot Started!") signal.signal(signal.SIGINT, fs_utils.exit_clean_up)
def main(): fs_utils.start_cleanup() # Check if the bot is restarting if path.exists('restart.pickle'): with open('restart.pickle', 'rb') as status: restart_message = pickle.load(status) restart_message.edit_text("Restarted Successfully!") remove('restart.pickle') start_handler = CommandHandler(BotCommands.StartCommand, start, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user) ping_handler = CommandHandler(BotCommands.PingCommand, ping, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user) restart_handler = CommandHandler(BotCommands.RestartCommand, restart, filters=CustomFilters.owner_filter) help_handler = CommandHandler(BotCommands.HelpCommand, bot_help, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user) stats_handler = CommandHandler(BotCommands.StatsCommand, stats, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user) log_handler = CommandHandler(BotCommands.LogCommand, log, filters=CustomFilters.owner_filter) 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) if USE_WEBHOOKS: from bot import (BOT_TOKEN, WEBHOOK_PORT, WEBHOOK_HOST, WEBHOOK_URL) updater.start_webhook( listen=WEBHOOK_HOST, # (c) https://t.me/c/1186975633/22915 port=WEBHOOK_PORT, url_path=BOT_TOKEN) updater.bot.set_webhook(url=WEBHOOK_URL + "/" + BOT_TOKEN) else: updater.start_polling() LOGGER.info("Bot Started!") signal.signal(signal.SIGINT, fs_utils.exit_clean_up)
def main(): fs_utils.start_cleanup() # Check if the bot is restarting if path.exists('restart.pickle'): with open('restart.pickle', 'rb') as status: restart_message = pickle.load(status) restart_message.edit_text("Restarted Successfully!") remove('restart.pickle') def getConfig(name: str): return environ[name] DOWNLOAD_DIR = getConfig('DOWNLOAD_DIR') mkdir(DOWNLOAD_DIR) LOGGER.info(f'Created Directory {DOWNLOAD_DIR}') start_handler = CommandHandler(BotCommands.StartCommand, start, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user) ping_handler = CommandHandler(BotCommands.PingCommand, ping, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user) restart_handler = CommandHandler(BotCommands.RestartCommand, restart, filters=CustomFilters.owner_filter) help_handler = CommandHandler(BotCommands.HelpCommand, bot_help, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user) stats_handler = CommandHandler(BotCommands.StatsCommand, stats, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user) log_handler = CommandHandler(BotCommands.LogCommand, log, filters=CustomFilters.owner_filter) 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) updater.start_polling() LOGGER.info("Bot Started!") signal.signal(signal.SIGINT, fs_utils.exit_clean_up)
def main(): fs_utils.start_cleanup() # Check if the bot is restarting if path.exists('restart.pickle'): with open('restart.pickle', 'rb') as status: restart_message = pickle.load(status) restart_message.edit_text("Restarted Successfully!") remove('restart.pickle') start_handler = CommandHandler(BotCommands.StartCommand, start, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user) help_handler = CommandHandler(BotCommands.HelpCommand, bot_help, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user) dispatcher.add_handler(start_handler) dispatcher.add_handler(help_handler) updater.start_polling() LOGGER.info("Bot Started!") signal.signal(signal.SIGINT, fs_utils.exit_clean_up)
def main(): fs_utils.start_cleanup() if IS_VPS: asyncio.get_event_loop().run_until_complete(start_server_async(PORT)) # 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") elif OWNER_ID: try: text = "<b>Bot Restarted!</b>" bot.sendMessage(chat_id=OWNER_ID, text=text, parse_mode=ParseMode.HTML) if AUTHORIZED_CHATS: for i in AUTHORIZED_CHATS: bot.sendMessage(chat_id=i, text=text, parse_mode=ParseMode.HTML) except Exception as e: LOGGER.warning(e) # bot.set_my_commands(botcmds) start_handler = CommandHandler(BotCommands.StartCommand, start, 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 | CustomFilters.sudo_user, 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 | CustomFilters.sudo_user, run_async=True) 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) updater.start_polling(drop_pending_updates=IGNORE_PENDING_REQUESTS) LOGGER.info("Bot Started!") signal.signal(signal.SIGINT, fs_utils.exit_clean_up)
def main(): fs_utils.start_cleanup() # Check if the bot is restarting if path.exists('restart.pickle'): with open('restart.pickle', 'rb') as status: restart_message = pickle.load(status) restart_message.edit_text("Restarted Successfully!") remove('restart.pickle') plugins = dict(root="bot/modules") app = Client(":memory:", api_id=TELEGRAM_API, api_hash=TELEGRAM_HASH, plugins=plugins, bot_token=BOT_TOKEN, workdir=DOWNLOAD_DIR) app.set_parse_mode("html") LOGGER.info("Bot Started!") signal.signal(signal.SIGINT, fs_utils.exit_clean_up) app.run()