Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
avipatilpro authored Jun 5, 2021
1 parent 86b9593 commit b09c4f6
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions WebStreamer/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# This file is a part of TG-FileStreamBot
# Coding: @AvishkarPatil & @EverythingSuckz & @AbirHasan2005

import os
import sys
import glob
Expand All @@ -13,6 +10,15 @@
from .vars import Var
from aiohttp import web
from .server import web_server
from .utils.keepalive import ping_server
from apscheduler.schedulers.background import BackgroundScheduler

logging.basicConfig(
level=logging.INFO,
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s"
)
logging.getLogger("pyrogram").setLevel(logging.WARNING)
logging.getLogger("apscheduler").setLevel(logging.WARNING)

ppath = "WebStreamer/bot/plugins/*.py"
files = glob.glob(ppath)
Expand All @@ -24,10 +30,9 @@ async def start_services():
print('\n')
print('------------------- Initalizing Telegram Bot -------------------')
await StreamBot.start()
print('----------------------------- DONE -----------------------------')
print('\n')
print('---------------------- DONE ----------------------')
print('\n')
print('------------------- Importing -------------------')
print('--------------------------- Importing ---------------------------')
for name in files:
with open(name) as a:
patt = Path(a.name)
Expand All @@ -39,12 +44,18 @@ async def start_services():
spec.loader.exec_module(load)
sys.modules["WebStreamer.bot.plugins." + plugin_name] = load
print("Imported => " + plugin_name)
print('\n')
print('------------------- Initalizing Web Server -------------------')
if Var.ON_HEROKU:
print('------------------ Starting Keep Alive Service ------------------')
print('\n')
scheduler = BackgroundScheduler()
scheduler.add_job(ping_server, "interval", seconds=1200)
scheduler.start()
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.FQDN
await web.TCPSite(app, bind_address, Var.PORT).start()
print('----------------------------- DONE -----------------------------')
print('\n')
print('----------------------- Service Started -----------------------')
print(' bot =>> {}'.format((await StreamBot.get_me()).first_name))
Expand All @@ -58,4 +69,4 @@ async def start_services():
try:
loop.run_until_complete(start_services())
except KeyboardInterrupt:
print('----------------------- Service Stopped -----------------------')
logging.info('----------------------- Service Stopped -----------------------')

0 comments on commit b09c4f6

Please sign in to comment.