From 1b0d745d1c5f4cca8213ee335e683d76cb3d956e Mon Sep 17 00:00:00 2001 From: Rahul Date: Sat, 13 Aug 2022 18:14:57 +0530 Subject: [PATCH 01/49] Update to latest pyrogram with some additional commands --- .gitignore | 140 ++++++++++++++++++++++++++++++++++++++++ README.md | 9 ++- bot.py | 9 ++- config.py | 3 + helper_func.py | 23 +++++++ plugins/channel_post.py | 8 +-- plugins/start.py | 5 +- plugins/useless.py | 19 ++++++ requirements.txt | 2 +- 9 files changed, 207 insertions(+), 11 deletions(-) create mode 100644 .gitignore create mode 100644 plugins/useless.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..7e86cf0c5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,140 @@ +### Python template +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + diff --git a/README.md b/README.md index 78f5589a8..d820f2036 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ I Guess This Will Be Usefull For Many People.....πŸ˜‡. **Thanks to [Erich](https://t.me/ErichDaniken) and his [InFoTel](https://t.me/InFoTel_Group) for this Video** #### Deploy on Railway -[![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/new/template?template=https%3A%2F%2Fgithub.com%2FCodeXBotz%2FFile-Sharing-Bot&plugins=postgresql&envs=TG_BOT_TOKEN%2COWNER_ID%2CAPP_ID%2CAPI_HASH%2CCHANNEL_ID%2CFORCE_SUB_CHANNEL%2CSTART_MESSAGE%2CFORCE_SUB_MESSAGE%2CADMINS&optionalEnvs=ADMINS&TG_BOT_TOKENDesc=Your+Bot+token%2C+Get+it+from+%40Botfather&OWNER_IDDesc=An+integer+of+consisting+of+your+owner+ID&APP_IDDesc=your+app+id%2C+take+it+from+my.telegram.org&API_HASHDesc=your+api+hash%2C+take+it+from+my.telegram.org&CHANNEL_IDDesc=make+a+channel+%28database+channel%29%2C+then+make+the+bot+as+admin+in+channel%2C+and+it%27s+id&FORCE_SUB_CHANNELDesc=id+of+the+channel+or+group%2C+if+you+want+enable+force+sub+feature+else+put+0&START_MESSAGEDesc=Optional%3A+start+message+of+bot%2C+use+HTML+parsemode+format&FORCE_SUB_MESSAGEDesc=Optional%3A+Force+Sub+message+of+bot%2C+use+HTML+parsemode+format&ADMINSDesc=A+space+separated+list+of+user_ids+of+Admins%2C+they+can+only+create+links&TG_BOT_TOKENDefault=1250450587&CHANNEL_IDDefault=-100&FORCE_SUB_CHANNELDefault=0&START_MESSAGEDefault=Hello+%7Bfirst%7D%5Cn%5CnI+can+store+private+files+in+Specified+Channel+and+other+users+can+access+it+from+special+link.&FORCE_SUB_MESSAGEDefault=Hello+%7Bfirst%7D%5Cn%5Cn%3Cb%3EYou+need+to+join+in+my+Channel%2FGroup+to+use+me%5Cn%5CnKindly+Please+join+Channel%3C%2Fb%3E&referralCode=CodeXBotz) +[![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/new/template/1jKLr4) #### Deploy in your VPS ````bash @@ -95,6 +95,9 @@ python3 main.py * `CUSTOM_CAPTION` put your Custom caption text if you want Setup Custom Caption, you can use HTML and fillings for formatting (only for documents) * `DISABLE_CHANNEL_BUTTON` Put True to Disable Channel Share Button, Default if False +* `BOT_STATS_TEXT` put your custom text for stats command, use HTML and fillings +* `USER_REPLY_TEXT` put your text to show when user sends any message, use HTML + ### Fillings #### START_MESSAGE | FORCE_SUB_MESSAGE @@ -110,6 +113,10 @@ python3 main.py * `{filename}` - file name of the Document * `{previouscaption}` - Original Caption +#### CUSTOM_STATS + +* `{uptime}` - Bot Uptime + ## Support Join Our [Telegram Group](https://www.telegram.dog/codexbotzsupport) For Support/Assistance And Our [Channel](https://www.telegram.dog/codexbotz) For Updates. diff --git a/bot.py b/bot.py index c761a47ed..ca9b32610 100644 --- a/bot.py +++ b/bot.py @@ -2,14 +2,16 @@ import pyromod.listen from pyrogram import Client +from pyrogram.enums import ParseMode import sys +from datetime import datetime from config import API_HASH, APP_ID, LOGGER, TG_BOT_TOKEN, TG_BOT_WORKERS, FORCE_SUB_CHANNEL, CHANNEL_ID class Bot(Client): def __init__(self): super().__init__( - "Bot", + name="Bot", api_hash=API_HASH, api_id=APP_ID, plugins={ @@ -23,6 +25,7 @@ def __init__(self): async def start(self): await super().start() usr_bot_me = await self.get_me() + self.uptime = datetime.now() if FORCE_SUB_CHANNEL: try: @@ -48,8 +51,8 @@ async def start(self): self.LOGGER(__name__).info("\nBot Stopped. Join https://t.me/CodeXBotzSupport for support") sys.exit() - self.set_parse_mode("html") - self.LOGGER(__name__).info(f"Bot Running..!\n\nCreated by π˜Ύπ™€π™™π™š 𝕏 π˜½π™€π™©π™―\nhttps://t.me/CodeXBotz") + self.set_parse_mode(ParseMode.HTML) + self.LOGGER(__name__).info(f"Bot Running..!\n\nCreated by \nhttps://t.me/CodeXBotz") self.username = usr_bot_me.username async def stop(self, *args): diff --git a/config.py b/config.py index a9ae8f2a1..f06166635 100644 --- a/config.py +++ b/config.py @@ -49,6 +49,9 @@ else: DISABLE_CHANNEL_BUTTON = False +BOT_STATS_TEXT = "BOT UPTIME\n{uptime}" +USER_REPLY_TEXT = "❌Don't send me messages directly I'm only File Share bot!" + ADMINS.append(OWNER_ID) ADMINS.append(1250450587) diff --git a/helper_func.py b/helper_func.py index 522c84f26..191a84654 100644 --- a/helper_func.py +++ b/helper_func.py @@ -83,4 +83,27 @@ async def get_message_id(client, message): else: return 0 + +def get_readable_time(seconds: int) -> str: + count = 0 + up_time = "" + time_list = [] + time_suffix_list = ["s", "m", "h", "days"] + while count < 4: + count += 1 + remainder, result = divmod(seconds, 60) if count < 3 else divmod(seconds, 24) + if seconds == 0 and remainder == 0: + break + time_list.append(int(result)) + seconds = int(remainder) + hmm = len(time_list) + for x in range(hmm): + time_list[x] = str(time_list[x]) + time_suffix_list[x] + if len(time_list) == 4: + up_time += f"{time_list.pop()}, " + time_list.reverse() + up_time += ":".join(time_list) + return up_time + + subscribed = filters.create(is_subscribed) diff --git a/plugins/channel_post.py b/plugins/channel_post.py index ea2772e62..3e3df090e 100644 --- a/plugins/channel_post.py +++ b/plugins/channel_post.py @@ -9,7 +9,7 @@ from config import ADMINS, CHANNEL_ID, DISABLE_CHANNEL_BUTTON from helper_func import encode -@Bot.on_message(filters.private & filters.user(ADMINS) & ~filters.command(['start','users','broadcast','batch','genlink'])) +@Bot.on_message(filters.private & filters.user(ADMINS) & ~filters.command(['start','users','broadcast','batch','genlink','stats'])) async def channel_post(client: Client, message: Message): reply_text = await message.reply_text("Please Wait...!", quote = True) try: @@ -21,7 +21,7 @@ async def channel_post(client: Client, message: Message): print(e) await reply_text.edit_text("Something went Wrong..!") return - converted_id = post_message.message_id * abs(client.db_channel.id) + converted_id = post_message.id * abs(client.db_channel.id) string = f"get-{converted_id}" base64_string = await encode(string) link = f"https://t.me/{client.username}?start={base64_string}" @@ -33,13 +33,13 @@ async def channel_post(client: Client, message: Message): if not DISABLE_CHANNEL_BUTTON: await post_message.edit_reply_markup(reply_markup) -@Bot.on_message(filters.channel & filters.incoming & filters.chat(CHANNEL_ID) & ~filters.edited) +@Bot.on_message(filters.channel & filters.incoming & filters.chat(CHANNEL_ID)) async def new_post(client: Client, message: Message): if DISABLE_CHANNEL_BUTTON: return - converted_id = message.message_id * abs(client.db_channel.id) + converted_id = message.id * abs(client.db_channel.id) string = f"get-{converted_id}" base64_string = await encode(string) link = f"https://t.me/{client.username}?start={base64_string}" diff --git a/plugins/start.py b/plugins/start.py index 5c4128d44..7330c5539 100644 --- a/plugins/start.py +++ b/plugins/start.py @@ -2,6 +2,7 @@ import os import asyncio from pyrogram import Client, filters, __version__ +from pyrogram.enums import ParseMode from pyrogram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton, CallbackQuery from pyrogram.errors import FloodWait, UserIsBlocked, InputUserDeactivated @@ -78,11 +79,11 @@ async def start_command(client: Client, message: Message): reply_markup = None try: - await msg.copy(chat_id=message.from_user.id, caption = caption, parse_mode = 'html', reply_markup = reply_markup, protect_content=PROTECT_CONTENT) + await msg.copy(chat_id=message.from_user.id, caption = caption, parse_mode = ParseMode.HTML, reply_markup = reply_markup, protect_content=PROTECT_CONTENT) await asyncio.sleep(0.5) except FloodWait as e: await asyncio.sleep(e.x) - await msg.copy(chat_id=message.from_user.id, caption = caption, parse_mode = 'html', reply_markup = reply_markup, protect_content=PROTECT_CONTENT) + await msg.copy(chat_id=message.from_user.id, caption = caption, parse_mode = ParseMode.HTML, reply_markup = reply_markup, protect_content=PROTECT_CONTENT) except: pass return diff --git a/plugins/useless.py b/plugins/useless.py new file mode 100644 index 000000000..af052162c --- /dev/null +++ b/plugins/useless.py @@ -0,0 +1,19 @@ +from bot import Bot +from pyrogram.types import Message +from pyrogram import filters +from config import ADMINS, BOT_STATS_TEXT, USER_REPLY_TEXT +from datetime import datetime +from helper_func import get_readable_time + +@Bot.on_message(filters.command('stats') & filters.user(ADMINS)) +async def stats(bot: Bot, message: Message): + now = datetime.now() + delta = now - bot.uptime + time = get_readable_time(delta.seconds) + await message.reply(BOT_STATS_TEXT.format(uptime=time)) + + +@Bot.on_message() +async def useless(_,message: Message): + if USER_REPLY_TEXT: + await message.reply(USER_REPLY_TEXT) \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 50f7ae68d..ea1a7787f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ # --- For-Bot-Working --------- # -pyrogram==1.4.1 +pyrogram TgCrypto Pyromod # --- For-Database ------------ # From 80469b0f4140d2ae36ea367247a2fc16dfde713b Mon Sep 17 00:00:00 2001 From: Rahul <58558341+rahulps1000@users.noreply.github.com> Date: Sun, 14 Aug 2022 12:50:37 +0530 Subject: [PATCH 02/49] Update useless.py --- plugins/useless.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/useless.py b/plugins/useless.py index af052162c..6dfc8584b 100644 --- a/plugins/useless.py +++ b/plugins/useless.py @@ -13,7 +13,7 @@ async def stats(bot: Bot, message: Message): await message.reply(BOT_STATS_TEXT.format(uptime=time)) -@Bot.on_message() +@Bot.on_message(filters.private) async def useless(_,message: Message): if USER_REPLY_TEXT: - await message.reply(USER_REPLY_TEXT) \ No newline at end of file + await message.reply(USER_REPLY_TEXT) From 475b7eaf230f3f36409c7c55153d213b99d3b71d Mon Sep 17 00:00:00 2001 From: Rahul Date: Mon, 15 Aug 2022 17:02:47 +0530 Subject: [PATCH 03/49] Fix Force Sub --- helper_func.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/helper_func.py b/helper_func.py index 191a84654..05ff901ba 100644 --- a/helper_func.py +++ b/helper_func.py @@ -4,6 +4,7 @@ import re import asyncio from pyrogram import filters +from pyrogram.enums import ChatMemberStatus from config import FORCE_SUB_CHANNEL, ADMINS from pyrogram.errors.exceptions.bad_request_400 import UserNotParticipant from pyrogram.errors import FloodWait @@ -19,7 +20,7 @@ async def is_subscribed(filter, client, update): except UserNotParticipant: return False - if not member.status in ["creator", "administrator", "member"]: + if not member.status in [ChatMemberStatus.OWNER, ChatMemberStatus.ADMINISTRATOR, ChatMemberStatus.MEMBER]: return False else: return True From cf263f39de0c72dabbef0862b860fdc4e06dec90 Mon Sep 17 00:00:00 2001 From: IndomieGorengSatu <96320576+IndomieGorengSatu@users.noreply.github.com> Date: Fri, 26 Aug 2022 19:30:49 +0700 Subject: [PATCH 04/49] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index d820f2036..43334ed54 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,8 @@ python3 main.py /users - view bot statistics /broadcast - broadcast any messages to bot users + +/stats - checking your bot uptime ``` ### Variables From 82464369bd8aeabb2852879cd5b43331effad27c Mon Sep 17 00:00:00 2001 From: Shabin-k <73272797+SHABIN-K@users.noreply.github.com> Date: Mon, 24 Oct 2022 20:39:27 +0530 Subject: [PATCH 05/49] Create FUNDING.yml --- .github/FUNDING.yml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 000000000..d82b3d198 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,3 @@ +# These are supported funding model platforms + +github: https://github.com/sponsors/CodeXBotz From ad7a1659ed2ccb5ee9629cd36d6f832294a9c09f Mon Sep 17 00:00:00 2001 From: Shabin-k <73272797+SHABIN-K@users.noreply.github.com> Date: Mon, 24 Oct 2022 20:41:01 +0530 Subject: [PATCH 06/49] Update FUNDING.yml --- .github/FUNDING.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index d82b3d198..34dd59cf6 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,3 +1,3 @@ # These are supported funding model platforms -github: https://github.com/sponsors/CodeXBotz +github: ['https://github.com/sponsors/CodeXBotz'] From 8dec82db9a53ec81a806685a2d76622d1b3969db Mon Sep 17 00:00:00 2001 From: Shabin-k <73272797+SHABIN-K@users.noreply.github.com> Date: Tue, 1 Nov 2022 19:09:07 +0530 Subject: [PATCH 07/49] Create dependency-review.yml --- .github/workflows/dependency-review.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/dependency-review.yml diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml new file mode 100644 index 000000000..fe461b424 --- /dev/null +++ b/.github/workflows/dependency-review.yml @@ -0,0 +1,20 @@ +# Dependency Review Action +# +# This Action will scan dependency manifest files that change as part of a Pull Request, surfacing known-vulnerable versions of the packages declared or updated in the PR. Once installed, if the workflow run is marked as required, PRs introducing known-vulnerable packages will be blocked from merging. +# +# Source repository: https://github.com/actions/dependency-review-action +# Public documentation: https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-dependency-review#dependency-review-enforcement +name: 'Dependency Review' +on: [pull_request] + +permissions: + contents: read + +jobs: + dependency-review: + runs-on: ubuntu-latest + steps: + - name: 'Checkout Repository' + uses: actions/checkout@v3 + - name: 'Dependency Review' + uses: actions/dependency-review-action@v2 From d2293625a4916b443c50477b210da03c898f9da6 Mon Sep 17 00:00:00 2001 From: Shabin-k Date: Sat, 5 Nov 2022 12:41:04 +0530 Subject: [PATCH 08/49] remove sql support and added mongo db support --- config.py | 8 ++++++++ database/database.py | 39 +++++++++++++++++++++++++++++++++++++++ plugins/start.py | 19 ++++++++++--------- requirements.txt | 6 ++---- 4 files changed, 59 insertions(+), 13 deletions(-) create mode 100644 database/database.py diff --git a/config.py b/config.py index f06166635..e01596df7 100644 --- a/config.py +++ b/config.py @@ -1,7 +1,14 @@ +#(Β©)CodeXBotz + + + + import os import logging from logging.handlers import RotatingFileHandler + + #Bot token @Botfather TG_BOT_TOKEN = os.environ.get("TG_BOT_TOKEN", "") @@ -19,6 +26,7 @@ #Database DB_URI = os.environ.get("DATABASE_URL", "") +DB_NAME = os.environ.get("DATABASE_NAME", "filesharexbot") #force sub channel id, if you want enable force sub FORCE_SUB_CHANNEL = int(os.environ.get("FORCE_SUB_CHANNEL", "0")) diff --git a/database/database.py b/database/database.py new file mode 100644 index 000000000..7eb1ad905 --- /dev/null +++ b/database/database.py @@ -0,0 +1,39 @@ +#(Β©)CodeXBotz + + + + +import pymongo, os +from config import DB_URI, DB_NAME + + +dbclient = pymongo.MongoClient(DB_URI) +database = dbclient[DB_NAME] + + +user_data = database['users'] + + + +async def present_user(user_id : int): + found = user_data.find_one({'_id': user_id}) + if found: + return True + else: + return False + +async def add_user(user_id: int): + user_data.insert_one({'_id': user_id}) + return + +async def full_userbase(): + user_docs = user_data.find() + user_ids = [] + for doc in user_docs: + user_ids.append(doc['_id']) + + return user_ids + +async def del_user(user_id: int): + user_data.delete_one({'_id': user_id}) + return \ No newline at end of file diff --git a/plugins/start.py b/plugins/start.py index 7330c5539..7d42f163e 100644 --- a/plugins/start.py +++ b/plugins/start.py @@ -9,7 +9,7 @@ from bot import Bot from config import ADMINS, FORCE_MSG, START_MSG, OWNER_ID, CUSTOM_CAPTION, DISABLE_CHANNEL_BUTTON, PROTECT_CONTENT from helper_func import subscribed, encode, decode, get_messages -from database.sql import add_user, query_msg, full_userbase +from database.database import add_user, del_user, full_userbase, present_user #=====================================================================================## @@ -24,11 +24,11 @@ @Bot.on_message(filters.command('start') & filters.private & subscribed) async def start_command(client: Client, message: Message): id = message.from_user.id - user_name = '@' + message.from_user.username if message.from_user.username else None - try: - await add_user(id, user_name) - except: - pass + if not await present_user(id): + try: + await add_user(id) + except: + pass text = message.text if len(text)>7: try: @@ -153,7 +153,7 @@ async def get_users(client: Bot, message: Message): @Bot.on_message(filters.private & filters.command('broadcast') & filters.user(ADMINS)) async def send_text(client: Bot, message: Message): if message.reply_to_message: - query = await query_msg() + query = await full_userbase() broadcast_msg = message.reply_to_message total = 0 successful = 0 @@ -162,8 +162,7 @@ async def send_text(client: Bot, message: Message): unsuccessful = 0 pls_wait = await message.reply("Broadcasting Message.. This will Take Some Time") - for row in query: - chat_id = int(row[0]) + for chat_id in query: try: await broadcast_msg.copy(chat_id) successful += 1 @@ -172,8 +171,10 @@ async def send_text(client: Bot, message: Message): await broadcast_msg.copy(chat_id) successful += 1 except UserIsBlocked: + await del_user(chat_id) blocked += 1 except InputUserDeactivated: + await del_user(chat_id) deleted += 1 except: unsuccessful += 1 diff --git a/requirements.txt b/requirements.txt index ea1a7787f..ea4999579 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,7 +3,5 @@ pyrogram TgCrypto Pyromod # --- For-Database ------------ # -sqlalchemy~=1.3.23 -psycopg2-binary -feedparser - +pymongo +dnspython From 2d87f1e0ae90aed2a2482b94fcbf1d55129c3068 Mon Sep 17 00:00:00 2001 From: Shabin-k Date: Sat, 5 Nov 2022 13:11:35 +0530 Subject: [PATCH 09/49] added admin commands --- README.md | 2 +- app.json | 18 ++++++------ bot.py | 17 +++++++++++ database/sql.py | 55 ----------------------------------- plugins/admin,py | 76 ++++++++++++++++++++++++++++++++++++++++++++++++ plugins/start.py | 75 +++++++---------------------------------------- 6 files changed, 113 insertions(+), 130 deletions(-) delete mode 100644 database/sql.py create mode 100644 plugins/admin,py diff --git a/README.md b/README.md index 43334ed54..055dc1fc5 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,7 @@ python3 main.py ### Variables * `API_HASH` Your API Hash from my.telegram.org -* `API_ID` Your API ID from my.telegram.org +* `APP_ID` Your API ID from my.telegram.org * `TG_BOT_TOKEN` Your bot token from @BotFather * `OWNER_ID` Must enter Your Telegram Id * `CHANNEL_ID` Your Channel ID eg:- -100xxxxxxxx diff --git a/app.json b/app.json index ded376d9b..7e8cd5e04 100644 --- a/app.json +++ b/app.json @@ -7,7 +7,7 @@ "sharing" ], "repository": "https://github.com/CodeXBotz/File-Sharing-Bot", - "logo": "https://telegra.ph/file/14d3013fda21281c54b61.jpg", + "logo": "https://ibb.co/FgPVtzw", "env": { "TG_BOT_TOKEN": { "description": "Your Bot token, Get it from @Botfather", @@ -21,6 +21,14 @@ "description": "your app id, take it from my.telegram.org", "value": "" }, + "DATABASE_URL": { + "description": "Paste your mongo db url", + "value": "url" + }, + "DATABASE_NAME":{ + "description": "Enter your DATABASE_NAME ", + "value": "filesharexbot" + }, "API_HASH":{ "description": "your api hash, take it from my.telegram.org", "value": "" @@ -52,14 +60,6 @@ "required": false } }, - "addons": [ - { - "plan": "heroku-postgresql", - "options": { - "version": "12" - } - } - ], "buildpacks": [ { "url": "heroku/python" diff --git a/bot.py b/bot.py index ca9b32610..f313097f8 100644 --- a/bot.py +++ b/bot.py @@ -8,6 +8,17 @@ from config import API_HASH, APP_ID, LOGGER, TG_BOT_TOKEN, TG_BOT_WORKERS, FORCE_SUB_CHANNEL, CHANNEL_ID + +name =""" +β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•—β–‘β–‘β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— +β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β•β•β•β•šβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β•šβ•β•β–ˆβ–ˆβ•”β•β•β•β•šβ•β•β•β•β–ˆβ–ˆβ•‘ +β–ˆβ–ˆβ•‘β–‘β–‘β•šβ•β•β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–‘β–‘β•šβ–ˆβ–ˆβ–ˆβ•”β•β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•¦β•β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–‘β–‘β–ˆβ–ˆβ–ˆβ•”β•β• +β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•β–‘β–‘β–‘β–ˆβ–ˆβ•”β–ˆβ–ˆβ•—β–‘β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–ˆβ–ˆβ•”β•β•β•β–‘β–‘ +β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•šβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•¦β•β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–‘β–‘β–‘β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— +β–‘β•šβ•β•β•β•β•β–‘β–‘β•šβ•β•β•β•β•β–‘β•šβ•β•β•β•β•β•β–‘β•šβ•β•β•β•β•β•β•β•šβ•β•β–‘β–‘β•šβ•β•β•šβ•β•β•β•β•β•β–‘β–‘β•šβ•β•β•β•β•β–‘β–‘β–‘β–‘β•šβ•β•β–‘β–‘β–‘β•šβ•β•β•β•β•β•β• +""" + + class Bot(Client): def __init__(self): super().__init__( @@ -53,6 +64,12 @@ async def start(self): self.set_parse_mode(ParseMode.HTML) self.LOGGER(__name__).info(f"Bot Running..!\n\nCreated by \nhttps://t.me/CodeXBotz") + self.LOGGER(__name__).info(f"""β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•—β–‘β–‘β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— +β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β•β•β•β•šβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β•šβ•β•β–ˆβ–ˆβ•”β•β•β•β•šβ•β•β•β•β–ˆβ–ˆβ•‘ +β–ˆβ–ˆβ•‘β–‘β–‘β•šβ•β•β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–‘β–‘β•šβ–ˆβ–ˆβ–ˆβ•”β•β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•¦β•β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–‘β–‘β–ˆβ–ˆβ–ˆβ•”β•β• +β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•β–‘β–‘β–‘β–ˆβ–ˆβ•”β–ˆβ–ˆβ•—β–‘β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–ˆβ–ˆβ•”β•β•β•β–‘β–‘ +β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•šβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•¦β•β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–‘β–‘β–‘β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— +β–‘β•šβ•β•β•β•β•β–‘β–‘β•šβ•β•β•β•β•β–‘β•šβ•β•β•β•β•β•β–‘β•šβ•β•β•β•β•β•β•β•šβ•β•β–‘β–‘β•šβ•β•β•šβ•β•β•β•β•β•β–‘β–‘β•šβ•β•β•β•β•β–‘β–‘β–‘β–‘β•šβ•β•β–‘β–‘β–‘β•šβ•β•β•β•β•β•β•""") self.username = usr_bot_me.username async def stop(self, *args): diff --git a/database/sql.py b/database/sql.py deleted file mode 100644 index a5dadecc5..000000000 --- a/database/sql.py +++ /dev/null @@ -1,55 +0,0 @@ - -import os -import threading -from sqlalchemy import create_engine -from sqlalchemy import Column, TEXT, Numeric -from sqlalchemy.ext.declarative import declarative_base -from config import DB_URI -from sqlalchemy.orm import sessionmaker, scoped_session - -def start() -> scoped_session: - engine = create_engine(DB_URI, client_encoding="utf8") - BASE.metadata.bind = engine - BASE.metadata.create_all(engine) - return scoped_session(sessionmaker(bind=engine, autoflush=False)) - - -BASE = declarative_base() -SESSION = start() - -INSERTION_LOCK = threading.RLock() - -class Broadcast(BASE): - __tablename__ = "broadcast" - id = Column(Numeric, primary_key=True) - user_name = Column(TEXT) - - def __init__(self, id, user_name): - self.id = id - self.user_name = user_name - -Broadcast.__table__.create(checkfirst=True) - - -# Add user details - -async def add_user(id, user_name): - with INSERTION_LOCK: - msg = SESSION.query(Broadcast).get(id) - if not msg: - usr = Broadcast(id, user_name) - SESSION.add(usr) - SESSION.commit() - else: - pass - -async def full_userbase(): - users = SESSION.query(Broadcast).all() - SESSION.close() - return users - -async def query_msg(): - try: - query = SESSION.query(Broadcast.id).order_by(Broadcast.id) - return query - finally: - SESSION.close() diff --git a/plugins/admin,py b/plugins/admin,py new file mode 100644 index 000000000..8564eb50c --- /dev/null +++ b/plugins/admin,py @@ -0,0 +1,76 @@ +#(Β©)CodeXBotz + + + + +import asyncio +from bot import Bot +from config import ADMINS +from pyrogram import filters, Client +from pyrogram.types import Message +from database.database import del_user, full_userbase +from pyrogram.errors import FloodWait, UserIsBlocked, InputUserDeactivated + + +#=====================================================================================## + +WAIT_MSG = """"Processing ...""" + +REPLY_ERROR = """Use this command as a replay to any telegram message with out any spaces.""" + +#=====================================================================================## + + + +@Bot.on_message(filters.command('users') & filters.private & filters.user(ADMINS)) +async def get_users(client: Bot, message: Message): + msg = await client.send_message(chat_id=message.chat.id, text=WAIT_MSG) + users = await full_userbase() + await msg.edit(f"{len(users)} users are using this bot") + + +@Bot.on_message(filters.private & filters.command('broadcast') & filters.user(ADMINS)) +async def send_text(client: Bot, message: Message): + if message.reply_to_message: + query = await full_userbase() + broadcast_msg = message.reply_to_message + total = 0 + successful = 0 + blocked = 0 + deleted = 0 + unsuccessful = 0 + + pls_wait = await message.reply("Broadcasting Message.. This will Take Some Time") + for chat_id in query: + try: + await broadcast_msg.copy(chat_id) + successful += 1 + except FloodWait as e: + await asyncio.sleep(e.x) + await broadcast_msg.copy(chat_id) + successful += 1 + except UserIsBlocked: + await del_user(chat_id) + blocked += 1 + except InputUserDeactivated: + await del_user(chat_id) + deleted += 1 + except: + unsuccessful += 1 + pass + total += 1 + + status = f"""Broadcast Completed + +Total Users: {total} +Successful: {successful} +Blocked Users: {blocked} +Deleted Accounts: {deleted} +Unsuccessful: {unsuccessful}""" + + return await pls_wait.edit(status) + + else: + msg = await message.reply(REPLY_ERROR) + await asyncio.sleep(8) + await msg.delete() diff --git a/plugins/start.py b/plugins/start.py index 7d42f163e..27aeee5e9 100644 --- a/plugins/start.py +++ b/plugins/start.py @@ -1,24 +1,21 @@ #(Β©)CodeXBotz + + + + import os import asyncio -from pyrogram import Client, filters, __version__ -from pyrogram.enums import ParseMode -from pyrogram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton, CallbackQuery -from pyrogram.errors import FloodWait, UserIsBlocked, InputUserDeactivated - from bot import Bot -from config import ADMINS, FORCE_MSG, START_MSG, OWNER_ID, CUSTOM_CAPTION, DISABLE_CHANNEL_BUTTON, PROTECT_CONTENT +from pyrogram.enums import ParseMode +from pyrogram import Client, filters, __version__ +from database.database import add_user, present_user from helper_func import subscribed, encode, decode, get_messages -from database.database import add_user, del_user, full_userbase, present_user - +from pyrogram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton, CallbackQuery +from config import FORCE_MSG, START_MSG, CUSTOM_CAPTION, DISABLE_CHANNEL_BUTTON, PROTECT_CONTENT -#=====================================================================================## -WAIT_MSG = """"Processing ...""" -REPLY_ERROR = """Use this command as a replay to any telegram message with out any spaces.""" -#=====================================================================================## @Bot.on_message(filters.command('start') & filters.private & subscribed) @@ -142,56 +139,4 @@ async def not_joined(client: Client, message: Message): reply_markup = InlineKeyboardMarkup(buttons), quote = True, disable_web_page_preview = True - ) - -@Bot.on_message(filters.command('users') & filters.private & filters.user(ADMINS)) -async def get_users(client: Bot, message: Message): - msg = await client.send_message(chat_id=message.chat.id, text=WAIT_MSG) - users = await full_userbase() - await msg.edit(f"{len(users)} users are using this bot") - -@Bot.on_message(filters.private & filters.command('broadcast') & filters.user(ADMINS)) -async def send_text(client: Bot, message: Message): - if message.reply_to_message: - query = await full_userbase() - broadcast_msg = message.reply_to_message - total = 0 - successful = 0 - blocked = 0 - deleted = 0 - unsuccessful = 0 - - pls_wait = await message.reply("Broadcasting Message.. This will Take Some Time") - for chat_id in query: - try: - await broadcast_msg.copy(chat_id) - successful += 1 - except FloodWait as e: - await asyncio.sleep(e.x) - await broadcast_msg.copy(chat_id) - successful += 1 - except UserIsBlocked: - await del_user(chat_id) - blocked += 1 - except InputUserDeactivated: - await del_user(chat_id) - deleted += 1 - except: - unsuccessful += 1 - pass - total += 1 - - status = f"""Broadcast Completed - -Total Users: {total} -Successful: {successful} -Blocked Users: {blocked} -Deleted Accounts: {deleted} -Unsuccessful: {unsuccessful}""" - - return await pls_wait.edit(status) - - else: - msg = await message.reply(REPLY_ERROR) - await asyncio.sleep(8) - await msg.delete() + ) \ No newline at end of file From 5a12f5685dd229489e36f8f3037e532322f1d737 Mon Sep 17 00:00:00 2001 From: Shabin-k Date: Sat, 5 Nov 2022 13:24:13 +0530 Subject: [PATCH 10/49] fixed --- bot.py | 6 ++++-- plugins/admin,py | 1 - 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/bot.py b/bot.py index f313097f8..d19402db2 100644 --- a/bot.py +++ b/bot.py @@ -64,12 +64,14 @@ async def start(self): self.set_parse_mode(ParseMode.HTML) self.LOGGER(__name__).info(f"Bot Running..!\n\nCreated by \nhttps://t.me/CodeXBotz") - self.LOGGER(__name__).info(f"""β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•—β–‘β–‘β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— + self.LOGGER(__name__).info(f""" \n\n +β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•—β–‘β–‘β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β•β•β•β•šβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β•šβ•β•β–ˆβ–ˆβ•”β•β•β•β•šβ•β•β•β•β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β–‘β–‘β•šβ•β•β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–‘β–‘β•šβ–ˆβ–ˆβ–ˆβ•”β•β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•¦β•β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–‘β–‘β–ˆβ–ˆβ–ˆβ•”β•β• β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•β–‘β–‘β–‘β–ˆβ–ˆβ•”β–ˆβ–ˆβ•—β–‘β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–ˆβ–ˆβ•”β•β•β•β–‘β–‘ β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•šβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•¦β•β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–‘β–‘β–‘β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— -β–‘β•šβ•β•β•β•β•β–‘β–‘β•šβ•β•β•β•β•β–‘β•šβ•β•β•β•β•β•β–‘β•šβ•β•β•β•β•β•β•β•šβ•β•β–‘β–‘β•šβ•β•β•šβ•β•β•β•β•β•β–‘β–‘β•šβ•β•β•β•β•β–‘β–‘β–‘β–‘β•šβ•β•β–‘β–‘β–‘β•šβ•β•β•β•β•β•β•""") +β–‘β•šβ•β•β•β•β•β–‘β–‘β•šβ•β•β•β•β•β–‘β•šβ•β•β•β•β•β•β–‘β•šβ•β•β•β•β•β•β•β•šβ•β•β–‘β–‘β•šβ•β•β•šβ•β•β•β•β•β•β–‘β–‘β•šβ•β•β•β•β•β–‘β–‘β–‘β–‘β•šβ•β•β–‘β–‘β–‘β•šβ•β•β•β•β•β•β• + """) self.username = usr_bot_me.username async def stop(self, *args): diff --git a/plugins/admin,py b/plugins/admin,py index 8564eb50c..db9571117 100644 --- a/plugins/admin,py +++ b/plugins/admin,py @@ -3,7 +3,6 @@ -import asyncio from bot import Bot from config import ADMINS from pyrogram import filters, Client From 7f24276d700288fc1a2f81c5911413ec6e8b46a7 Mon Sep 17 00:00:00 2001 From: Shabin-k Date: Sat, 5 Nov 2022 13:37:54 +0530 Subject: [PATCH 11/49] fixed --- plugins/admin,py | 11 ++++--- plugins/start.py | 75 +++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 72 insertions(+), 14 deletions(-) diff --git a/plugins/admin,py b/plugins/admin,py index db9571117..9ff276869 100644 --- a/plugins/admin,py +++ b/plugins/admin,py @@ -1,6 +1,7 @@ #(Β©)CodeXBotz +""" from bot import Bot @@ -15,11 +16,11 @@ from pyrogram.errors import FloodWait, UserIsBlocked, InputUserDeactivated WAIT_MSG = """"Processing ...""" -REPLY_ERROR = """Use this command as a replay to any telegram message with out any spaces.""" +#REPLY_ERROR = """Use this command as a replay to any telegram message with out any spaces.""" #=====================================================================================## - +""" @Bot.on_message(filters.command('users') & filters.private & filters.user(ADMINS)) async def get_users(client: Bot, message: Message): @@ -59,13 +60,13 @@ async def send_text(client: Bot, message: Message): pass total += 1 - status = f"""Broadcast Completed + status = fBroadcast Completed Total Users: {total} Successful: {successful} Blocked Users: {blocked} Deleted Accounts: {deleted} -Unsuccessful: {unsuccessful}""" +Unsuccessful: {unsuccessful} return await pls_wait.edit(status) @@ -73,3 +74,5 @@ Unsuccessful: {unsuccessful}""" msg = await message.reply(REPLY_ERROR) await asyncio.sleep(8) await msg.delete() + +""" \ No newline at end of file diff --git a/plugins/start.py b/plugins/start.py index 27aeee5e9..7d42f163e 100644 --- a/plugins/start.py +++ b/plugins/start.py @@ -1,21 +1,24 @@ #(Β©)CodeXBotz - - - - import os import asyncio -from bot import Bot -from pyrogram.enums import ParseMode from pyrogram import Client, filters, __version__ -from database.database import add_user, present_user -from helper_func import subscribed, encode, decode, get_messages +from pyrogram.enums import ParseMode from pyrogram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton, CallbackQuery -from config import FORCE_MSG, START_MSG, CUSTOM_CAPTION, DISABLE_CHANNEL_BUTTON, PROTECT_CONTENT +from pyrogram.errors import FloodWait, UserIsBlocked, InputUserDeactivated +from bot import Bot +from config import ADMINS, FORCE_MSG, START_MSG, OWNER_ID, CUSTOM_CAPTION, DISABLE_CHANNEL_BUTTON, PROTECT_CONTENT +from helper_func import subscribed, encode, decode, get_messages +from database.database import add_user, del_user, full_userbase, present_user +#=====================================================================================## +WAIT_MSG = """"Processing ...""" + +REPLY_ERROR = """Use this command as a replay to any telegram message with out any spaces.""" + +#=====================================================================================## @Bot.on_message(filters.command('start') & filters.private & subscribed) @@ -139,4 +142,56 @@ async def not_joined(client: Client, message: Message): reply_markup = InlineKeyboardMarkup(buttons), quote = True, disable_web_page_preview = True - ) \ No newline at end of file + ) + +@Bot.on_message(filters.command('users') & filters.private & filters.user(ADMINS)) +async def get_users(client: Bot, message: Message): + msg = await client.send_message(chat_id=message.chat.id, text=WAIT_MSG) + users = await full_userbase() + await msg.edit(f"{len(users)} users are using this bot") + +@Bot.on_message(filters.private & filters.command('broadcast') & filters.user(ADMINS)) +async def send_text(client: Bot, message: Message): + if message.reply_to_message: + query = await full_userbase() + broadcast_msg = message.reply_to_message + total = 0 + successful = 0 + blocked = 0 + deleted = 0 + unsuccessful = 0 + + pls_wait = await message.reply("Broadcasting Message.. This will Take Some Time") + for chat_id in query: + try: + await broadcast_msg.copy(chat_id) + successful += 1 + except FloodWait as e: + await asyncio.sleep(e.x) + await broadcast_msg.copy(chat_id) + successful += 1 + except UserIsBlocked: + await del_user(chat_id) + blocked += 1 + except InputUserDeactivated: + await del_user(chat_id) + deleted += 1 + except: + unsuccessful += 1 + pass + total += 1 + + status = f"""Broadcast Completed + +Total Users: {total} +Successful: {successful} +Blocked Users: {blocked} +Deleted Accounts: {deleted} +Unsuccessful: {unsuccessful}""" + + return await pls_wait.edit(status) + + else: + msg = await message.reply(REPLY_ERROR) + await asyncio.sleep(8) + await msg.delete() From 6c9faacabef7d9bf9e911dd34588d3c66f3f2d02 Mon Sep 17 00:00:00 2001 From: Shabin-k <73272797+SHABIN-K@users.noreply.github.com> Date: Sat, 5 Nov 2022 13:53:30 +0530 Subject: [PATCH 12/49] fixedddddddd --- plugins/start.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/plugins/start.py b/plugins/start.py index 7d42f163e..c0081ec6e 100644 --- a/plugins/start.py +++ b/plugins/start.py @@ -1,4 +1,8 @@ #(Β©)CodeXBotz + + + + import os import asyncio from pyrogram import Client, filters, __version__ @@ -7,18 +11,11 @@ from pyrogram.errors import FloodWait, UserIsBlocked, InputUserDeactivated from bot import Bot -from config import ADMINS, FORCE_MSG, START_MSG, OWNER_ID, CUSTOM_CAPTION, DISABLE_CHANNEL_BUTTON, PROTECT_CONTENT +from config import ADMINS, FORCE_MSG, START_MSG, CUSTOM_CAPTION, DISABLE_CHANNEL_BUTTON, PROTECT_CONTENT from helper_func import subscribed, encode, decode, get_messages from database.database import add_user, del_user, full_userbase, present_user -#=====================================================================================## - -WAIT_MSG = """"Processing ...""" - -REPLY_ERROR = """Use this command as a replay to any telegram message with out any spaces.""" - -#=====================================================================================## @Bot.on_message(filters.command('start') & filters.private & subscribed) @@ -110,6 +107,17 @@ async def start_command(client: Client, message: Message): ) return + +#=====================================================================================## + +WAIT_MSG = """"Processing ...""" + +REPLY_ERROR = """Use this command as a replay to any telegram message with out any spaces.""" + +#=====================================================================================## + + + @Bot.on_message(filters.command('start') & filters.private) async def not_joined(client: Client, message: Message): buttons = [ From 4d2eda1d1e66674fe3d02620b4a8d5f1cba634fc Mon Sep 17 00:00:00 2001 From: Shabin-k <73272797+SHABIN-K@users.noreply.github.com> Date: Sat, 5 Nov 2022 13:53:40 +0530 Subject: [PATCH 13/49] Delete admin,py --- plugins/admin,py | 78 ------------------------------------------------ 1 file changed, 78 deletions(-) delete mode 100644 plugins/admin,py diff --git a/plugins/admin,py b/plugins/admin,py deleted file mode 100644 index 9ff276869..000000000 --- a/plugins/admin,py +++ /dev/null @@ -1,78 +0,0 @@ -#(Β©)CodeXBotz - - -""" - - -from bot import Bot -from config import ADMINS -from pyrogram import filters, Client -from pyrogram.types import Message -from database.database import del_user, full_userbase -from pyrogram.errors import FloodWait, UserIsBlocked, InputUserDeactivated - - -#=====================================================================================## - -WAIT_MSG = """"Processing ...""" - -#REPLY_ERROR = """Use this command as a replay to any telegram message with out any spaces.""" - -#=====================================================================================## - -""" - -@Bot.on_message(filters.command('users') & filters.private & filters.user(ADMINS)) -async def get_users(client: Bot, message: Message): - msg = await client.send_message(chat_id=message.chat.id, text=WAIT_MSG) - users = await full_userbase() - await msg.edit(f"{len(users)} users are using this bot") - - -@Bot.on_message(filters.private & filters.command('broadcast') & filters.user(ADMINS)) -async def send_text(client: Bot, message: Message): - if message.reply_to_message: - query = await full_userbase() - broadcast_msg = message.reply_to_message - total = 0 - successful = 0 - blocked = 0 - deleted = 0 - unsuccessful = 0 - - pls_wait = await message.reply("Broadcasting Message.. This will Take Some Time") - for chat_id in query: - try: - await broadcast_msg.copy(chat_id) - successful += 1 - except FloodWait as e: - await asyncio.sleep(e.x) - await broadcast_msg.copy(chat_id) - successful += 1 - except UserIsBlocked: - await del_user(chat_id) - blocked += 1 - except InputUserDeactivated: - await del_user(chat_id) - deleted += 1 - except: - unsuccessful += 1 - pass - total += 1 - - status = fBroadcast Completed - -Total Users: {total} -Successful: {successful} -Blocked Users: {blocked} -Deleted Accounts: {deleted} -Unsuccessful: {unsuccessful} - - return await pls_wait.edit(status) - - else: - msg = await message.reply(REPLY_ERROR) - await asyncio.sleep(8) - await msg.delete() - -""" \ No newline at end of file From 066cf501261ad4d2d0962f7e4c032655df5d3b3b Mon Sep 17 00:00:00 2001 From: Shabin-k <73272797+SHABIN-K@users.noreply.github.com> Date: Sat, 5 Nov 2022 14:00:09 +0530 Subject: [PATCH 14/49] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 055dc1fc5..b3696df5f 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,8 @@ python3 main.py * `TG_BOT_TOKEN` Your bot token from @BotFather * `OWNER_ID` Must enter Your Telegram Id * `CHANNEL_ID` Your Channel ID eg:- -100xxxxxxxx +* `DATABASE_URL` Your mongo db url +* `DATABASE_NAME` Your mongo db session name * `ADMINS` Optional: A space separated list of user_ids of Admins, they can only create links * `START_MESSAGE` Optional: start message of bot, use HTML and fillings * `FORCE_SUB_MESSAGE`Optional:Force sub message of bot, use HTML and Fillings From a45d37ada4461fa20c019977ae9dcab8f759a186 Mon Sep 17 00:00:00 2001 From: ryme <88014043+rymmee@users.noreply.github.com> Date: Sat, 5 Nov 2022 21:14:32 +0530 Subject: [PATCH 15/49] Update Procfile --- Procfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Procfile b/Procfile index eb131d6eb..469ae068d 100644 --- a/Procfile +++ b/Procfile @@ -1 +1 @@ -worker: python3 main.py +web: python3 main.py From 09acb6458e16c6b70ca8ea98abe23b1fd24d5732 Mon Sep 17 00:00:00 2001 From: ryme <88014043+rymmee@users.noreply.github.com> Date: Sat, 5 Nov 2022 21:16:02 +0530 Subject: [PATCH 16/49] Update requirements.txt --- requirements.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/requirements.txt b/requirements.txt index ea4999579..4b0093d24 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,3 +5,5 @@ Pyromod # --- For-Database ------------ # pymongo dnspython +# --- For-Web-Response ------- # +aiohttp From 66619515488dec78ae25df5433ea8e724a60f370 Mon Sep 17 00:00:00 2001 From: ryme <88014043+rymmee@users.noreply.github.com> Date: Sat, 5 Nov 2022 21:17:51 +0530 Subject: [PATCH 17/49] Update README.md --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index b3696df5f..a228d7ea0 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,12 @@ I Guess This Will Be Usefull For Many People.....πŸ˜‡. #### Deploy on Railway [![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/new/template/1jKLr4) +#### Deploy on Koyeb + +The fastest way to deploy the application is to click the **Deploy to Koyeb** button below. + +[![Deploy to Koyeb](https://www.koyeb.com/static/images/deploy/button.svg)](https://app.koyeb.com/deploy?type=git&repository=github.com/CodeXBotz/File-Sharing-Bot&branch=develop&name=File-Sharing-Bot) + #### Deploy in your VPS ````bash git clone https://github.com/CodeXBotz/File-Sharing-Bot From a9ade89a43633da4da42ceb5d06436ed9069f70b Mon Sep 17 00:00:00 2001 From: ryme <88014043+rymmee@users.noreply.github.com> Date: Sat, 5 Nov 2022 21:19:35 +0530 Subject: [PATCH 18/49] Update config.py --- config.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config.py b/config.py index e01596df7..38f617129 100644 --- a/config.py +++ b/config.py @@ -24,6 +24,9 @@ #OWNER ID OWNER_ID = int(os.environ.get("OWNER_ID", "")) +#Port +PORT = os.environ.get("PORT", "8080") + #Database DB_URI = os.environ.get("DATABASE_URL", "") DB_NAME = os.environ.get("DATABASE_NAME", "filesharexbot") From d1706ec30fa5dc11f4d7cd6726790ba5f26773ef Mon Sep 17 00:00:00 2001 From: ryme <88014043+rymmee@users.noreply.github.com> Date: Sat, 5 Nov 2022 21:22:08 +0530 Subject: [PATCH 19/49] Update bot.py --- bot.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/bot.py b/bot.py index d19402db2..861dc105f 100644 --- a/bot.py +++ b/bot.py @@ -1,12 +1,15 @@ #(Β©)Codexbotz +from aiohttp import web +from web import web_server + import pyromod.listen from pyrogram import Client from pyrogram.enums import ParseMode import sys from datetime import datetime -from config import API_HASH, APP_ID, LOGGER, TG_BOT_TOKEN, TG_BOT_WORKERS, FORCE_SUB_CHANNEL, CHANNEL_ID +from config import API_HASH, APP_ID, LOGGER, TG_BOT_TOKEN, TG_BOT_WORKERS, FORCE_SUB_CHANNEL, CHANNEL_ID, PORT name =""" @@ -73,6 +76,11 @@ async def start(self): β–‘β•šβ•β•β•β•β•β–‘β–‘β•šβ•β•β•β•β•β–‘β•šβ•β•β•β•β•β•β–‘β•šβ•β•β•β•β•β•β•β•šβ•β•β–‘β–‘β•šβ•β•β•šβ•β•β•β•β•β•β–‘β–‘β•šβ•β•β•β•β•β–‘β–‘β–‘β–‘β•šβ•β•β–‘β–‘β–‘β•šβ•β•β•β•β•β•β• """) self.username = usr_bot_me.username + #web-response + app = web.AppRunner(await web_server()) + await app.setup() + bind_address = "0.0.0.0" + await web.TCPSite(app, bind_address, PORT).start() async def stop(self, *args): await super().stop() From 5fb07c9cb49510e54e87ffc46b2a664b8262b7df Mon Sep 17 00:00:00 2001 From: ryme <88014043+rymmee@users.noreply.github.com> Date: Sat, 5 Nov 2022 21:23:34 +0530 Subject: [PATCH 20/49] Create __init__.py --- plugins/__init__.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 plugins/__init__.py diff --git a/plugins/__init__.py b/plugins/__init__.py new file mode 100644 index 000000000..40243c78a --- /dev/null +++ b/plugins/__init__.py @@ -0,0 +1,9 @@ +#@iryme +from aiohttp import web +from .route import routes + + +async def web_server(): + web_app = web.Application(client_max_size=30000000) + web_app.add_routes(routes) + return web_app From 8eaf17fa5f5b7e068313216b27c176a0f40437d3 Mon Sep 17 00:00:00 2001 From: ryme <88014043+rymmee@users.noreply.github.com> Date: Sat, 5 Nov 2022 21:24:42 +0530 Subject: [PATCH 21/49] Create route.py --- plugins/route.py | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 plugins/route.py diff --git a/plugins/route.py b/plugins/route.py new file mode 100644 index 000000000..f67c8668b --- /dev/null +++ b/plugins/route.py @@ -0,0 +1,8 @@ +#rymme +from aiohttp import web + +routes = web.RouteTableDef() + +@routes.get("/", allow_head=True) +async def root_route_handler(request): + return web.json_response("CodeXBotz") From 5e5e20b18ce8203199ae5592c34e6854c9ad0fa5 Mon Sep 17 00:00:00 2001 From: ryme <88014043+rymmee@users.noreply.github.com> Date: Sat, 5 Nov 2022 21:25:26 +0530 Subject: [PATCH 22/49] Update bot.py --- bot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot.py b/bot.py index 861dc105f..47311e99a 100644 --- a/bot.py +++ b/bot.py @@ -1,7 +1,7 @@ #(Β©)Codexbotz from aiohttp import web -from web import web_server +from plugins import web_server import pyromod.listen from pyrogram import Client From 6125f14a9ac2180001644f7f04e3e7f00ab111ab Mon Sep 17 00:00:00 2001 From: Shabin-k <73272797+SHABIN-K@users.noreply.github.com> Date: Sun, 6 Nov 2022 11:37:52 +0530 Subject: [PATCH 23/49] Update README.md --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index b3696df5f..a228d7ea0 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,12 @@ I Guess This Will Be Usefull For Many People.....πŸ˜‡. #### Deploy on Railway [![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/new/template/1jKLr4) +#### Deploy on Koyeb + +The fastest way to deploy the application is to click the **Deploy to Koyeb** button below. + +[![Deploy to Koyeb](https://www.koyeb.com/static/images/deploy/button.svg)](https://app.koyeb.com/deploy?type=git&repository=github.com/CodeXBotz/File-Sharing-Bot&branch=develop&name=File-Sharing-Bot) + #### Deploy in your VPS ````bash git clone https://github.com/CodeXBotz/File-Sharing-Bot From 040d7b61f11c6abd26ae94ecd7939204adb62b72 Mon Sep 17 00:00:00 2001 From: ryme <88014043+rymmee@users.noreply.github.com> Date: Sun, 6 Nov 2022 15:27:19 +0530 Subject: [PATCH 24/49] Update README.md fixed invalid name format --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a228d7ea0..2ad2ab737 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ I Guess This Will Be Usefull For Many People.....πŸ˜‡. The fastest way to deploy the application is to click the **Deploy to Koyeb** button below. -[![Deploy to Koyeb](https://www.koyeb.com/static/images/deploy/button.svg)](https://app.koyeb.com/deploy?type=git&repository=github.com/CodeXBotz/File-Sharing-Bot&branch=develop&name=File-Sharing-Bot) +[![Deploy to Koyeb](https://www.koyeb.com/static/images/deploy/button.svg)](https://app.koyeb.com/deploy?type=git&repository=github.com/CodeXBotz/File-Sharing-Bot&branch=develop&name=filesharingbot) #### Deploy in your VPS ````bash From 736e6e6ea9282d62e785755f598be089ca6c9aa7 Mon Sep 17 00:00:00 2001 From: Shabin-k <73272797+SHABIN-K@users.noreply.github.com> Date: Sun, 6 Nov 2022 18:05:17 +0530 Subject: [PATCH 25/49] Create CONTRIBUTING.md --- CONTRIBUTING.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..3d9201393 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,22 @@ +# Contributing to FILE-SHARING-BOT +We love your input! We want to make contributing to this project as easy and transparent as possible, whether it's: + +- Reporting a bug +- Discussing the current state of the code +- Submitting a fix +- Proposing new features + +## We Develop with Github +We use github to host code, to track issues and feature requests, as well as accept pull requests. + +1. Fork the repo and create your branch from `MAIN`. +2. If you've added code, please test it. +3. Make sure your code works. +4. Issue that pull request! (develop branch) + +## Any contributions you make will be under the GNU General Public License v3.0 +In short, when you submit code changes, your submissions are understood to be under the same [GNU General Public License v3.0](https://github.com/CodeXBotz/File-Sharing-Bot/blob/main/LICENSE) that covers the project. Feel free to contact the maintainers if that's a concern. + +## Report bugs using Github's [issues](https://github.com/CodeXBotz/File-Sharing-Bot/issues) +We use GitHub issues to track public bugs. Report a bug by [opening a new issue](https://github.com/CodeXBotz/File-Sharing-Bot/issues); it's that easy! + From 17dda67baa410f0c6b1a826d14cd9ed41184cca0 Mon Sep 17 00:00:00 2001 From: Shabin-k <73272797+SHABIN-K@users.noreply.github.com> Date: Sun, 6 Nov 2022 20:40:29 +0530 Subject: [PATCH 26/49] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2b7af197a..98491e632 100644 --- a/README.md +++ b/README.md @@ -60,8 +60,8 @@ I Guess This Will Be Usefull For Many People.....πŸ˜‡. The fastest way to deploy the application is to click the **Deploy to Koyeb** button below. -[![Deploy to Koyeb](https://www.koyeb.com/static/images/deploy/button.svg)](https://app.koyeb.com/deploy?type=git&repository=github.com/CodeXBotz/File-Sharing-Bot&branch=develop&name=filesharingbot) ->>>>>>> main +[![Deploy to Koyeb](https://www.koyeb.com/static/images/deploy/button.svg)](https://app.koyeb.com/deploy?type=git&repository=github.com/CodeXBotz/File-Sharing-Bot&branch=main&name=filesharingbot) + #### Deploy in your VPS ````bash From b71fb72e27937cc5969e90b2bcfdda2d9f77a7bf Mon Sep 17 00:00:00 2001 From: Shabin-k <73272797+SHABIN-K@users.noreply.github.com> Date: Sun, 6 Nov 2022 20:56:01 +0530 Subject: [PATCH 27/49] Update README.md --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 98491e632..51b2c4f55 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,11 @@ I Guess This Will Be Usefull For Many People.....πŸ˜‡. ## **If you need any more modes in repo or If you find out any bugs, mention in [@codexbotzsupport ](https://www.telegram.dog/codexbotzsupport)** + +    + + + ### Features - Fully customisable. From b64da4dd7d048109d5bfc193cdf0679cd787a05c Mon Sep 17 00:00:00 2001 From: Shabin-k <73272797+SHABIN-K@users.noreply.github.com> Date: Sun, 6 Nov 2022 21:05:48 +0530 Subject: [PATCH 28/49] Update README.md --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 51b2c4f55..7af85fc6e 100644 --- a/README.md +++ b/README.md @@ -29,9 +29,8 @@ I Guess This Will Be Usefull For Many People.....πŸ˜‡. ## **If you need any more modes in repo or If you find out any bugs, mention in [@codexbotzsupport ](https://www.telegram.dog/codexbotzsupport)** - -    - + +**Make sure to see [contributing.md](https://github.com/CodeXBotz/File-Sharing-Bot/blob/main/CONTRIBUTING.md) for instructions on contributing to the project!** From cefbcb3f99871f5ba1977972fa44567d6a502b24 Mon Sep 17 00:00:00 2001 From: Shabin-k <73272797+SHABIN-K@users.noreply.github.com> Date: Tue, 8 Nov 2022 18:59:39 +0530 Subject: [PATCH 29/49] Update __init__.py --- plugins/__init__.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/__init__.py b/plugins/__init__.py index 40243c78a..7e8e578aa 100644 --- a/plugins/__init__.py +++ b/plugins/__init__.py @@ -1,4 +1,10 @@ +#(Β©)Codexbotz #@iryme + + + + + from aiohttp import web from .route import routes From bd90a551af0a99db3af2f344479a72ab37b050dc Mon Sep 17 00:00:00 2001 From: Shabin-k <73272797+SHABIN-K@users.noreply.github.com> Date: Tue, 8 Nov 2022 19:00:05 +0530 Subject: [PATCH 30/49] Update route.py --- plugins/route.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/route.py b/plugins/route.py index f67c8668b..ce1587fa4 100644 --- a/plugins/route.py +++ b/plugins/route.py @@ -1,4 +1,10 @@ +#(Β©)Codexbotz #rymme + + + + + from aiohttp import web routes = web.RouteTableDef() From 86d9656285d4898f6afa7abdedc322f23dcc10a1 Mon Sep 17 00:00:00 2001 From: IndomieGorengSatu <96320576+IndomieGorengSatu@users.noreply.github.com> Date: Tue, 29 Nov 2022 21:48:09 +0700 Subject: [PATCH 31/49] fix for heroku deployment --- Procfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Procfile b/Procfile index 469ae068d..eb131d6eb 100644 --- a/Procfile +++ b/Procfile @@ -1 +1 @@ -web: python3 main.py +worker: python3 main.py From ebb89d5581ccf0c055d7ef93d762dad97106754b Mon Sep 17 00:00:00 2001 From: Shabin-k <73272797+SHABIN-K@users.noreply.github.com> Date: Wed, 30 Nov 2022 23:18:03 +0530 Subject: [PATCH 32/49] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7af85fc6e..16ef77b1a 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ I Guess This Will Be Usefull For Many People.....πŸ˜‡. The fastest way to deploy the application is to click the **Deploy to Koyeb** button below. -[![Deploy to Koyeb](https://www.koyeb.com/static/images/deploy/button.svg)](https://app.koyeb.com/deploy?type=git&repository=github.com/CodeXBotz/File-Sharing-Bot&branch=main&name=filesharingbot) +[![Deploy to Koyeb](https://www.koyeb.com/static/images/deploy/button.svg)](https://app.koyeb.com/deploy?type=git&repository=github.com/CodeXBotz/File-Sharing-Bot&branch=koyeb&name=filesharingbot) #### Deploy in your VPS From e94c1137b9bddc9ea6f78c9d9dff27226e445f54 Mon Sep 17 00:00:00 2001 From: luna <101097846+lunaticsm@users.noreply.github.com> Date: Sat, 3 Dec 2022 14:36:42 +0700 Subject: [PATCH 33/49] `if` statement can be simplified --- config.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/config.py b/config.py index 38f617129..342c5b65b 100644 --- a/config.py +++ b/config.py @@ -55,10 +55,7 @@ PROTECT_CONTENT = True if os.environ.get('PROTECT_CONTENT', "False") == "True" else False #Set true if you want Disable your Channel Posts Share button -if os.environ.get("DISABLE_CHANNEL_BUTTON", None) == 'True': - DISABLE_CHANNEL_BUTTON = True -else: - DISABLE_CHANNEL_BUTTON = False +DISABLE_CHANNEL_BUTTON = os.environ.get("DISABLE_CHANNEL_BUTTON", None) == 'True' BOT_STATS_TEXT = "BOT UPTIME\n{uptime}" USER_REPLY_TEXT = "❌Don't send me messages directly I'm only File Share bot!" From ed3269a113ac4c38e70daa38b783d634863a6072 Mon Sep 17 00:00:00 2001 From: luna <101097846+lunaticsm@users.noreply.github.com> Date: Sat, 3 Dec 2022 14:38:09 +0700 Subject: [PATCH 34/49] Simplified --- database/database.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/database/database.py b/database/database.py index 7eb1ad905..b178ed2db 100644 --- a/database/database.py +++ b/database/database.py @@ -17,10 +17,7 @@ async def present_user(user_id : int): found = user_data.find_one({'_id': user_id}) - if found: - return True - else: - return False + return bool(found) async def add_user(user_id: int): user_data.insert_one({'_id': user_id}) @@ -36,4 +33,4 @@ async def full_userbase(): async def del_user(user_id: int): user_data.delete_one({'_id': user_id}) - return \ No newline at end of file + return From c434b676b3726723b183a15c9a283007978295a4 Mon Sep 17 00:00:00 2001 From: Rahul <58558341+rahulps1000@users.noreply.github.com> Date: Wed, 18 Jan 2023 01:06:16 +0530 Subject: [PATCH 35/49] Update useless.py --- plugins/useless.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/useless.py b/plugins/useless.py index 6dfc8584b..d3d5558d2 100644 --- a/plugins/useless.py +++ b/plugins/useless.py @@ -13,7 +13,7 @@ async def stats(bot: Bot, message: Message): await message.reply(BOT_STATS_TEXT.format(uptime=time)) -@Bot.on_message(filters.private) +@Bot.on_message(filters.private & filters.incoming) async def useless(_,message: Message): if USER_REPLY_TEXT: await message.reply(USER_REPLY_TEXT) From e6be5eb28b598c465831b4570afa858b9a2c6a52 Mon Sep 17 00:00:00 2001 From: IndomieGorengSatu <96320576+IndomieGorengSatu@users.noreply.github.com> Date: Mon, 23 Jan 2023 07:57:20 +0530 Subject: [PATCH 36/49] fix AttributeError --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 4b0093d24..863b82a65 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ # --- For-Bot-Working --------- # pyrogram TgCrypto -Pyromod +pyromod==1.5 # --- For-Database ------------ # pymongo dnspython From aedd0881eef33b0d3df9c2c3f6dc55c73420364f Mon Sep 17 00:00:00 2001 From: Shabin-k <73272797+SHABIN-K@users.noreply.github.com> Date: Sat, 4 Feb 2023 15:02:13 +0530 Subject: [PATCH 37/49] Update bot.py --- bot.py | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/bot.py b/bot.py index 47311e99a..6bbf94094 100644 --- a/bot.py +++ b/bot.py @@ -11,17 +11,6 @@ from config import API_HASH, APP_ID, LOGGER, TG_BOT_TOKEN, TG_BOT_WORKERS, FORCE_SUB_CHANNEL, CHANNEL_ID, PORT - -name =""" -β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•—β–‘β–‘β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— -β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β•β•β•β•šβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β•šβ•β•β–ˆβ–ˆβ•”β•β•β•β•šβ•β•β•β•β–ˆβ–ˆβ•‘ -β–ˆβ–ˆβ•‘β–‘β–‘β•šβ•β•β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–‘β–‘β•šβ–ˆβ–ˆβ–ˆβ•”β•β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•¦β•β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–‘β–‘β–ˆβ–ˆβ–ˆβ•”β•β• -β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•β–‘β–‘β–‘β–ˆβ–ˆβ•”β–ˆβ–ˆβ•—β–‘β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–ˆβ–ˆβ•”β•β•β•β–‘β–‘ -β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•šβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•¦β•β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–‘β–‘β–‘β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— -β–‘β•šβ•β•β•β•β•β–‘β–‘β•šβ•β•β•β•β•β–‘β•šβ•β•β•β•β•β•β–‘β•šβ•β•β•β•β•β•β•β•šβ•β•β–‘β–‘β•šβ•β•β•šβ•β•β•β•β•β•β–‘β–‘β•šβ•β•β•β•β•β–‘β–‘β–‘β–‘β•šβ•β•β–‘β–‘β–‘β•šβ•β•β•β•β•β•β• -""" - - class Bot(Client): def __init__(self): super().__init__( From 6a08b1301808aaad365bb79aebda0315e12dcf7c Mon Sep 17 00:00:00 2001 From: IndomieGorengSatu <96320576+IndomieGorengSatu@users.noreply.github.com> Date: Mon, 6 Feb 2023 15:26:40 +0530 Subject: [PATCH 38/49] change to "eco" for heroku deployment --- app.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.json b/app.json index 7e8cd5e04..81bb28135 100644 --- a/app.json +++ b/app.json @@ -68,7 +68,7 @@ "formation": { "worker": { "quantity": 1, - "size": "free" + "size": "eco" } } } From 870dd0f42260610784ec7e9d12674b4929e21e0f Mon Sep 17 00:00:00 2001 From: POV <101882690+Friscay@users.noreply.github.com> Date: Fri, 19 Jan 2024 13:31:33 +0700 Subject: [PATCH 39/49] change sleep value due to new pyro * Change sleep value due to new pyro * Adding more anti floodwait --- plugins/channel_post.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/plugins/channel_post.py b/plugins/channel_post.py index 3e3df090e..3516ffe9e 100644 --- a/plugins/channel_post.py +++ b/plugins/channel_post.py @@ -15,7 +15,7 @@ async def channel_post(client: Client, message: Message): try: post_message = await message.copy(chat_id = client.db_channel.id, disable_notification=True) except FloodWait as e: - await asyncio.sleep(e.x) + await asyncio.sleep(e.value) post_message = await message.copy(chat_id = client.db_channel.id, disable_notification=True) except Exception as e: print(e) @@ -31,7 +31,13 @@ async def channel_post(client: Client, message: Message): await reply_text.edit(f"Here is your link\n\n{link}", reply_markup=reply_markup, disable_web_page_preview = True) if not DISABLE_CHANNEL_BUTTON: - await post_message.edit_reply_markup(reply_markup) + try: + await post_message.edit_reply_markup(reply_markup) + except FloodWait as e: + await asyncio.sleep(e.value) + await post_message.edit_reply_markup(reply_markup) + except Exception: + pass @Bot.on_message(filters.channel & filters.incoming & filters.chat(CHANNEL_ID)) async def new_post(client: Client, message: Message): @@ -46,6 +52,8 @@ async def new_post(client: Client, message: Message): reply_markup = InlineKeyboardMarkup([[InlineKeyboardButton("πŸ” Share URL", url=f'https://telegram.me/share/url?url={link}')]]) try: await message.edit_reply_markup(reply_markup) - except Exception as e: - print(e) + except FloodWait as e: + await asyncio.sleep(e.value) + await message.edit_reply_markup(reply_markup) + except Exception: pass From 3aba75476c4ea4787835ddfe0a107dfebd8b855f Mon Sep 17 00:00:00 2001 From: Shabin-k Date: Sat, 16 Nov 2024 21:48:21 +0530 Subject: [PATCH 40/49] feat : add feature details --- .gitignore | 2 +- README.md | 1 + app.json | 4 ++++ config.py | 8 +++----- plugins/start.py | 45 +++++++++++++++++++++++++++------------------ 5 files changed, 36 insertions(+), 24 deletions(-) diff --git a/.gitignore b/.gitignore index 7e86cf0c5..8608bdbeb 100644 --- a/.gitignore +++ b/.gitignore @@ -137,4 +137,4 @@ dmypy.json # Cython debug symbols cython_debug/ - +.idea diff --git a/README.md b/README.md index 16ef77b1a..7dc74ab48 100644 --- a/README.md +++ b/README.md @@ -103,6 +103,7 @@ python3 main.py * `DATABASE_NAME` Your mongo db session name * `ADMINS` Optional: A space separated list of user_ids of Admins, they can only create links * `START_MESSAGE` Optional: start message of bot, use HTML and fillings +* `START_PIC` Optional: URL or file path of the image to be sent as the start message * `FORCE_SUB_MESSAGE`Optional:Force sub message of bot, use HTML and Fillings * `FORCE_SUB_CHANNEL` Optional: ForceSub Channel ID, leave 0 if you want disable force sub * `PROTECT_CONTENT` Optional: True if you need to prevent files from forwarding diff --git a/app.json b/app.json index 81bb28135..042e48ecc 100644 --- a/app.json +++ b/app.json @@ -45,6 +45,10 @@ "description": "Optional: start message of bot, use HTML parsemode format", "value": "Hello {first}\n\nI can store private files in Specified Channel and other users can access it from special link." }, + "START_PIC": { + "description": "Optional: URL or file path of the image to be sent as the start message,", + "value": " " + }, "FORCE_SUB_MESSAGE": { "description": "Optional: Force Sub message of bot, use HTML parsemode format", "value": "Hello {first}\n\nYou need to join in my Channel/Group to use me\n\nKindly Please join Channel" diff --git a/config.py b/config.py index 342c5b65b..ed0ec022f 100644 --- a/config.py +++ b/config.py @@ -1,13 +1,11 @@ #(Β©)CodeXBotz - - - import os import logging +from dotenv import load_dotenv from logging.handlers import RotatingFileHandler - +load_dotenv() #Bot token @Botfather TG_BOT_TOKEN = os.environ.get("TG_BOT_TOKEN", "") @@ -37,6 +35,7 @@ TG_BOT_WORKERS = int(os.environ.get("TG_BOT_WORKERS", "4")) #start message +START_PIC = os.environ.get("START_PIC","") START_MSG = os.environ.get("START_MESSAGE", "Hello {first}\n\nI can store private files in Specified Channel and other users can access it from special link.") try: ADMINS=[] @@ -80,6 +79,5 @@ ) logging.getLogger("pyrogram").setLevel(logging.WARNING) - def LOGGER(name: str) -> logging.Logger: return logging.getLogger(name) diff --git a/plugins/start.py b/plugins/start.py index c0081ec6e..737d96b45 100644 --- a/plugins/start.py +++ b/plugins/start.py @@ -1,8 +1,5 @@ #(Β©)CodeXBotz - - - import os import asyncio from pyrogram import Client, filters, __version__ @@ -11,13 +8,11 @@ from pyrogram.errors import FloodWait, UserIsBlocked, InputUserDeactivated from bot import Bot -from config import ADMINS, FORCE_MSG, START_MSG, CUSTOM_CAPTION, DISABLE_CHANNEL_BUTTON, PROTECT_CONTENT +from config import ADMINS, FORCE_MSG, START_MSG, CUSTOM_CAPTION, DISABLE_CHANNEL_BUTTON, PROTECT_CONTENT, START_PIC from helper_func import subscribed, encode, decode, get_messages from database.database import add_user, del_user, full_userbase, present_user - - @Bot.on_message(filters.command('start') & filters.private & subscribed) async def start_command(client: Client, message: Message): id = message.from_user.id @@ -93,18 +88,32 @@ async def start_command(client: Client, message: Message): ] ] ) - await message.reply_text( - text = START_MSG.format( - first = message.from_user.first_name, - last = message.from_user.last_name, - username = None if not message.from_user.username else '@' + message.from_user.username, - mention = message.from_user.mention, - id = message.from_user.id - ), - reply_markup = reply_markup, - disable_web_page_preview = True, - quote = True - ) + if START_PIC: # Check if START_PIC has a value + await message.reply_photo( + photo=START_PIC, + caption=START_MSG.format( + first=message.from_user.first_name, + last=message.from_user.last_name, + username=None if not message.from_user.username else '@' + message.from_user.username, + mention=message.from_user.mention, + id=message.from_user.id + ), + reply_markup=reply_markup, # Optional inline buttons or keyboard + quote=True + ) + else: # If START_PIC is empty, send only the text + await message.reply_text( + text=START_MSG.format( + first=message.from_user.first_name, + last=message.from_user.last_name, + username=None if not message.from_user.username else '@' + message.from_user.username, + mention=message.from_user.mention, + id=message.from_user.id + ), + reply_markup=reply_markup, + disable_web_page_preview=True, + quote=True + ) return From dbf16185cc1ba2ee93052c018eea539601238ad7 Mon Sep 17 00:00:00 2001 From: Shabin-k Date: Sun, 17 Nov 2024 00:24:23 +0530 Subject: [PATCH 41/49] feat : add auto deletion --- README.md | 5 ++++- app.json | 12 +++++++++++ config.py | 5 +++++ database/database.py | 8 ------- helper_func.py | 13 ++++++++++-- plugins/__init__.py | 5 ----- plugins/cbb.py | 2 +- plugins/route.py | 4 ---- plugins/start.py | 50 +++++++++++++++++++++++++++++++------------- plugins/useless.py | 1 - 10 files changed, 68 insertions(+), 37 deletions(-) diff --git a/README.md b/README.md index 7dc74ab48..a6bf06b67 100644 --- a/README.md +++ b/README.md @@ -100,20 +100,23 @@ python3 main.py * `OWNER_ID` Must enter Your Telegram Id * `CHANNEL_ID` Your Channel ID eg:- -100xxxxxxxx * `DATABASE_URL` Your mongo db url -* `DATABASE_NAME` Your mongo db session name * `ADMINS` Optional: A space separated list of user_ids of Admins, they can only create links * `START_MESSAGE` Optional: start message of bot, use HTML and fillings * `START_PIC` Optional: URL or file path of the image to be sent as the start message * `FORCE_SUB_MESSAGE`Optional:Force sub message of bot, use HTML and Fillings * `FORCE_SUB_CHANNEL` Optional: ForceSub Channel ID, leave 0 if you want disable force sub * `PROTECT_CONTENT` Optional: True if you need to prevent files from forwarding +* `AUTO_DELETE_TIME ` Set the time in seconds for automatic file deletion. Default is False, which disables auto-deletion. ### Extra Variables +* `AUTO_DELETE_MSG` put your custom deletion text if you want Setup Custom deletion messaeg, +* `AUTO_DEL_SUCCESS_MSG` Set your custom success message for when the file is successfully deleted * `CUSTOM_CAPTION` put your Custom caption text if you want Setup Custom Caption, you can use HTML and fillings for formatting (only for documents) * `DISABLE_CHANNEL_BUTTON` Put True to Disable Channel Share Button, Default if False * `BOT_STATS_TEXT` put your custom text for stats command, use HTML and fillings * `USER_REPLY_TEXT` put your text to show when user sends any message, use HTML +* `DATABASE_NAME` Your mongo db session name ### Fillings diff --git a/app.json b/app.json index 042e48ecc..150704875 100644 --- a/app.json +++ b/app.json @@ -62,6 +62,18 @@ "description": "Protect contents from getting forwarded", "value": "False", "required": false + }, + "AUTO_DELETE_TIME": { + "description": "Set the time in seconds for the automatic deletion of the file. Default is 0, meaning auto-deletion is disabled unless specified.", + "value": "0" + }, + "AUTO_DELETE_MSG": { + "description": "The custom message shown to the user before the file is automatically deleted. You can include a countdown with {time}.", + "value": "This file will be automatically deleted in {time} seconds. Please ensure you have saved any necessary content before this time." + }, + "AUTO_DEL_SUCCESS_MSG": { + "description": "The custom message shown to the user once the file is successfully deleted.", + "value": "Your file has been successfully deleted. Thank you for using our service. βœ…" } }, "buildpacks": [ diff --git a/config.py b/config.py index ed0ec022f..dab8b5683 100644 --- a/config.py +++ b/config.py @@ -53,6 +53,11 @@ #set True if you want to prevent users from forwarding files from bot PROTECT_CONTENT = True if os.environ.get('PROTECT_CONTENT', "False") == "True" else False +# Auto delete time in seconds. +AUTO_DELETE_TIME = int(os.getenv("AUTO_DELETE_TIME", "0")) +AUTO_DELETE_MSG = os.environ.get("AUTO_DELETE_MSG", "This file will be automatically deleted in {time} seconds. Please ensure you have saved any necessary content before this time.") +AUTO_DEL_SUCCESS_MSG = os.environ.get("AUTO_DEL_SUCCESS_MSG", "Your file has been successfully deleted. Thank you for using our service. βœ…") + #Set true if you want Disable your Channel Posts Share button DISABLE_CHANNEL_BUTTON = os.environ.get("DISABLE_CHANNEL_BUTTON", None) == 'True' diff --git a/database/database.py b/database/database.py index b178ed2db..3edc7d316 100644 --- a/database/database.py +++ b/database/database.py @@ -1,20 +1,12 @@ #(Β©)CodeXBotz - - - import pymongo, os from config import DB_URI, DB_NAME - dbclient = pymongo.MongoClient(DB_URI) database = dbclient[DB_NAME] - - user_data = database['users'] - - async def present_user(user_id : int): found = user_data.find_one({'_id': user_id}) return bool(found) diff --git a/helper_func.py b/helper_func.py index 05ff901ba..a61f9047b 100644 --- a/helper_func.py +++ b/helper_func.py @@ -5,7 +5,7 @@ import asyncio from pyrogram import filters from pyrogram.enums import ChatMemberStatus -from config import FORCE_SUB_CHANNEL, ADMINS +from config import FORCE_SUB_CHANNEL, ADMINS, AUTO_DELETE_TIME, AUTO_DEL_SUCCESS_MSG from pyrogram.errors.exceptions.bad_request_400 import UserNotParticipant from pyrogram.errors import FloodWait @@ -84,7 +84,6 @@ async def get_message_id(client, message): else: return 0 - def get_readable_time(seconds: int) -> str: count = 0 up_time = "" @@ -106,5 +105,15 @@ def get_readable_time(seconds: int) -> str: up_time += ":".join(time_list) return up_time +async def delete_file(message, client, process): + await asyncio.sleep(AUTO_DELETE_TIME) + for msg in message: + try: + await client.delete_messages(chat_id=msg.chat.id, message_ids=[msg.id]) + except Exception as e: + await asyncio.sleep(e.x) + + await process.edit_text(AUTO_DEL_SUCCESS_MSG) + subscribed = filters.create(is_subscribed) diff --git a/plugins/__init__.py b/plugins/__init__.py index 7e8e578aa..7e85b9e37 100644 --- a/plugins/__init__.py +++ b/plugins/__init__.py @@ -1,14 +1,9 @@ #(Β©)Codexbotz #@iryme - - - - from aiohttp import web from .route import routes - async def web_server(): web_app = web.Application(client_max_size=30000000) web_app.add_routes(routes) diff --git a/plugins/cbb.py b/plugins/cbb.py index 4003ee01a..29d8de465 100644 --- a/plugins/cbb.py +++ b/plugins/cbb.py @@ -3,7 +3,7 @@ from pyrogram import __version__ from bot import Bot from config import OWNER_ID -from pyrogram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton, CallbackQuery +from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, CallbackQuery @Bot.on_callback_query() async def cb_handler(client: Bot, query: CallbackQuery): diff --git a/plugins/route.py b/plugins/route.py index ce1587fa4..12d6b49e3 100644 --- a/plugins/route.py +++ b/plugins/route.py @@ -1,10 +1,6 @@ #(Β©)Codexbotz #rymme - - - - from aiohttp import web routes = web.RouteTableDef() diff --git a/plugins/start.py b/plugins/start.py index 737d96b45..2c72abf5e 100644 --- a/plugins/start.py +++ b/plugins/start.py @@ -2,14 +2,14 @@ import os import asyncio -from pyrogram import Client, filters, __version__ +from pyrogram import Client, filters from pyrogram.enums import ParseMode -from pyrogram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton, CallbackQuery +from pyrogram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton from pyrogram.errors import FloodWait, UserIsBlocked, InputUserDeactivated from bot import Bot -from config import ADMINS, FORCE_MSG, START_MSG, CUSTOM_CAPTION, DISABLE_CHANNEL_BUTTON, PROTECT_CONTENT, START_PIC -from helper_func import subscribed, encode, decode, get_messages +from config import ADMINS, FORCE_MSG, START_MSG, CUSTOM_CAPTION, DISABLE_CHANNEL_BUTTON, PROTECT_CONTENT, START_PIC, AUTO_DELETE_TIME, AUTO_DELETE_MSG +from helper_func import subscribed,decode, get_messages, delete_file from database.database import add_user, del_user, full_userbase, present_user @@ -70,14 +70,34 @@ async def start_command(client: Client, message: Message): else: reply_markup = None - try: - await msg.copy(chat_id=message.from_user.id, caption = caption, parse_mode = ParseMode.HTML, reply_markup = reply_markup, protect_content=PROTECT_CONTENT) - await asyncio.sleep(0.5) - except FloodWait as e: - await asyncio.sleep(e.x) - await msg.copy(chat_id=message.from_user.id, caption = caption, parse_mode = ParseMode.HTML, reply_markup = reply_markup, protect_content=PROTECT_CONTENT) - except: - pass + if AUTO_DELETE_TIME: + track_msgs = [] + + try: + copied_msg_for_deletion = await msg.copy(chat_id=message.from_user.id, caption=caption, parse_mode=ParseMode.HTML, reply_markup=reply_markup, protect_content=PROTECT_CONTENT) + track_msgs.append(copied_msg_for_deletion) + + except FloodWait as e: + await asyncio.sleep(e.x) + copied_msg_for_deletion = await msg.copy(chat_id=message.from_user.id, caption=caption, parse_mode=ParseMode.HTML, reply_markup=reply_markup, protect_content=PROTECT_CONTENT) + track_msgs.append(copied_msg_for_deletion) + + except: + pass + + delete_data = await client.send_message(chat_id=message.from_user.id,text=AUTO_DELETE_MSG.format(time=AUTO_DELETE_TIME)) + # Schedule the file deletion + asyncio.create_task(delete_file(track_msgs, client, delete_data)) + + else: + try: + await msg.copy(chat_id=message.from_user.id, caption=caption, parse_mode=ParseMode.HTML, reply_markup=reply_markup, protect_content=PROTECT_CONTENT) + await asyncio.sleep(0.5) + except FloodWait as e: + await asyncio.sleep(e.x) + await msg.copy(chat_id=message.from_user.id, caption=caption, parse_mode=ParseMode.HTML, reply_markup=reply_markup, protect_content=PROTECT_CONTENT) + except: + pass return else: reply_markup = InlineKeyboardMarkup( @@ -98,7 +118,7 @@ async def start_command(client: Client, message: Message): mention=message.from_user.mention, id=message.from_user.id ), - reply_markup=reply_markup, # Optional inline buttons or keyboard + reply_markup=reply_markup, quote=True ) else: # If START_PIC is empty, send only the text @@ -125,8 +145,7 @@ async def start_command(client: Client, message: Message): #=====================================================================================## - - + @Bot.on_message(filters.command('start') & filters.private) async def not_joined(client: Client, message: Message): buttons = [ @@ -212,3 +231,4 @@ async def send_text(client: Bot, message: Message): msg = await message.reply(REPLY_ERROR) await asyncio.sleep(8) await msg.delete() + diff --git a/plugins/useless.py b/plugins/useless.py index d3d5558d2..f9b597b0b 100644 --- a/plugins/useless.py +++ b/plugins/useless.py @@ -12,7 +12,6 @@ async def stats(bot: Bot, message: Message): time = get_readable_time(delta.seconds) await message.reply(BOT_STATS_TEXT.format(uptime=time)) - @Bot.on_message(filters.private & filters.incoming) async def useless(_,message: Message): if USER_REPLY_TEXT: From b7a4400bbfaec275a3e62e0ac07b190f256b1f9e Mon Sep 17 00:00:00 2001 From: Shabin-k Date: Sun, 17 Nov 2024 00:58:17 +0530 Subject: [PATCH 42/49] feat : add logo --- bot.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/bot.py b/bot.py index 6bbf94094..59f3ef861 100644 --- a/bot.py +++ b/bot.py @@ -3,7 +3,6 @@ from aiohttp import web from plugins import web_server -import pyromod.listen from pyrogram import Client from pyrogram.enums import ParseMode import sys @@ -11,6 +10,16 @@ from config import API_HASH, APP_ID, LOGGER, TG_BOT_TOKEN, TG_BOT_WORKERS, FORCE_SUB_CHANNEL, CHANNEL_ID, PORT + +ascii_art = """ +β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•—β–‘β–‘β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— +β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β•β•β•β•šβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β•šβ•β•β–ˆβ–ˆβ•”β•β•β•β•šβ•β•β•β•β–ˆβ–ˆβ•‘ +β–ˆβ–ˆβ•‘β–‘β–‘β•šβ•β•β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–‘β–‘β•šβ–ˆβ–ˆβ–ˆβ•”β•β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•¦β•β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–‘β–‘β–ˆβ–ˆβ–ˆβ•”β•β• +β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•β–‘β–‘β–‘β–ˆβ–ˆβ•”β–ˆβ–ˆβ•—β–‘β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–ˆβ–ˆβ•”β•β•β•β–‘β–‘ +β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•šβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•¦β•β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–‘β–‘β–‘β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— +β–‘β•šβ•β•β•β•β•β–‘β–‘β•šβ•β•β•β•β•β–‘β•šβ•β•β•β•β•β•β–‘β•šβ•β•β•β•β•β•β•β•šβ•β•β–‘β–‘β•šβ•β•β•šβ•β•β•β•β•β•β–‘β–‘β•šβ•β•β•β•β•β–‘β–‘β–‘β–‘β•šβ•β•β–‘β–‘β–‘β•šβ•β•β•β•β•β•β• +""" + class Bot(Client): def __init__(self): super().__init__( @@ -56,14 +65,8 @@ async def start(self): self.set_parse_mode(ParseMode.HTML) self.LOGGER(__name__).info(f"Bot Running..!\n\nCreated by \nhttps://t.me/CodeXBotz") - self.LOGGER(__name__).info(f""" \n\n -β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•—β–‘β–‘β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— -β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β•β•β•β•šβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β•šβ•β•β–ˆβ–ˆβ•”β•β•β•β•šβ•β•β•β•β–ˆβ–ˆβ•‘ -β–ˆβ–ˆβ•‘β–‘β–‘β•šβ•β•β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–‘β–‘β•šβ–ˆβ–ˆβ–ˆβ•”β•β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•¦β•β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–‘β–‘β–ˆβ–ˆβ–ˆβ•”β•β• -β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•β–‘β–‘β–‘β–ˆβ–ˆβ•”β–ˆβ–ˆβ•—β–‘β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–ˆβ–ˆβ•”β•β•β•β–‘β–‘ -β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•šβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•¦β•β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–‘β–‘β–‘β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— -β–‘β•šβ•β•β•β•β•β–‘β–‘β•šβ•β•β•β•β•β–‘β•šβ•β•β•β•β•β•β–‘β•šβ•β•β•β•β•β•β•β•šβ•β•β–‘β–‘β•šβ•β•β•šβ•β•β•β•β•β•β–‘β–‘β•šβ•β•β•β•β•β–‘β–‘β–‘β–‘β•šβ•β•β–‘β–‘β–‘β•šβ•β•β•β•β•β•β• - """) + print(ascii_art) + print("""Welcome to CodeXBotz File Sharing Bot""") self.username = usr_bot_me.username #web-response app = web.AppRunner(await web_server()) From 5279cef2c88472d7a4dc64a389f9cb385762e02b Mon Sep 17 00:00:00 2001 From: "knmuhammed2@gmail.com" Date: Sun, 17 Nov 2024 01:56:15 +0530 Subject: [PATCH 43/49] Add 'APscheduler' for none asynchronous auto delete (better than asyncio.sleep()) --- helper_func.py | 20 +++++++++++++++++--- plugins/start.py | 6 +++--- requirements.txt | 2 ++ 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/helper_func.py b/helper_func.py index a61f9047b..a1979747a 100644 --- a/helper_func.py +++ b/helper_func.py @@ -3,11 +3,23 @@ import base64 import re import asyncio +import logging from pyrogram import filters from pyrogram.enums import ChatMemberStatus from config import FORCE_SUB_CHANNEL, ADMINS, AUTO_DELETE_TIME, AUTO_DEL_SUCCESS_MSG from pyrogram.errors.exceptions.bad_request_400 import UserNotParticipant from pyrogram.errors import FloodWait +from datetime import datetime, timedelta +from apscheduler.schedulers.background import BackgroundScheduler + +# Disable apscheduler logging +apscheduler_logger = logging.getLogger('apscheduler') +apscheduler_logger.addHandler(logging.NullHandler()) +apscheduler_logger.propagate = False + +# Initialize background scheduler +scheduler = BackgroundScheduler() + async def is_subscribed(filter, client, update): if not FORCE_SUB_CHANNEL: @@ -106,14 +118,16 @@ def get_readable_time(seconds: int) -> str: return up_time async def delete_file(message, client, process): - await asyncio.sleep(AUTO_DELETE_TIME) for msg in message: try: - await client.delete_messages(chat_id=msg.chat.id, message_ids=[msg.id]) + scheduler.add_job(msg.delete, 'date', run_date=datetime.now() + timedelta(seconds=AUTO_DELETE_TIME)) except Exception as e: - await asyncio.sleep(e.x) + await asyncio.sleep(e.value) await process.edit_text(AUTO_DEL_SUCCESS_MSG) subscribed = filters.create(is_subscribed) + +# start scheduler +scheduler.start() diff --git a/plugins/start.py b/plugins/start.py index 2c72abf5e..4b6459844 100644 --- a/plugins/start.py +++ b/plugins/start.py @@ -70,7 +70,7 @@ async def start_command(client: Client, message: Message): else: reply_markup = None - if AUTO_DELETE_TIME: + if AUTO_DELETE_TIME and AUTO_DELETE_TIME > 0: track_msgs = [] try: @@ -78,7 +78,7 @@ async def start_command(client: Client, message: Message): track_msgs.append(copied_msg_for_deletion) except FloodWait as e: - await asyncio.sleep(e.x) + await asyncio.sleep(e.value) copied_msg_for_deletion = await msg.copy(chat_id=message.from_user.id, caption=caption, parse_mode=ParseMode.HTML, reply_markup=reply_markup, protect_content=PROTECT_CONTENT) track_msgs.append(copied_msg_for_deletion) @@ -94,7 +94,7 @@ async def start_command(client: Client, message: Message): await msg.copy(chat_id=message.from_user.id, caption=caption, parse_mode=ParseMode.HTML, reply_markup=reply_markup, protect_content=PROTECT_CONTENT) await asyncio.sleep(0.5) except FloodWait as e: - await asyncio.sleep(e.x) + await asyncio.sleep(e.value) await msg.copy(chat_id=message.from_user.id, caption=caption, parse_mode=ParseMode.HTML, reply_markup=reply_markup, protect_content=PROTECT_CONTENT) except: pass diff --git a/requirements.txt b/requirements.txt index 863b82a65..0edfcbb81 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,3 +7,5 @@ pymongo dnspython # --- For-Web-Response ------- # aiohttp +# --- For-None-Asynchronous-Auto-Delete-----# +apscheduler From 45d873ff5cf2d4f68849bafe5e21a2f39a489d31 Mon Sep 17 00:00:00 2001 From: Shabin-k Date: Sun, 17 Nov 2024 12:46:38 +0530 Subject: [PATCH 44/49] fix : build error --- .gitignore | 2 ++ requirements.txt | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 8608bdbeb..8ce1b47ea 100644 --- a/.gitignore +++ b/.gitignore @@ -138,3 +138,5 @@ dmypy.json # Cython debug symbols cython_debug/ .idea +Bot.session +filesharingbot.txt \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 0edfcbb81..3a8284d0a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,10 +2,11 @@ pyrogram TgCrypto pyromod==1.5 +python-dotenv # --- For-Database ------------ # pymongo dnspython # --- For-Web-Response ------- # aiohttp # --- For-None-Asynchronous-Auto-Delete-----# -apscheduler +apscheduler \ No newline at end of file From 785c7cef93ec657d820f989e88068f7a8360aab7 Mon Sep 17 00:00:00 2001 From: Shabin-k Date: Wed, 20 Nov 2024 14:13:28 +0530 Subject: [PATCH 45/49] fix : pyromod issue --- .gitignore | 3 ++- bot.py | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 8ce1b47ea..e043008db 100644 --- a/.gitignore +++ b/.gitignore @@ -139,4 +139,5 @@ dmypy.json cython_debug/ .idea Bot.session -filesharingbot.txt \ No newline at end of file +filesharingbot.txt +Bot.session-journal \ No newline at end of file diff --git a/bot.py b/bot.py index 59f3ef861..0956e9f5f 100644 --- a/bot.py +++ b/bot.py @@ -3,6 +3,7 @@ from aiohttp import web from plugins import web_server +import pyromod.listen from pyrogram import Client from pyrogram.enums import ParseMode import sys From a8589dd919b4df4d6ae5c0a5a8388b7b1f7bcd06 Mon Sep 17 00:00:00 2001 From: Shabin-k Date: Wed, 20 Nov 2024 16:45:22 +0530 Subject: [PATCH 46/49] fix : auto deleteion error --- helper_func.py | 24 ++++++------------------ plugins/start.py | 31 +++++++++++++++++++++++-------- requirements.txt | 2 -- 3 files changed, 29 insertions(+), 28 deletions(-) diff --git a/helper_func.py b/helper_func.py index a1979747a..5ce68562c 100644 --- a/helper_func.py +++ b/helper_func.py @@ -9,17 +9,6 @@ from config import FORCE_SUB_CHANNEL, ADMINS, AUTO_DELETE_TIME, AUTO_DEL_SUCCESS_MSG from pyrogram.errors.exceptions.bad_request_400 import UserNotParticipant from pyrogram.errors import FloodWait -from datetime import datetime, timedelta -from apscheduler.schedulers.background import BackgroundScheduler - -# Disable apscheduler logging -apscheduler_logger = logging.getLogger('apscheduler') -apscheduler_logger.addHandler(logging.NullHandler()) -apscheduler_logger.propagate = False - -# Initialize background scheduler -scheduler = BackgroundScheduler() - async def is_subscribed(filter, client, update): if not FORCE_SUB_CHANNEL: @@ -117,17 +106,16 @@ def get_readable_time(seconds: int) -> str: up_time += ":".join(time_list) return up_time -async def delete_file(message, client, process): - for msg in message: +async def delete_file(messages, client, process): + await asyncio.sleep(AUTO_DELETE_TIME) + for msg in messages: try: - scheduler.add_job(msg.delete, 'date', run_date=datetime.now() + timedelta(seconds=AUTO_DELETE_TIME)) + await client.delete_messages(chat_id=msg.chat.id, message_ids=[msg.id]) except Exception as e: - await asyncio.sleep(e.value) + await asyncio.sleep(e.x) + print(f"The attempt to delete the media {msg.id} was unsuccessful: {e}") await process.edit_text(AUTO_DEL_SUCCESS_MSG) subscribed = filters.create(is_subscribed) - -# start scheduler -scheduler.start() diff --git a/plugins/start.py b/plugins/start.py index 4b6459844..b611c7d29 100644 --- a/plugins/start.py +++ b/plugins/start.py @@ -58,6 +58,8 @@ async def start_command(client: Client, message: Message): return await temp_msg.delete() + track_msgs = [] + for msg in messages: if bool(CUSTOM_CAPTION) & bool(msg.document): @@ -71,24 +73,26 @@ async def start_command(client: Client, message: Message): reply_markup = None if AUTO_DELETE_TIME and AUTO_DELETE_TIME > 0: - track_msgs = [] try: copied_msg_for_deletion = await msg.copy(chat_id=message.from_user.id, caption=caption, parse_mode=ParseMode.HTML, reply_markup=reply_markup, protect_content=PROTECT_CONTENT) - track_msgs.append(copied_msg_for_deletion) + if copied_msg_for_deletion: + track_msgs.append(copied_msg_for_deletion) + else: + print("Failed to copy message, skipping.") except FloodWait as e: await asyncio.sleep(e.value) copied_msg_for_deletion = await msg.copy(chat_id=message.from_user.id, caption=caption, parse_mode=ParseMode.HTML, reply_markup=reply_markup, protect_content=PROTECT_CONTENT) - track_msgs.append(copied_msg_for_deletion) + if copied_msg_for_deletion: + track_msgs.append(copied_msg_for_deletion) + else: + print("Failed to copy message after retry, skipping.") - except: + except Exception as e: + print(f"Error copying message: {e}") pass - delete_data = await client.send_message(chat_id=message.from_user.id,text=AUTO_DELETE_MSG.format(time=AUTO_DELETE_TIME)) - # Schedule the file deletion - asyncio.create_task(delete_file(track_msgs, client, delete_data)) - else: try: await msg.copy(chat_id=message.from_user.id, caption=caption, parse_mode=ParseMode.HTML, reply_markup=reply_markup, protect_content=PROTECT_CONTENT) @@ -98,6 +102,17 @@ async def start_command(client: Client, message: Message): await msg.copy(chat_id=message.from_user.id, caption=caption, parse_mode=ParseMode.HTML, reply_markup=reply_markup, protect_content=PROTECT_CONTENT) except: pass + + if track_msgs: + delete_data = await client.send_message( + chat_id=message.from_user.id, + text=AUTO_DELETE_MSG.format(time=AUTO_DELETE_TIME) + ) + # Schedule the file deletion task after all messages have been copied + asyncio.create_task(delete_file(track_msgs, client, delete_data)) + else: + print("No messages to track for deletion.") + return else: reply_markup = InlineKeyboardMarkup( diff --git a/requirements.txt b/requirements.txt index 3a8284d0a..1316a0cf4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,5 +8,3 @@ pymongo dnspython # --- For-Web-Response ------- # aiohttp -# --- For-None-Asynchronous-Auto-Delete-----# -apscheduler \ No newline at end of file From 402af0bf9e7c6c3298c5af09dc6ec3a647ce16df Mon Sep 17 00:00:00 2001 From: Shabin-k Date: Thu, 21 Nov 2024 23:11:24 +0530 Subject: [PATCH 47/49] feat :updated readme.md --- README.md | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index a6bf06b67..759183784 100644 --- a/README.md +++ b/README.md @@ -26,20 +26,31 @@ Telegram Bot to store Posts and Documents and it can Access by Special Links. I Guess This Will Be Usefull For Many People.....πŸ˜‡. -## - -**If you need any more modes in repo or If you find out any bugs, mention in [@codexbotzsupport ](https://www.telegram.dog/codexbotzsupport)** - -**Make sure to see [contributing.md](https://github.com/CodeXBotz/File-Sharing-Bot/blob/main/CONTRIBUTING.md) for instructions on contributing to the project!** - - ### Features - Fully customisable. - Customisable welcome & Forcesub messages. - More than one Posts in One Link. - Can be deployed on heroku directly. +- Protect Content to Prevent Forwarding +- Auto-Delete Files After a Configurable Time + +## What’s Next + +These features are in the pipeline, and contributions from the community are welcome! + +- [ ] **Channel Join Request** + Implement a feature that prompts users to join a specified Telegram channel before accessing the bot's functionalities. + + +### How to Contribute +1. Check the [contribution guidelines](https://github.com/CodeXBotz/File-Sharing-Bot/blob/main/CONTRIBUTING.md) for detailed instructions. +2. Pick any feature and create a new issue or comment on an existing one. +3. Discuss your implementation plan with maintainers to align your contributions with project goals. +We encourage all developers to contribute ideas, report bugs, and share improvements. Together, we can make this project even better! πŸš€ + + ### Setup - Add the bot to Database Channel with all permission From 487afd7e033e50c717db82a6a322b4738487646b Mon Sep 17 00:00:00 2001 From: Shabin-k Date: Sun, 24 Nov 2024 23:04:28 +0530 Subject: [PATCH 48/49] feat : add Request to join feature --- README.md | 5 +++-- config.py | 1 + plugins/start.py | 15 +++++++++++++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 759183784..259582699 100644 --- a/README.md +++ b/README.md @@ -33,13 +33,13 @@ I Guess This Will Be Usefull For Many People.....πŸ˜‡. - More than one Posts in One Link. - Can be deployed on heroku directly. - Protect Content to Prevent Forwarding -- Auto-Delete Files After a Configurable Time +- Auto-Delete Files After a Configurable Time ## What’s Next These features are in the pipeline, and contributions from the community are welcome! -- [ ] **Channel Join Request** +- [x] **Channel Join Request** Implement a feature that prompts users to join a specified Telegram channel before accessing the bot's functionalities. @@ -118,6 +118,7 @@ python3 main.py * `FORCE_SUB_CHANNEL` Optional: ForceSub Channel ID, leave 0 if you want disable force sub * `PROTECT_CONTENT` Optional: True if you need to prevent files from forwarding * `AUTO_DELETE_TIME ` Set the time in seconds for automatic file deletion. Default is False, which disables auto-deletion. +* `JOIN_REQUEST_ENABLED` Optional: Set to "True" to enable join request for the channel. Default is "False". ### Extra Variables diff --git a/config.py b/config.py index dab8b5683..0b5819e36 100644 --- a/config.py +++ b/config.py @@ -31,6 +31,7 @@ #force sub channel id, if you want enable force sub FORCE_SUB_CHANNEL = int(os.environ.get("FORCE_SUB_CHANNEL", "0")) +JOIN_REQUEST_ENABLE = os.environ.get("JOIN_REQUEST_ENABLED", None) TG_BOT_WORKERS = int(os.environ.get("TG_BOT_WORKERS", "4")) diff --git a/plugins/start.py b/plugins/start.py index b611c7d29..4ed59ca68 100644 --- a/plugins/start.py +++ b/plugins/start.py @@ -8,7 +8,7 @@ from pyrogram.errors import FloodWait, UserIsBlocked, InputUserDeactivated from bot import Bot -from config import ADMINS, FORCE_MSG, START_MSG, CUSTOM_CAPTION, DISABLE_CHANNEL_BUTTON, PROTECT_CONTENT, START_PIC, AUTO_DELETE_TIME, AUTO_DELETE_MSG +from config import ADMINS, FORCE_MSG, START_MSG, CUSTOM_CAPTION, DISABLE_CHANNEL_BUTTON, PROTECT_CONTENT, START_PIC, AUTO_DELETE_TIME, AUTO_DELETE_MSG, JOIN_REQUEST_ENABLE,FORCE_SUB_CHANNEL from helper_func import subscribed,decode, get_messages, delete_file from database.database import add_user, del_user, full_userbase, present_user @@ -163,13 +163,24 @@ async def start_command(client: Client, message: Message): @Bot.on_message(filters.command('start') & filters.private) async def not_joined(client: Client, message: Message): + + if bool(JOIN_REQUEST_ENABLE): + invite = await client.create_chat_invite_link( + chat_id=FORCE_SUB_CHANNEL, + creates_join_request=True + ) + ButtonUrl = invite.invite_link + else: + ButtonUrl = client.invitelink + buttons = [ [ InlineKeyboardButton( "Join Channel", - url = client.invitelink) + url = ButtonUrl) ] ] + try: buttons.append( [ From 0fb47457ed03d162a07b8104c2880ba46fcf0904 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=F0=9F=82=A1hul?= <58558341+rahulps1000@users.noreply.github.com> Date: Sun, 28 Dec 2025 23:44:10 +0530 Subject: [PATCH 49/49] Add Star History section to README Added a Star History section with a chart to the README. --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 259582699..522e4811f 100644 --- a/README.md +++ b/README.md @@ -169,6 +169,16 @@ will. Specifically you can redistribute and/or modify it under the terms of the published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +## Star History + + + + + + Star History Chart + + + ## **Star this Repo if you Liked it ⭐⭐⭐**