Fixed Heroku NoneType error + Added NO_PORT

This commit is contained in:
EverythingSuckz
2021-04-18 22:09:11 +05:30
parent 7a91df2cec
commit 6cc385112b
4 changed files with 80 additions and 71 deletions

View File

@@ -1,12 +1,12 @@
<h1 align="center">Telegram File Stream Bot</h3>
<p align="center">
<a href="https://github.com/EverythingSuckz/TG-FileStreamBot">
<img src="https://socialify.git.ci/EverythingSuckz/TG-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/EverythingSuckz/TG-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" height=400>
</a>
<p align="center">
A Telegram bot to stream files to web
<br />
<a href="https://telegram.dog/TG_FileStreamBot"><strong>BOT Demo »</strong></a>
<a href="https://telegram.dog/TG_FileStreamBot"><strong>Telegram Bot »</strong></a>
<br />
<a href="https://github.com/EverythingSuckz/TG-FileStreamBot/issues">Report a Bug</a>
|
@@ -121,6 +121,8 @@ FQDN=yourserverip
`WEB_SERVER_BIND_ADDRESS` : Your server bind adress. Defauls to `0.0.0.0`
`NO_PORT` : If you don't want your port to be displayed. You should point your `PORT` to `80` (http) or `443` (https) for the links to work. Ignore this if you're on Heroku.
`FQDN` : A Fully Qualified Domain Name if present. Defaults to `WEB_SERVER_BIND_ADDRESS`
## How to use the bot
@@ -146,4 +148,4 @@ You can contact either via my [Telegram Chat](https://xn--r1a.click/WhyThisUsern
- Me
- [eyaadh](https://github.com/eyaadh) for his awesome [Megatron Bot](https://github.com/eyaadh/megadlbot_oss)
- [Dan Tès](https://telegram.dog/haskell) for his [Pyrogram Library](https://github.com/pyrogram/pyrogram)
- [Dan Tès](https://telegram.dog/haskell) for his [Pyrogram Library](https://github.com/pyrogram/pyrogram)

View File

@@ -10,10 +10,11 @@ from pyrogram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton
@StreamBot.on_message(filters.private & (filters.document | filters.video | filters.audio), group=4)
async def media_receive_handler(c: Client, m: Message):
log_msg = await m.copy(chat_id=Var.BIN_CHANNEL)
stream_link = "https://{}/{}".format(Var.FQDN, log_msg.message_id) if Var.ON_HEROKU else \
stream_link = "https://{}/{}".format(Var.FQDN, log_msg.message_id) if Var.ON_HEROKU or Var.NO_PORT else \
"http://{}:{}/{}".format(Var.FQDN,
Var.PORT,
log_msg.message_id)
await m.reply_text(
text="`{}`".format(stream_link)
text="`{}`".format(stream_link),
quote=True
)

View File

@@ -15,7 +15,8 @@ class Var(object):
BIN_CHANNEL = int(getenv('BIN_CHANNEL', None))
PORT = int(getenv('PORT', 8080))
BIND_ADRESS = str(getenv('WEB_SERVER_BIND_ADDRESS', '0.0.0.0'))
OWNER_ID = int(getenv('OWNER_ID', None)) #TODO
OWNER_ID = int(getenv('OWNER_ID')) #TODO
NO_PORT = bool(getenv('NO_PORT', False))
if 'DYNO' in environ:
ON_HEROKU = True
APP_NAME = str(getenv('APP_NAME'))

135
app.json
View File

@@ -1,69 +1,74 @@
{
"name": "TG-FileStreamBot",
"description": "A Pyrogram Telegram bot to Stream Telegram files to web.",
"keywords": [
"telegram",
"stream",
"web",
"pyrogram",
"aiohttp",
"python",
"plugin",
"modular",
"media"
],
"repository": "https://github.com/EverythingSuckz/TG-FileStreamBot",
"success_url": "/",
"logo": "https://telegra.ph/file/9d63060a06c6fc6def1da.png",
"website": "stream.wrench.gq",
"env": {
"ENV": {
"description": "Set this to True if you don't want to crash the bot",
"value": "True"
"name": "TG-FileStreamBot",
"description": "A Pyrogram Telegram bot to Stream Telegram files to web.",
"keywords": [
"telegram",
"stream",
"web",
"pyrogram",
"aiohttp",
"python",
"plugin",
"modular",
"media"
],
"repository": "https://github.com/EverythingSuckz/TG-FileStreamBot",
"success_url": "/",
"logo": "https://telegra.ph/file/9d63060a06c6fc6def1da.png",
"website": "stream.wrench.gq",
"env": {
"ENV": {
"description": "Set this to True if you don't want to crash the bot",
"value": "True"
},
"APP_NAME": {
"description": "Copy-Paste the app name that you just typed above."
},
"API_ID": {
"description": "Get this value from https://my.telegram.org"
},
"API_HASH": {
"description": "Get this value from https://my.telegram.org"
},
"BOT_TOKEN": {
"description": "Get this value from @BotFather"
},
"BIN_CHANNEL": {
"description": "The BIN Channel ID. Read the readme for more info about this var"
},
"SLEEP_THRESHOLD": {
"description": "Floodwait Sleep timer. Read the readme for more info about this var",
"required": false
},
"WORKERS": {
"description": "No. of workers that is to be assigned. Read the readme for more info about this var",
"required": false
},
"PORT": {
"description": "Port that you want your webapp to be listened to. Read the readme for more info about this var",
"required": false
},
"NO_PORT": {
"description": "If you don't want your port to be displayed. Read the readme for more info about this var",
"value": "False",
"required": false
},
"BIND_ADRESS": {
"description": "Read the readme for more info about this var",
"required": false
},
"FQDN": {
"description": "Read the readme for more info about this var",
"required": false
}
},
"APP_NAME": {
"description": "Copy-Paste the app name that you just typed above."
},
"API_ID": {
"description": "Get this value from https://my.telegram.org"
},
"API_HASH": {
"description": "Get this value from https://my.telegram.org"
},
"BOT_TOKEN": {
"description": "Get this value from @BotFather"
},
"BIN_CHANNEL": {
"description": "The BIN Channel ID. Read the readme for more info about this var"
},
"SLEEP_THRESHOLD": {
"description": "Floodwait Sleep timer. Read the readme for more info about this var",
"required": false
},
"WORKERS": {
"description": "No. of workers that is to be assigned. Read the readme for more info about this var",
"required": false
},
"PORT": {
"description": "Port that you want your webapp to be listened to. Read the readme for more info about this var",
"required": false
},
"BIND_ADRESS": {
"description": "Read the readme for more info about this var",
"required": false
},
"FQDN": {
"description": "Read the readme for more info about this var",
"required": false
"buildpacks": [{
"url": "heroku/python"
}],
"formation": {
"web": {
"quantity": 1,
"size": "free"
}
}
},
"buildpacks": [{
"url": "heroku/python"
}],
"formation": {
"web": {
"quantity": 1,
"size": "free"
}
}
}