forked from EverythingSuckz/TG-FileStreamBot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__main__.py
More file actions
59 lines (51 loc) · 2.25 KB
/
Copy path__main__.py
File metadata and controls
59 lines (51 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# This file is a part of TG-FileStreamBot
# Coding : Jyothis Jayanth [@EverythingSuckz]
import asyncio
import logging
from aiohttp import web
from pyrogram import idle
from WebStreamer import bot_info
from WebStreamer.vars import Var
from WebStreamer.server import web_server
from WebStreamer.utils.keepalive import ping_server
from WebStreamer.bot.clients import initialize_clients
logging.basicConfig(
level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s"
)
logging.getLogger("pyrogram").setLevel(logging.ERROR)
logging.getLogger("aiohttp").setLevel(logging.ERROR)
logging.getLogger("aiohttp.web").setLevel(logging.ERROR)
loop = asyncio.get_event_loop()
async def start_services():
print("----------------------------- DONE -----------------------------")
print()
print(
"----------------------------- Initializing Clients -----------------------------"
)
await initialize_clients()
print("----------------------------- DONE -----------------------------")
if Var.ON_HEROKU:
print("------------------ Starting Keep Alive Service ------------------")
print()
asyncio.create_task(ping_server())
print("-------------------- Initalizing Web Server --------------------")
app = web.AppRunner(await web_server())
await app.setup()
bind_address = "0.0.0.0" if Var.ON_HEROKU else Var.BIND_ADDRESS
await web.TCPSite(app, bind_address, Var.PORT).start()
print("----------------------------- DONE -----------------------------")
print()
print("----------------------- Service Started -----------------------")
print(" bot =>> {}".format(bot_info.first_name))
if bot_info.dc_id:
print(" DC ID =>> {}".format(str(bot_info.dc_id)))
print(" server ip =>> {}".format(bind_address, Var.PORT))
if Var.ON_HEROKU:
print(" app running on =>> {}".format(Var.FQDN))
print("---------------------------------------------------------------")
await idle()
if __name__ == "__main__":
try:
loop.run_until_complete(start_services())
except KeyboardInterrupt:
logging.info("----------------------- Service Stopped -----------------------")