MCPcopy Create free account
hub / github.com/TechifyBots/File-Stream-Bot / start_services

Function start_services

biisal/__main__.py:33–85  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

31
32
33async def start_services():
34 print('\n')
35 print('------------------- Initalizing Telegram Bot -------------------')
36 bot_info = await StreamBot.get_me()
37 StreamBot.username = bot_info.username
38 print("------------------------------ DONE ------------------------------")
39 print()
40 print(
41 "---------------------- Initializing Clients ----------------------"
42 )
43 await initialize_clients()
44 print("------------------------------ DONE ------------------------------")
45 print('\n')
46 print('--------------------------- Importing ---------------------------')
47 for name in files:
48 with open(name) as a:
49 patt = Path(a.name)
50 plugin_name = patt.stem.replace(".py", "")
51 plugins_dir = Path(f"biisal/bot/plugins/{plugin_name}.py")
52 import_path = ".plugins.{}".format(plugin_name)
53 spec = importlib.util.spec_from_file_location(import_path, plugins_dir)
54 load = importlib.util.module_from_spec(spec)
55 spec.loader.exec_module(load)
56 sys.modules["biisal.bot.plugins." + plugin_name] = load
57 print("Imported => " + plugin_name)
58 if Var.ON_HEROKU:
59 print("------------------ Starting Keep Alive Service ------------------")
60 print()
61 asyncio.create_task(ping_server())
62 print('-------------------- Initalizing Web Server -------------------------')
63 app = web.AppRunner(await web_server())
64 await app.setup()
65 bind_address = "0.0.0.0" if Var.ON_HEROKU else Var.BIND_ADRESS
66 await web.TCPSite(app, bind_address, Var.PORT).start()
67 print('----------------------------- DONE ---------------------------------------------------------------------')
68 print('\n')
69 print('---------------------------------------------------------------------------------------------------------')
70 print('---------------------------------------------------------------------------------------------------------')
71 print(' follow me for more such exciting bots! https://github.com/TechifyBots')
72 print('---------------------------------------------------------------------------------------------------------')
73 print('\n')
74 print('----------------------- Service Started -----------------------------------------------------------------')
75 print(' bot =>> {}'.format((await StreamBot.get_me()).first_name))
76 print(' server ip =>> {}:{}'.format(bind_address, Var.PORT))
77 print(' Owner =>> {}'.format((Var.OWNER_USERNAME)))
78 if Var.ON_HEROKU:
79 print(' app runnng on =>> {}'.format(Var.FQDN))
80 print('---------------------------------------------------------------------------------------------------------')
81 try:
82 await StreamBot.send_message(chat_id=Var.OWNER_ID[0] ,text='<b>ʙᴏᴛ ʀᴇsᴛᴀʀᴛᴇᴅ !!</b>')
83 except Exception as e:
84 print(f'got this err to send restart msg to owner : {e}')
85 await idle()
86
87if __name__ == '__main__':
88 try:

Callers 1

__main__.pyFile · 0.85

Calls 3

initialize_clientsFunction · 0.90
ping_serverFunction · 0.85
web_serverFunction · 0.85

Tested by

no test coverage detected