from os import getpid, makedirs from modules.utils import * from modules.inline import * from app import app from pyrogram import idle pid = getpid() makedirs(f'{configGet("cache", "locations")}{sep}avatars', exist_ok=True) # Importing from modules.commands.application import * from modules.commands.applications import * from modules.commands.cancel import * from modules.commands.label import * from modules.commands.message import * from modules.commands.nearby import * from modules.commands.reapply import * from modules.commands.reboot import * from modules.commands.rules import * from modules.commands.sponsorship import * from modules.commands.start import * from modules.commands.warn import * from modules.commands.warnings import * from modules.callbacks.nothing import * from modules.callbacks.reapply import * from modules.callbacks.rules import * from modules.callbacks.sponsorship import * from modules.callbacks.sub import * from modules.callbacks.sus import * from modules.handlers.confirmation import * from modules.handlers.contact import * from modules.handlers.group_join import * from modules.handlers.sponsorship import * from modules.handlers.voice import * from modules.handlers.welcome import * from modules.handlers.everything import * from modules.scheduled import * if __name__ == "__main__": logWrite(f"Starting up with pid {pid}") # Yes, it should be in some kind of async main() function but I don't give a shit. # I did compare performance, almost no difference and it's much more useful this way. Change my mind. app.start() # if configGet("birthdays_notify"): # every().day.at(configGet("birthdays_time")).do(check_birthdays, app) # # Background tasks checker # def background_task(): # try: # while True: # try: # run_pending() # #print('Checked') # time.sleep(1) # except: # pass # except KeyboardInterrupt: # print('\nShutting down') # killProc(pid) # t = Thread(target=background_task) # t.start() try: app.send_message(configGet("owner"), f"Starting up with pid `{pid}`") except bad_request_400.PeerIdInvalid: logWrite(f"Could not send startup message to bot owner. Perhaps user has not started the bot yet.") scheduler.start() idle() try: app.send_message(configGet("owner"), f"Shutting with pid `{pid}`") except bad_request_400.PeerIdInvalid: logWrite(f"Could not send shutdown message to bot owner. Perhaps user has not started the bot yet.") app.stop() killProc(pid)