mirror of
https://github.com/avipatilpro/FileStreamBot.git
synced 2026-01-15 14:22:53 -03:00
something updated !
- Bot Sleep Fixed - Custom Domain Support - Bot Uptime - Some Minor Chnages
This commit is contained in:
17
.github/workflows/YOURACTION.yml
vendored
17
.github/workflows/YOURACTION.yml
vendored
@@ -1,17 +0,0 @@
|
||||
name: Heroku Awake
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "*/30 * * * *"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: mikeesto/heroku-awake@1.0.0
|
||||
with:
|
||||
URL: "https://HEROKU_APP_NAME.herokuapp.com"
|
||||
|
||||
# Put Your Heroke App Name As it is in above line
|
||||
# Don't Change Any other Thing than App Name
|
||||
12
README.md
12
README.md
@@ -1,8 +1,9 @@
|
||||
<h1 align="center">Telegram File to Link Bot !</h1>
|
||||
<p align="center">
|
||||
<a href="https://github.com/Avipatilpro/FileStreamBot">
|
||||
<img src="https://socialify.git.ci/Avipatilpro/FileStreamBot/image?description=1&font=Source%20Code%20Pro&forks=1&issues=1&logo=https%3A%2F%2Fwww.flaticon.com%2Fpremium-icon%2Ficons%2Fsvg%2F2321%2F2321089.svg&pattern=Circuit%20Board&pulls=1&stargazers=1&theme=Dark" alt="Cover Image" width="650">
|
||||
<img src="https://socialify.git.ci/avipatilpro/FileStreamBot/image?description=1&descriptionEditable=Telegram%20File%20to%20Link%20Fastest%20Bot%20%2C%20also%20used%20for%20Movies%20streaming%20Generate%20Direct%20Links&font=KoHo&forks=1&logo=https%3A%2F%2Fi.ibb.co%2FZJzJ9Hq%2Flink-3x.png&pattern=Brick%20Wall&stargazers=1&theme=Dark" alt="Cover Image" width="550">
|
||||
</a>
|
||||
|
||||
<p align="center">
|
||||
A Telegram bot to stream files to web.
|
||||
<br />
|
||||
@@ -37,14 +38,7 @@ Either you could locally host or deploy on [Heroku](https://heroku.com)
|
||||
### Deploy on Heroku
|
||||
|
||||
1. Fork This Repo
|
||||
2. In .github/workflow/YOURACTION.yml
|
||||
3. edit this file and at last line in file replace the app name with your heroku app name
|
||||
|
||||
4.```URL: "https://HEROKU_APP_NAME.herokuapp.com"```
|
||||
|
||||
5. change this name 😑😑😑
|
||||
|
||||
6. If You nota Do this bot will not work
|
||||
2. Click on Deploy Easily
|
||||
|
||||
### So Follow Above Steps 👆 and then also deply other wise not work
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# This file is a part of TG-FileStreamBot
|
||||
# Coding : Jyothis Jayanth [@EverythingSuckz]
|
||||
|
||||
# Maintained By : Avishkar Patil [ @Avishkarpatil ] [ Telegram ]
|
||||
|
||||
import time
|
||||
StartTime = time.time()
|
||||
|
||||
@@ -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 -----------------------')
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
# Taken from megadlbot_oss <https://github.com/eyaadh/megadlbot_oss/blob/master/mega/webserver/routes.py>
|
||||
# Thanks to Eyaadh <https://github.com/eyaadh>
|
||||
|
||||
import time
|
||||
import math
|
||||
import logging
|
||||
import secrets
|
||||
@@ -8,17 +6,18 @@ import mimetypes
|
||||
from ..vars import Var
|
||||
from aiohttp import web
|
||||
from ..bot import StreamBot
|
||||
from WebStreamer import StartTime
|
||||
from ..utils.custom_dl import TGCustomYield, chunk_size, offset_fix
|
||||
|
||||
from ..utils.time_format import get_readable_time
|
||||
routes = web.RouteTableDef()
|
||||
|
||||
|
||||
@routes.get("/", allow_head=True)
|
||||
async def root_route_handler(request):
|
||||
bot_details = await StreamBot.get_me()
|
||||
return web.json_response({"status": "running",
|
||||
"server_permission": "Open",
|
||||
"telegram_bot": '@'+bot_details.username})
|
||||
"maintained_by": "Avishkar_Patil",
|
||||
"uptime": get_readable_time(time.time() - StartTime),
|
||||
"telegram_bot": '@'+(await StreamBot.get_me()).username})
|
||||
|
||||
|
||||
@routes.get("/{message_id}")
|
||||
@@ -74,4 +73,4 @@ async def media_streamer(request, message_id: int):
|
||||
if return_resp.status == 200:
|
||||
return_resp.headers.add("Content-Length", str(file_size))
|
||||
|
||||
return return_resp
|
||||
return return_resp
|
||||
|
||||
11
WebStreamer/utils/keepalive.py
Normal file
11
WebStreamer/utils/keepalive.py
Normal file
@@ -0,0 +1,11 @@
|
||||
# Bot Sleeping
|
||||
|
||||
import logging
|
||||
import requests
|
||||
from ..vars import Var
|
||||
def ping_server():
|
||||
k = requests.get(f'https://ping-pong-sn.herokuapp.com/pingback?link={Var.URL}').json()
|
||||
if not k.get('error'):
|
||||
logging.info('KeepAliveService: Pinged {} with status {}'.format(Var.FQDN, k.get('Status')))
|
||||
else:
|
||||
logging.error('Couldn\'t Ping the Server!')
|
||||
24
WebStreamer/utils/time_format.py
Normal file
24
WebStreamer/utils/time_format.py
Normal file
@@ -0,0 +1,24 @@
|
||||
# Bot Uptime
|
||||
|
||||
def get_readable_time(seconds: int) -> str:
|
||||
count = 0
|
||||
readable_time = ""
|
||||
time_list = []
|
||||
time_suffix_list = ["s", "m", "h", " days"]
|
||||
while count < 4:
|
||||
count += 1
|
||||
if count < 3:
|
||||
remainder, result = divmod(seconds, 60)
|
||||
else:
|
||||
remainder, result = divmod(seconds, 24)
|
||||
if seconds == 0 and remainder == 0:
|
||||
break
|
||||
time_list.append(int(result))
|
||||
seconds = int(remainder)
|
||||
for x in range(len(time_list)):
|
||||
time_list[x] = str(time_list[x]) + time_suffix_list[x]
|
||||
if len(time_list) == 4:
|
||||
readable_time += time_list.pop() + ", "
|
||||
time_list.reverse()
|
||||
readable_time += ": ".join(time_list)
|
||||
return readable_time
|
||||
@@ -24,7 +24,9 @@ class Var(object):
|
||||
APP_NAME = str(getenv('APP_NAME'))
|
||||
else:
|
||||
ON_HEROKU = False
|
||||
FQDN = str(getenv('FQDN', BIND_ADRESS)) if not ON_HEROKU else APP_NAME+'.herokuapp.com'
|
||||
FQDN = str(getenv('FQDN', BIND_ADRESS)) if not ON_HEROKU or getenv('FQDN') else APP_NAME+'.herokuapp.com'
|
||||
URL = "https://{}/".format(FQDN) if ON_HEROKU or NO_PORT else \
|
||||
"http://{}:{}/".format(FQDN, PORT)
|
||||
DATABASE_URL = str(getenv('DATABASE_URL'))
|
||||
UPDATES_CHANNEL = str(getenv('UPDATES_CHANNEL', None))
|
||||
BANNED_CHANNELS = list(set(int(x) for x in str(getenv("BANNED_CHANNELS", "-1001362659779")).split()))
|
||||
|
||||
@@ -4,4 +4,6 @@ aiohttp
|
||||
python-dotenv
|
||||
motor
|
||||
aiofiles
|
||||
dnspython
|
||||
dnspython
|
||||
apscheduler
|
||||
requests
|
||||
|
||||
Reference in New Issue
Block a user