Bump to v1.8

This commit is contained in:
Dr.Caduceus
2024-11-24 16:27:07 +05:30
committed by GitHub
parent 35e0008d2f
commit 225f39bdbd
6 changed files with 51 additions and 13 deletions

View File

@@ -66,7 +66,7 @@ pip install -r requirements.txt
<a name="variables"></a> <a name="variables"></a>
## 📝 Variables ## 📝 Variables
**The variables provided below should either be completed within the [config.py](https://github.com/TheCaduceus/FileStreamBot/blob/main/bot/config.py) file or configured as environment variables.** **The variables listed below should be defined either in [config.py](https://github.com/TheCaduceus/FileStreamBot/blob/main/bot/config.py) file or as environment variables, depending on your setup.**
* `API_ID`|`TELEGRAM_API_ID`: API ID of your Telegram account, can be obtained from [My Telegram](https://my.telegram.org). `int` * `API_ID`|`TELEGRAM_API_ID`: API ID of your Telegram account, can be obtained from [My Telegram](https://my.telegram.org). `int`
* `API_HASH`|`TELEGRAM_API_HASH`: API hash of your Telegram account, can be obtained from [My Telegram](https://my.telegram.org). `str` * `API_HASH`|`TELEGRAM_API_HASH`: API hash of your Telegram account, can be obtained from [My Telegram](https://my.telegram.org). `str`
* `OWNER_ID`: ID of your Telegram account, can be obtained by sending **/info** to [@DumpJsonBot](https://t.me/DumpJsonBot). `int` * `OWNER_ID`: ID of your Telegram account, can be obtained by sending **/info** to [@DumpJsonBot](https://t.me/DumpJsonBot). `int`
@@ -74,13 +74,14 @@ pip install -r requirements.txt
* `BOT_USERNAME`|`TELEGRAM_BOT_USERNAME`: Username of your Telegram bot, create one using [@BotFather](https://t.me/BotFather). `str` * `BOT_USERNAME`|`TELEGRAM_BOT_USERNAME`: Username of your Telegram bot, create one using [@BotFather](https://t.me/BotFather). `str`
* `BOT_TOKEN`|`TELEGRAM_BOT_TOKEN`: Telegram API token of your bot, can be obtained from [@BotFather](https://t.me/BotFather). `str` * `BOT_TOKEN`|`TELEGRAM_BOT_TOKEN`: Telegram API token of your bot, can be obtained from [@BotFather](https://t.me/BotFather). `str`
* `CHANNEL_ID`|`TELEGRAM_CHANNEL_ID`: ID of the channel where bot will forward all files received from users, can be obtained by forwarding any message from channel to [@DumpJsonBot](https://t.me/DumpJsonBot) and then looking from `forward_from_chat` key. `int` * `CHANNEL_ID`|`TELEGRAM_CHANNEL_ID`: ID of the channel where bot will forward all files received from users, can be obtained by forwarding any message from channel to [@DumpJsonBot](https://t.me/DumpJsonBot) and then looking from `forward_from_chat` key. `int`
* `BOT_WORKERS`: Number of updates bot should process from Telegram at once, by default to 10 updates. `int`
* `SECRET_CODE_LENGTH`: Number of characters that file code should contain, by default to 24 characters. `int` * `SECRET_CODE_LENGTH`: Number of characters that file code should contain, by default to 24 characters. `int`
* `BASE_URL`: Base URL that bot should use while generating file links, can be FQDN and by default to `127.0.0.1`. `str` * `BASE_URL`: Base URL that bot should use while generating file links, can be FQDN and by default to `127.0.0.1`. `str`
* `BIND_ADDRESS`: Bind address for web server, by default to `0.0.0.0` to run on all possible addresses. `str` * `BIND_ADDRESS`: Bind address for web server, by default to `0.0.0.0` to run on all possible addresses. `str`
* `PORT`: Port for web server to run on, by default to `8080`. `int` * `PORT`: Port for web server to run on, by default to `8080`. `int`
## 🕹 Deployment ## 🕹 Deployment
> [!NOTE]
> This bot is designed for personal use or to share with friends and family only. It is not intended for mass public use or exposure to a large audience.
<a name="d-1"></a> <a name="d-1"></a>

View File

@@ -5,15 +5,15 @@ from .config import Telegram, LOGGER_CONFIG_JSON
dictConfig(LOGGER_CONFIG_JSON) dictConfig(LOGGER_CONFIG_JSON)
version = 1.7 version = 1.8
logger = getLogger('bot') logger = getLogger('bot')
TelegramBot = Client( TelegramBot = Client(
name ='bot', name = 'bot',
api_id = Telegram.API_ID, api_id = Telegram.API_ID,
api_hash = Telegram.API_HASH, api_hash = Telegram.API_HASH,
bot_token = Telegram.BOT_TOKEN, bot_token = Telegram.BOT_TOKEN,
plugins = {'root': 'bot/plugins'}, plugins = {'root': 'bot/plugins'},
workers = Telegram.BOT_WORKERS, sleep_threshold = -1,
max_concurrent_transmissions = 1000 max_concurrent_transmissions = 10,
) )

View File

@@ -7,7 +7,6 @@ class Telegram:
ALLOWED_USER_IDS = env.get("ALLOWED_USER_IDS", "").split() ALLOWED_USER_IDS = env.get("ALLOWED_USER_IDS", "").split()
BOT_USERNAME = env.get("TELEGRAM_BOT_USERNAME", "BotFather") BOT_USERNAME = env.get("TELEGRAM_BOT_USERNAME", "BotFather")
BOT_TOKEN = env.get("TELEGRAM_BOT_TOKEN", "1234567:xyz") BOT_TOKEN = env.get("TELEGRAM_BOT_TOKEN", "1234567:xyz")
BOT_WORKERS = env.get("BOT_WORKERS", 10)
CHANNEL_ID = int(env.get("TELEGRAM_CHANNEL_ID", -100123456789)) CHANNEL_ID = int(env.get("TELEGRAM_CHANNEL_ID", -100123456789))
SECRET_CODE_LENGTH = int(env.get("SECRET_CODE_LENGTH", 24)) SECRET_CODE_LENGTH = int(env.get("SECRET_CODE_LENGTH", 24))

View File

@@ -1,8 +1,9 @@
from hydrogram import Client from hydrogram import Client
from hydrogram.types import Message, CallbackQuery from hydrogram.types import Message, CallbackQuery, InlineKeyboardMarkup, InlineKeyboardButton
from typing import Union, Callable from typing import Union, Callable
from functools import wraps from functools import wraps
from bot.config import Telegram from bot.config import Telegram
from bot.modules.static import *
def verify_user(func: Callable): def verify_user(func: Callable):
@@ -12,5 +13,13 @@ def verify_user(func: Callable):
if not Telegram.ALLOWED_USER_IDS or chat_id in Telegram.ALLOWED_USER_IDS: if not Telegram.ALLOWED_USER_IDS or chat_id in Telegram.ALLOWED_USER_IDS:
return await func(client, update) return await func(client, update)
elif isinstance(update, CallbackQuery):
return await update.answer(UserNotInAllowedList, show_alert=True)
elif isinstance(update, Message):
return await update.reply(
text = UserNotInAllowedList,
quote = True,
reply_markup = InlineKeyboardMarkup([[InlineKeyboardButton('Deploy Own', url='https://github.com/TheCaduceus/FileStreamBot')]])
)
return decorator return decorator

View File

@@ -1,11 +1,30 @@
WelcomeText = \ WelcomeText = \
""" """\
Hi **%(first_name)s**, send me a file to instantly generate file links. Hi **%(first_name)s**, send me a file to instantly generate file links.
**Commands:**
/privacy - View bot's privacy policy.
/log - Get bot's log file. (owner only)
/help - Show this message.
""" """
PrivacyText = \ PrivacyText = \
""" """
This bot securely stores your files to deliver its service. **Privacy Policy**
**1.Data Storage:** Files you upload/send are securely saved in the bot's private Telegram channel.
**2.Download Links:** Links include a secret code to prevent unauthorized access.
**3.User Control:** You can revoke links anytime using the "Revoke" button.
**4.Moderation:** The bot owner can view and delete your files if necessary.
**5.Open Source:** The bot is [open source](https://github.com/TheCaduceus/FileStreamBot). Deploy your own instance for maximum privacy.
**6.Retention:** Files are stored until you revoke their links.
__By using this bot, you agree to this policy.__
""" """
FileLinksText = \ FileLinksText = \
@@ -41,3 +60,8 @@ InvalidPayloadText = \
""" """
Invalid payload. Invalid payload.
""" """
UserNotInAllowedList = \
"""
You are not allowed to use this bot.
"""

View File

@@ -1,6 +1,7 @@
from hydrogram import filters from hydrogram import filters
from hydrogram.types import Message from hydrogram.types import Message
from bot import TelegramBot from bot import TelegramBot
from bot.config import Telegram
from bot.modules.static import * from bot.modules.static import *
from bot.modules.decorators import verify_user from bot.modules.decorators import verify_user
@@ -8,11 +9,15 @@ from bot.modules.decorators import verify_user
@verify_user @verify_user
async def start_command(_, msg: Message): async def start_command(_, msg: Message):
await msg.reply( await msg.reply(
text=WelcomeText % {'first_name': msg.from_user.first_name}, text = WelcomeText % {'first_name': msg.from_user.first_name},
quote=True quote = True
) )
@TelegramBot.on_message(filters.command('privacy') & filters.private) @TelegramBot.on_message(filters.command('privacy') & filters.private)
@verify_user @verify_user
async def privacy_command(_, msg: Message): async def privacy_command(_, msg: Message):
await msg.reply(text=PrivacyText, quote=True) await msg.reply(text=PrivacyText, quote=True, disable_web_page_preview=True)
@TelegramBot.on_message(filters.command('log') & filters.chat(Telegram.OWNER_ID))
async def log_command(_, msg: Message):
await msg.reply_document('event-log.txt', quote=True)