mirror of
https://github.com/avipatilpro/FileStreamBot.git
synced 2026-01-15 14:22:53 -03:00
Initial Commit
This commit is contained in:
@@ -1,6 +1,3 @@
|
||||
# This file is a part of TG-FileStreamBot
|
||||
# Coding: @AvishkarPatil & @EverythingSuckz & @AbirHasan2005
|
||||
|
||||
import os
|
||||
import sys
|
||||
import glob
|
||||
@@ -13,6 +10,15 @@ from .bot import StreamBot
|
||||
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)
|
||||
@@ -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)
|
||||
@@ -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))
|
||||
@@ -58,4 +69,4 @@ if __name__ == '__main__':
|
||||
try:
|
||||
loop.run_until_complete(start_services())
|
||||
except KeyboardInterrupt:
|
||||
print('----------------------- Service Stopped -----------------------')
|
||||
logging.info('----------------------- Service Stopped -----------------------')
|
||||
|
||||
Reference in New Issue
Block a user