Spaces:
Sleeping
Sleeping
Dr.Caduceus
commited on
Bump to v1.8
Browse files- README.md +3 -2
- bot/__init__.py +4 -4
- bot/config.py +0 -1
- bot/modules/decorators.py +10 -1
- bot/modules/static.py +26 -2
- bot/plugins/commands.py +8 -3
README.md
CHANGED
|
@@ -66,7 +66,7 @@ pip install -r requirements.txt
|
|
| 66 |
<a name="variables"></a>
|
| 67 |
|
| 68 |
## 📝 Variables
|
| 69 |
-
**The variables
|
| 70 |
* `API_ID`|`TELEGRAM_API_ID`: API ID of your Telegram account, can be obtained from [My Telegram](https://my.telegram.org). `int`
|
| 71 |
* `API_HASH`|`TELEGRAM_API_HASH`: API hash of your Telegram account, can be obtained from [My Telegram](https://my.telegram.org). `str`
|
| 72 |
* `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
|
|
| 74 |
* `BOT_USERNAME`|`TELEGRAM_BOT_USERNAME`: Username of your Telegram bot, create one using [@BotFather](https://t.me/BotFather). `str`
|
| 75 |
* `BOT_TOKEN`|`TELEGRAM_BOT_TOKEN`: Telegram API token of your bot, can be obtained from [@BotFather](https://t.me/BotFather). `str`
|
| 76 |
* `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`
|
| 77 |
-
* `BOT_WORKERS`: Number of updates bot should process from Telegram at once, by default to 10 updates. `int`
|
| 78 |
* `SECRET_CODE_LENGTH`: Number of characters that file code should contain, by default to 24 characters. `int`
|
| 79 |
* `BASE_URL`: Base URL that bot should use while generating file links, can be FQDN and by default to `127.0.0.1`. `str`
|
| 80 |
* `BIND_ADDRESS`: Bind address for web server, by default to `0.0.0.0` to run on all possible addresses. `str`
|
| 81 |
* `PORT`: Port for web server to run on, by default to `8080`. `int`
|
| 82 |
|
| 83 |
## 🕹 Deployment
|
|
|
|
|
|
|
| 84 |
|
| 85 |
<a name="d-1"></a>
|
| 86 |
|
|
|
|
| 66 |
<a name="variables"></a>
|
| 67 |
|
| 68 |
## 📝 Variables
|
| 69 |
+
**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.**
|
| 70 |
* `API_ID`|`TELEGRAM_API_ID`: API ID of your Telegram account, can be obtained from [My Telegram](https://my.telegram.org). `int`
|
| 71 |
* `API_HASH`|`TELEGRAM_API_HASH`: API hash of your Telegram account, can be obtained from [My Telegram](https://my.telegram.org). `str`
|
| 72 |
* `OWNER_ID`: ID of your Telegram account, can be obtained by sending **/info** to [@DumpJsonBot](https://t.me/DumpJsonBot). `int`
|
|
|
|
| 74 |
* `BOT_USERNAME`|`TELEGRAM_BOT_USERNAME`: Username of your Telegram bot, create one using [@BotFather](https://t.me/BotFather). `str`
|
| 75 |
* `BOT_TOKEN`|`TELEGRAM_BOT_TOKEN`: Telegram API token of your bot, can be obtained from [@BotFather](https://t.me/BotFather). `str`
|
| 76 |
* `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`
|
|
|
|
| 77 |
* `SECRET_CODE_LENGTH`: Number of characters that file code should contain, by default to 24 characters. `int`
|
| 78 |
* `BASE_URL`: Base URL that bot should use while generating file links, can be FQDN and by default to `127.0.0.1`. `str`
|
| 79 |
* `BIND_ADDRESS`: Bind address for web server, by default to `0.0.0.0` to run on all possible addresses. `str`
|
| 80 |
* `PORT`: Port for web server to run on, by default to `8080`. `int`
|
| 81 |
|
| 82 |
## 🕹 Deployment
|
| 83 |
+
> [!NOTE]
|
| 84 |
+
> 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.
|
| 85 |
|
| 86 |
<a name="d-1"></a>
|
| 87 |
|
bot/__init__.py
CHANGED
|
@@ -5,15 +5,15 @@ from .config import Telegram, LOGGER_CONFIG_JSON
|
|
| 5 |
|
| 6 |
dictConfig(LOGGER_CONFIG_JSON)
|
| 7 |
|
| 8 |
-
version = 1.
|
| 9 |
logger = getLogger('bot')
|
| 10 |
|
| 11 |
TelegramBot = Client(
|
| 12 |
-
name ='bot',
|
| 13 |
api_id = Telegram.API_ID,
|
| 14 |
api_hash = Telegram.API_HASH,
|
| 15 |
bot_token = Telegram.BOT_TOKEN,
|
| 16 |
plugins = {'root': 'bot/plugins'},
|
| 17 |
-
|
| 18 |
-
max_concurrent_transmissions =
|
| 19 |
)
|
|
|
|
| 5 |
|
| 6 |
dictConfig(LOGGER_CONFIG_JSON)
|
| 7 |
|
| 8 |
+
version = 1.8
|
| 9 |
logger = getLogger('bot')
|
| 10 |
|
| 11 |
TelegramBot = Client(
|
| 12 |
+
name = 'bot',
|
| 13 |
api_id = Telegram.API_ID,
|
| 14 |
api_hash = Telegram.API_HASH,
|
| 15 |
bot_token = Telegram.BOT_TOKEN,
|
| 16 |
plugins = {'root': 'bot/plugins'},
|
| 17 |
+
sleep_threshold = -1,
|
| 18 |
+
max_concurrent_transmissions = 10,
|
| 19 |
)
|
bot/config.py
CHANGED
|
@@ -7,7 +7,6 @@ class Telegram:
|
|
| 7 |
ALLOWED_USER_IDS = env.get("ALLOWED_USER_IDS", "").split()
|
| 8 |
BOT_USERNAME = env.get("TELEGRAM_BOT_USERNAME", "BotFather")
|
| 9 |
BOT_TOKEN = env.get("TELEGRAM_BOT_TOKEN", "1234567:xyz")
|
| 10 |
-
BOT_WORKERS = env.get("BOT_WORKERS", 10)
|
| 11 |
CHANNEL_ID = int(env.get("TELEGRAM_CHANNEL_ID", -100123456789))
|
| 12 |
SECRET_CODE_LENGTH = int(env.get("SECRET_CODE_LENGTH", 24))
|
| 13 |
|
|
|
|
| 7 |
ALLOWED_USER_IDS = env.get("ALLOWED_USER_IDS", "").split()
|
| 8 |
BOT_USERNAME = env.get("TELEGRAM_BOT_USERNAME", "BotFather")
|
| 9 |
BOT_TOKEN = env.get("TELEGRAM_BOT_TOKEN", "1234567:xyz")
|
|
|
|
| 10 |
CHANNEL_ID = int(env.get("TELEGRAM_CHANNEL_ID", -100123456789))
|
| 11 |
SECRET_CODE_LENGTH = int(env.get("SECRET_CODE_LENGTH", 24))
|
| 12 |
|
bot/modules/decorators.py
CHANGED
|
@@ -1,8 +1,9 @@
|
|
| 1 |
from hydrogram import Client
|
| 2 |
-
from hydrogram.types import Message, CallbackQuery
|
| 3 |
from typing import Union, Callable
|
| 4 |
from functools import wraps
|
| 5 |
from bot.config import Telegram
|
|
|
|
| 6 |
|
| 7 |
def verify_user(func: Callable):
|
| 8 |
|
|
@@ -12,5 +13,13 @@ def verify_user(func: Callable):
|
|
| 12 |
|
| 13 |
if not Telegram.ALLOWED_USER_IDS or chat_id in Telegram.ALLOWED_USER_IDS:
|
| 14 |
return await func(client, update)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
return decorator
|
|
|
|
| 1 |
from hydrogram import Client
|
| 2 |
+
from hydrogram.types import Message, CallbackQuery, InlineKeyboardMarkup, InlineKeyboardButton
|
| 3 |
from typing import Union, Callable
|
| 4 |
from functools import wraps
|
| 5 |
from bot.config import Telegram
|
| 6 |
+
from bot.modules.static import *
|
| 7 |
|
| 8 |
def verify_user(func: Callable):
|
| 9 |
|
|
|
|
| 13 |
|
| 14 |
if not Telegram.ALLOWED_USER_IDS or chat_id in Telegram.ALLOWED_USER_IDS:
|
| 15 |
return await func(client, update)
|
| 16 |
+
elif isinstance(update, CallbackQuery):
|
| 17 |
+
return await update.answer(UserNotInAllowedList, show_alert=True)
|
| 18 |
+
elif isinstance(update, Message):
|
| 19 |
+
return await update.reply(
|
| 20 |
+
text = UserNotInAllowedList,
|
| 21 |
+
quote = True,
|
| 22 |
+
reply_markup = InlineKeyboardMarkup([[InlineKeyboardButton('Deploy Own', url='https://github.com/TheCaduceus/FileStreamBot')]])
|
| 23 |
+
)
|
| 24 |
|
| 25 |
return decorator
|
bot/modules/static.py
CHANGED
|
@@ -1,11 +1,30 @@
|
|
| 1 |
WelcomeText = \
|
| 2 |
-
"""
|
| 3 |
Hi **%(first_name)s**, send me a file to instantly generate file links.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
"""
|
| 5 |
|
| 6 |
PrivacyText = \
|
| 7 |
"""
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
"""
|
| 10 |
|
| 11 |
FileLinksText = \
|
|
@@ -41,3 +60,8 @@ InvalidPayloadText = \
|
|
| 41 |
"""
|
| 42 |
Invalid payload.
|
| 43 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
WelcomeText = \
|
| 2 |
+
"""\
|
| 3 |
Hi **%(first_name)s**, send me a file to instantly generate file links.
|
| 4 |
+
|
| 5 |
+
**Commands:**
|
| 6 |
+
/privacy - View bot's privacy policy.
|
| 7 |
+
/log - Get bot's log file. (owner only)
|
| 8 |
+
/help - Show this message.
|
| 9 |
"""
|
| 10 |
|
| 11 |
PrivacyText = \
|
| 12 |
"""
|
| 13 |
+
**Privacy Policy**
|
| 14 |
+
|
| 15 |
+
**1.Data Storage:** Files you upload/send are securely saved in the bot's private Telegram channel.
|
| 16 |
+
|
| 17 |
+
**2.Download Links:** Links include a secret code to prevent unauthorized access.
|
| 18 |
+
|
| 19 |
+
**3.User Control:** You can revoke links anytime using the "Revoke" button.
|
| 20 |
+
|
| 21 |
+
**4.Moderation:** The bot owner can view and delete your files if necessary.
|
| 22 |
+
|
| 23 |
+
**5.Open Source:** The bot is [open source](https://github.com/TheCaduceus/FileStreamBot). Deploy your own instance for maximum privacy.
|
| 24 |
+
|
| 25 |
+
**6.Retention:** Files are stored until you revoke their links.
|
| 26 |
+
|
| 27 |
+
__By using this bot, you agree to this policy.__
|
| 28 |
"""
|
| 29 |
|
| 30 |
FileLinksText = \
|
|
|
|
| 60 |
"""
|
| 61 |
Invalid payload.
|
| 62 |
"""
|
| 63 |
+
|
| 64 |
+
UserNotInAllowedList = \
|
| 65 |
+
"""
|
| 66 |
+
You are not allowed to use this bot.
|
| 67 |
+
"""
|
bot/plugins/commands.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
from hydrogram import filters
|
| 2 |
from hydrogram.types import Message
|
| 3 |
from bot import TelegramBot
|
|
|
|
| 4 |
from bot.modules.static import *
|
| 5 |
from bot.modules.decorators import verify_user
|
| 6 |
|
|
@@ -8,11 +9,15 @@ from bot.modules.decorators import verify_user
|
|
| 8 |
@verify_user
|
| 9 |
async def start_command(_, msg: Message):
|
| 10 |
await msg.reply(
|
| 11 |
-
text=WelcomeText % {'first_name': msg.from_user.first_name},
|
| 12 |
-
quote=True
|
| 13 |
)
|
| 14 |
|
| 15 |
@TelegramBot.on_message(filters.command('privacy') & filters.private)
|
| 16 |
@verify_user
|
| 17 |
async def privacy_command(_, msg: Message):
|
| 18 |
-
await msg.reply(text=PrivacyText, quote=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from hydrogram import filters
|
| 2 |
from hydrogram.types import Message
|
| 3 |
from bot import TelegramBot
|
| 4 |
+
from bot.config import Telegram
|
| 5 |
from bot.modules.static import *
|
| 6 |
from bot.modules.decorators import verify_user
|
| 7 |
|
|
|
|
| 9 |
@verify_user
|
| 10 |
async def start_command(_, msg: Message):
|
| 11 |
await msg.reply(
|
| 12 |
+
text = WelcomeText % {'first_name': msg.from_user.first_name},
|
| 13 |
+
quote = True
|
| 14 |
)
|
| 15 |
|
| 16 |
@TelegramBot.on_message(filters.command('privacy') & filters.private)
|
| 17 |
@verify_user
|
| 18 |
async def privacy_command(_, msg: Message):
|
| 19 |
+
await msg.reply(text=PrivacyText, quote=True, disable_web_page_preview=True)
|
| 20 |
+
|
| 21 |
+
@TelegramBot.on_message(filters.command('log') & filters.chat(Telegram.OWNER_ID))
|
| 22 |
+
async def log_command(_, msg: Message):
|
| 23 |
+
await msg.reply_document('event-log.txt', quote=True)
|