diff --git a/.github/workflows/ISSUE_TEMPLATE/bug_report.md b/.github/workflows/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index 0d64d898cda9..000000000000 --- a/.github/workflows/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,26 +0,0 @@ ---- -name: Bug report -about: Create a report to help us improve -title: '' -labels: bug -assignees: '' - ---- - -**Describe the bug** -A clear and concise description of what the bug is. - -**To Reproduce** -Steps to reproduce the behavior: -1. Used this Command with this link or file. -2. Before/after/while Upload .. -3. Check logs - -**Expected behavior** -A clear and concise description of what you expected to happen. - -**Screenshots** -If applicable, add screenshots to help explain your problem. - -**Additional context** -Add any other context about the problem here. diff --git a/.github/workflows/ISSUE_TEMPLATE/feature_request.md b/.github/workflows/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index 11fc491ef1da..000000000000 --- a/.github/workflows/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -name: Feature request -about: Suggest an idea for this project -title: '' -labels: enhancement -assignees: '' - ---- - -**Is your feature request related to a problem? Please describe.** -A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] - -**Describe the solution you'd like** -A clear and concise description of what you want to happen. - -**Describe alternatives you've considered** -A clear and concise description of any alternative solutions or features you've considered. - -**Additional context** -Add any other context or screenshots about the feature request here. diff --git a/README.md b/README.md index 85374133fa82..0fa42de2cde7 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,8 @@ programming in Python. - Enable/Disable multi mirror function - Enable/Disable torrent seeding system - Token system for shortners with database support + - Shortner link bypass detection + - Minimum average download speed limit ## Status @@ -270,63 +272,52 @@ programming in Python. **2. Optional Fields** - - `USER_SESSION_STRING`: To download/upload from your telegram account if user is `PREMIUM` and to send rss. To generate - session string use this command `python3 generate_string_session.py` after mounting repo folder for sure. `Str`. * - *NOTE**: You can't use bot with private message. Use it with superGroup. + - `AUTHORIZED_CHATS`: Fill user_id and chat_id of groups/users you want to authorize. Separate them by space. `Int` + - `SUDO_USERS`: Fill user_id of users whom you want to give sudo permission. Separate them by space. `Int` - `DATABASE_URL`: Your Mongo Database URL (Connection string). Follow this [Generate Database](https://github.com/Dawn-India/Z-Mirror/tree/main#generate-database) to generate database. Data will be saved in Database: auth and sudo users, users settings including thumbnails for each user, rss data and incomplete tasks. **NOTE**: You can always edit all settings that saved in database from the official site -> (Browse collections). `Str` - - `DOWNLOAD_DIR`: The path to the local folder where the downloads should be downloaded to. `Str` - - `CMD_SUFFIX`: commands index number. This number will added at the end all commands. `Str`|`Int` - - `AUTHORIZED_CHATS`: Fill user_id and chat_id of groups/users you want to authorize. Separate them by space. `Int` - - `SUDO_USERS`: Fill user_id of users whom you want to give sudo permission. Separate them by space. `Int` - - `DEFAULT_UPLOAD`: Whether `rc` to upload to `RCLONE_PATH` or `gd` to upload to `GDRIVE_ID`. Default is `gd`. Read - More [HERE](https://github.com/Dawn-India/Z-Mirror/tree/main#upload).`Str` - - `STATUS_UPDATE_INTERVAL`: Time in seconds after which the progress/status message will be updated. Recommended `10` - seconds at least. `Int` - - `STATUS_LIMIT`: Limit the no. of tasks shown in status message with buttons. Default is `10`. **NOTE**: Recommended - limit is `4` tasks. `Int` - - `EXTENSION_FILTER`: File extensions that won't upload/clone. Separate them by space. `Str` - - `INCOMPLETE_TASK_NOTIFIER`: Get incomplete task messages after restart. Require database and superGroup. Default - is `False`. `Bool` + - `USER_SESSION_STRING`: To download/upload from your telegram account if user is `PREMIUM` and to send rss. To generate + session string use this command `python3 generate_string_session.py` after mounting repo folder for sure. `Str`. * + + **3. Optional APIs** - `FILELION_API`: Filelion api key to mirror Filelion links. Get it from [Filelion](https://vidhide.com/?op=my_account). `str` - `STREAMWISH_API`: Streamwish api key to mirror Streamwish links. Get it from [Streamwish](https://streamwish.com/?op=my_account). `str` - - `YT_DLP_OPTIONS`: Default yt-dlp options. Check all possible - options [HERE](https://github.com/yt-dlp/yt-dlp/blob/master/yt_dlp/YoutubeDL.py#L184) or use - this [script](https://t.me/mltb_official_channel/177) to convert cli arguments to api options. Format: key:value|key: - value|key:value. Add `^` before integer or float, some numbers must be numeric and some string. `str` - - Example: "format:bv*+mergeall[vcodec=none]|nocheckcertificate:True" - - `USE_SERVICE_ACCOUNTS`: Whether to use Service Accounts or not, with google-api-python-client. For this to work - see [Using Service Accounts](https://github.com/Dawn-India/Z-Mirror#generate-service-accounts-what-is-service-account) - section below. Default is `False`. `Bool` - - `NAME_SUBSTITUTE`: Add word/letter/sentense/pattern to remove or replace with other words with sensitive case or without.**Notes**: - 1. Seed will get disbaled while using this option - 2. Before any character you must add \, those are the characters: `\^$.|?*+()[]{}-` - * Example-1: `text : code : s | mirror : leech | tea : : s | clone` - - text will get replaced by code with sensitive case - - mirror will get replaced by leech - - tea will get removed with sensitive case - - clone will get removed - * Example-2: `\(text\) | \[test\] : test | \\text\\ : text : s` - - `(text)` will get removed - - `[test]` will get replaced by test - - `\text\` will get replaced by text with sensitive case + - **3. GDrive Tools** + **4. GDrive Tools** - `GDRIVE_ID`: This is the Folder/TeamDrive ID of the Google Drive OR `root` to which you want to upload all the mirrors using google-api-python-client. `Str` - - `IS_TEAM_DRIVE`: Set `True` if uploading to TeamDrive using google-api-python-client. Default is `False`. `Bool` - `INDEX_URL`: Refer to . `Str` + - `IS_TEAM_DRIVE`: Set `True` if uploading to TeamDrive using google-api-python-client. Default is `False`. `Bool` - `STOP_DUPLICATE`: Bot will check file/folder name in Drive incase uploading to `GDRIVE_ID`. If it's present in Drive then downloading or cloning will be stopped. (**NOTE**: Item will be checked using name and not hash, so this feature is not perfect yet). Default is `False`. `Bool` + - `DISABLE_DRIVE_LINK`: Disable drive links for all users. Default is `False`. `Bool` + - `USE_SERVICE_ACCOUNTS`: Whether to use Service Accounts or not, with google-api-python-client. For this to work + see [Using Service Accounts](https://github.com/Dawn-India/Z-Mirror#generate-service-accounts-what-is-service-account) + section below. Default is `False`. `Bool` + + **5. qBittorrent/Aria2c/Sabnzbd** - **4. Rclone** + - `TORRENT_TIMEOUT`: Timeout of dead torrents downloading with qBittorrent and Aria2c in seconds. `Int` + - `BASE_URL`: Valid BASE URL where the bot is deployed to use torrent web files selection. Format of URL should + be `http://myip`, where `myip` is the IP/Domain(public) of your bot or if you have chosen port other than `80` so + write it in this format `http://myip:port` (`http` and not `https`). `Str` + - `BASE_URL_PORT`: Which is the **BASE_URL** Port. Default is `80`. `Int` + - `WEB_PINCODE`: Whether to ask for pincode before selecting files from torrent in web or not. Default + is `False`. `Bool`. + - **Qbittorrent NOTE**: If your facing ram issues then set limit for `MaxConnections`, + decrease `AsyncIOThreadsCount`, set limit of `DiskWriteCacheSize` to `32` and decrease `MemoryWorkingSetLimit` + from qbittorrent.conf or bsetting command. + - Open port 8090 in your vps to access webui from any device. username: zee, password: @Z_Mirror + + **6. Rclone** - `RCLONE_PATH`: Default rclone path to which you want to upload all the files/folders using rclone. `Str` - `RCLONE_FLAGS`: key:value|key|key|key:value . Check here all [RcloneFlags](https://rclone.org/flags/). `Str` @@ -337,7 +328,27 @@ programming in Python. - `RCLONE_SERVE_USER`: Username for rclone serve authentication. `Str` - `RCLONE_SERVE_PASS`: Password for rclone serve authentication. `Str` - **5. Update** + **7. JDownloader** + + - `JD_EMAIL`: jdownlaoder email sign up on [JDownloader](https://my.jdownloader.org/) + - `JD_PASS`: jdownlaoder password + + **8. MEGA Sdk** + - `MEGA_EMAIL`: Mega email sign up on [Mega](https://mega.nz/) + - `MEGA_PASS`: Mega password + + **9. Sabnzbd** + + - `USENET_SERVERS`: list of dictionaries, you can add as much as you want and there is a button for servers in sabnzbd settings to edit current servers and add new servers. + + ***[{'name': 'main', 'host': '', 'port': 563, 'timeout': 60, 'username': '', 'password': '', 'connections': 8, 'ssl': 1, 'ssl_verify': 2, 'ssl_ciphers': '', 'enable': 1, 'required': 0, 'optional': 0, 'retention': 0, 'send_group': 0, 'priority': 0}]*** + + - [READ THIS FOR MORE INFORMATION](https://sabnzbd.org/wiki/configuration/4.2/servers) + + - **NOTE**: Enable port 8070 in your vps to access sabnzbd full web interface + - Open port 8070 in your vps to access web interface from any device. Use it like http://ip:8070/sabnzbd/. + + **10. Update** - `UPSTREAM_REPO`: Your github repository link, if your repo is private add `https://username:{githubtoken}@github.com/{username}/{reponame}` format. Get token @@ -348,49 +359,102 @@ programming in Python. read [THIS](https://github.com/Dawn-India/Z-Mirror/tree/main#upstream-repo-recommended). - `UPSTREAM_BRANCH`: Upstream branch for update. Default is `main`. `Str` - **6. Leech** + **11. Leech** - - `LEECH_SPLIT_SIZE`: Size of split in bytes. Default is `2GB`. Default is `4GB` if your account is premium. `Int` - `AS_DOCUMENT`: Default type of Telegram file upload. Default is `False` mean as media. `Bool` + - `LEECH_SPLIT_SIZE`: Size of split in bytes. Default is `2GB`. Default is `4GB` if your account is premium. `Int` + - `LEECH_FILENAME_PREFIX`: Add custom word to the beginning of the leeched file name/caption. `Str` + - `LEECH_FILENAME_SUFFIX`: Add custom word to the end of the leeched file name/caption. `Str` + - `LEECH_CAPTION_FONT` : Font style for caption. Default is `regular`. `Str` - `EQUAL_SPLITS`: Split files larger than **LEECH_SPLIT_SIZE** into equal parts size (Not working with zip cmd). Default is `False`. `Bool` - `MEDIA_GROUP`: View Uploaded splitted file parts in media group. Default is `False`. `Bool`. - `USER_TRANSMISSION`: Upload/Download by user session. Only in superChat. Default is `False`. `Bool` - `MIXED_LEECH`: Upload by user and bot session with respect to file size. Only in superChat. Default is `False`. `Bool` - - `LEECH_FILENAME_PREFIX`: Add custom word to leeched file name. `Str` - - `LEECH_DUMP_CHAT`: ID or USERNAME or PM(private message) to where files would be uploaded. `Int`|`Str`. Add `-100` before channel/superGroup id. - - **7. qBittorrent/Aria2c/Sabnzbd** - - - `TORRENT_TIMEOUT`: Timeout of dead torrents downloading with qBittorrent and Aria2c in seconds. `Int` - - `BASE_URL`: Valid BASE URL where the bot is deployed to use torrent web files selection. Format of URL should - be `http://myip`, where `myip` is the IP/Domain(public) of your bot or if you have chosen port other than `80` so - write it in this format `http://myip:port` (`http` and not `https`). `Str` - - `BASE_URL_PORT`: Which is the **BASE_URL** Port. Default is `80`. `Int` - - `WEB_PINCODE`: Whether to ask for pincode before selecting files from torrent in web or not. Default - is `False`. `Bool`. - - **Qbittorrent NOTE**: If your facing ram issues then set limit for `MaxConnections`, - decrease `AsyncIOThreadsCount`, set limit of `DiskWriteCacheSize` to `32` and decrease `MemoryWorkingSetLimit` - from qbittorrent.conf or bsetting command. - - Open port 8090 in your vps to access webui from any device. username: zee, password: @Z_Mirror - - **8. JDownloader** - - - `JD_EMAIL`: jdownlaoder email sign up on [JDownloader](https://my.jdownloader.org/) - - `JD_PASS`: jdownlaoder password + - `USER_LEECH_DESTINATION`: ID or USERNAME or PM(private message) to where files would be uploaded. `Int`|`Str`. Add `-100` before channel/superGroup id. + - `NAME_SUBSTITUTE`: Add word/letter/sentense/pattern to remove or replace with other words with sensitive case or without.**Notes**: + 1. Seed will get disbaled while using this option + 2. Before any character you must add \, those are the characters: `\^$.|?*+()[]{}-` + * Example-1: `text : code : s | mirror : leech | tea : : s | clone` + - text will get replaced by code with sensitive case + - mirror will get replaced by leech + - tea will get removed with sensitive case + - clone will get removed + * Example-2: `\(text\) | \[test\] : test | \\text\\ : text : s` + - `(text)` will get removed + - `[test]` will get replaced by test + - `\text\` will get replaced by text with sensitive case - **9. Sabnzbd** +**12. Super Group Features** + + - `REQUEST_LIMITS`: Limit the no. of requests per user. Default is `0`. `Int` + - `TOKEN_TIMEOUT`: Time in seconds for token timeout. Default is `0` seconds. `Int` + - `MINIMUM_DURATOIN`: Minimum duration for the shortner links. Open your shorturl and count the minimum time to reach to the end. If a user completes the shortener faster than the minimum required time then the bot will reject his token. Default is `0` seconds. `Int` + - `USER_MAX_TASKS`: Maximum tasks per user. Default is `0`. `Int` + - `AUTO_DELETE_MESSAGE_DURATION`: Time in seconds for auto delete message. Default is `0` seconds. `Int` + - `ENABLE_MESSAGE_FILTER`: Enable message filter to stop users from sending foroward messages. Default is `False`. `Bool` + - `DELETE_LINKS`: Enable it to delete all links from the chat to avoid copyright + issues. Default is `False`. `Bool` + - `DM_MODE`: Enable it to allow users to receive files in DM. Default is `False`. `Bool` + - `STOP_DUPLICATE_TASKS`: Stop duplicate tasks for all users from all bots under the same database. Default is `False`. `Bool` + - `INCOMPLETE_TASK_NOTIFIER`: Get incomplete task messages after restart. Require database and superGroup. Default + is `False`. `Bool` - - `USENET_SERVERS`: list of dictionaries, you can add as much as you want and there is a button for servers in sabnzbd settings to edit current servers and add new servers. +**13. Extras** - ***[{'name': 'main', 'host': '', 'port': 563, 'timeout': 60, 'username': '', 'password': '', 'connections': 8, 'ssl': 1, 'ssl_verify': 2, 'ssl_ciphers': '', 'enable': 1, 'required': 0, 'optional': 0, 'retention': 0, 'send_group': 0, 'priority': 0}]*** + - `EXTENSION_FILTER`: File extensions that won't upload/clone. Separate them by space. `Str` + - `YT_DLP_OPTIONS`: Default yt-dlp options. Check all possible + options [HERE](https://github.com/yt-dlp/yt-dlp/blob/master/yt_dlp/YoutubeDL.py#L184) or use + this [script](https://t.me/mltb_official_channel/177) to convert cli arguments to api options. Format: key:value|key: + value|key:value. Add `^` before integer or float, some numbers must be numeric and some string. `str` + - Example: "format:bv*+mergeall[vcodec=none]|nocheckcertificate:True" + - `SET_COMMANDS`: Auto set bot commands. Default is `False`. `Bool` + - `CMD_SUFFIX`: commands index number. This number will added at the end all commands. `Str`|`Int` + - `DEFAULT_UPLOAD`: Whether `rc` to upload to `RCLONE_PATH` or `gd` to upload to `GDRIVE_ID`. Default is `gd`. Read + More [HERE](https://github.com/Dawn-India/Z-Mirror/tree/main#upload).`Str` + - `STATUS_LIMIT`: Limit the no. of tasks shown in status message with buttons. Default is `10`. **NOTE**: Recommended + limit is `4` tasks. `Int` + - `STATUS_UPDATE_INTERVAL`: Time in seconds after which the progress/status message will be updated. Recommended `10` + seconds at least. `Int` + - `DOWNLOAD_DIR`: The path to the local folder where the downloads should be downloaded to. `Str` - - [READ THIS FOR MORE INFORMATION](https://sabnzbd.org/wiki/configuration/4.2/servers) +**14. Feature Control** + - `DISABLE_BULK`: Disable bulk link function. Default is `False`. `Bool` + - `DISABLE_MULTI`: Disable multi mirror function. Default is `False`. `Bool` + - `DISABLE_SEED`: Disable torrent seeding system. Default is `False`. `Bool` + - `DISABLE_LEECH`: Disable leech function. Default is `False`. `Bool` + +**15. Chat IDs** + - `FSUB_IDS`: Chat ID/USERNAME where force subscribe module will work. Force users to join the channel before using the + bot. `str` + - `LOG_CHAT_ID`: Chat ID/USERNAME where all logs will be sent. `str` + - `DUMP_CHAT_ID`: Chat ID/USERNAME where all leeched files will be sent. `str` + +**16. Limits** + - `STORAGE_THRESHOLD`: Storage threshold limit in GB. Default is `0`. `Int` + - `TORRENT_LIMIT`: Torrent limit in GB. Default is `0`. `Int` + - `DIRECT_LIMIT`: Direct download limit in GB. Default is `0`. `Int` + - `YTDLP_LIMIT`: Yt-dlp limit in GB. Default is `0`. `Int` + - `PLAYLIST_LIMIT`: Yt-dlp playlist limit. Default is `0`. `Int` + - `GDRIVE_LIMIT`: Google drive limit in GB. Default is `0`. `Int` + - `MEGA_LIMIT`: Mega limit in GB. Default is `0`. `Int` + - `LEECH_LIMIT`: Leech limit in GB. Default is `0`. `Int` + - `CLONE_LIMIT`: Clone limit in GB. Default is `0`. `Int` + - `RCLONE_LIMIT`: Rclone limit in GB. Default is `0`. `Int` + - `JD_LIMIT`: JDownloader limit in GB. Default is `0`. `Int` + - `NZB_LIMIT`: Sabnzbd limit in GB. Default is `0`. `Int` + - `AVG_SPEED`: Minimun average download speed limit in MB(aria2/qbit). Default is `0`. `Int` + + **17. Queue System** - - **NOTE**: Enable port 8070 in your vps to access sabnzbd full web interface - - Open port 8070 in your vps to access web interface from any device. Use it like http://ip:8070/sabnzbd/. + - `QUEUE_ALL`: Number of parallel tasks of downloads and uploads. For example if 20 task added and `QUEUE_ALL` is `8`, + then the summation of uploading and downloading tasks are 8 and the rest in queue. `Int`. **NOTE**: if you want to + fill `QUEUE_DOWNLOAD` or `QUEUE_UPLOAD`, then `QUEUE_ALL` value must be greater than or equal to the greatest one and + less than or equal to summation of `QUEUE_UPLOAD` and `QUEUE_DOWNLOAD`. + - `QUEUE_DOWNLOAD`: Number of all parallel downloading tasks. `Int` + - `QUEUE_UPLOAD`: Number of all parallel uploading tasks. `Int` - **10. RSS** + **18. RSS** - `RSS_DELAY`: Time in seconds for rss refresh interval. Recommended `600` second at least. Default is `600` in sec. `Int` @@ -402,16 +466,7 @@ programming in Python. with `USER_STRING_SESSION` add group id for `RSS_CHAT`. If `DATABASE_URL` not added you will miss the feeds while bot offline. - **11. Queue System** - - - `QUEUE_ALL`: Number of parallel tasks of downloads and uploads. For example if 20 task added and `QUEUE_ALL` is `8`, - then the summation of uploading and downloading tasks are 8 and the rest in queue. `Int`. **NOTE**: if you want to - fill `QUEUE_DOWNLOAD` or `QUEUE_UPLOAD`, then `QUEUE_ALL` value must be greater than or equal to the greatest one and - less than or equal to summation of `QUEUE_UPLOAD` and `QUEUE_DOWNLOAD`. - - `QUEUE_DOWNLOAD`: Number of all parallel downloading tasks. `Int` - - `QUEUE_UPLOAD`: Number of all parallel uploading tasks. `Int` - - **12. Torrent Search** + **19. Torrent Search** - `SEARCH_API_LINK`: Search api app link. Get your api from deploying this [repository](https://github.com/Ryuk-me/Torrent-Api-py). `Str` diff --git a/bot/__init__.py b/bot/__init__.py index 0c83a454d6c8..2e0d892e5d55 100644 --- a/bot/__init__.py +++ b/bot/__init__.py @@ -847,6 +847,15 @@ else: TOKEN_TIMEOUT = "" +MINIMUM_DURATOIN = environ.get( + "MINIMUM_DURATOIN", + "" +) +if MINIMUM_DURATOIN.isdigit(): + MINIMUM_DURATOIN = int(MINIMUM_DURATOIN) +else: + MINIMUM_DURATOIN = "" + FSUB_IDS = environ.get( "FSUB_IDS", "" @@ -1084,6 +1093,7 @@ "MEGA_PASSWORD": MEGA_PASSWORD, "MIXED_LEECH": MIXED_LEECH, "MEGA_LIMIT": MEGA_LIMIT, + "MINIMUM_DURATOIN": MINIMUM_DURATOIN, "NAME_SUBSTITUTE": NAME_SUBSTITUTE, "NZB_LIMIT": NZB_LIMIT, "PLAYLIST_LIMIT": PLAYLIST_LIMIT, diff --git a/bot/helper/ext_utils/db_handler.py b/bot/helper/ext_utils/db_handler.py index 4c1108052c28..20376cccc981 100644 --- a/bot/helper/ext_utils/db_handler.py +++ b/bot/helper/ext_utils/db_handler.py @@ -359,12 +359,12 @@ async def update_user_tdata(self, user_id, token, time): ) self._conn.close # type: ignore - async def update_user_token(self, user_id, token): + async def update_user_token(self, user_id, token, inittime): if self._err: return await self._db.access_token.update_one( # type: ignore {"_id": user_id}, - {"$set": {"token": token}}, + {"$set": {"token": token, "inittime": inittime}}, upsert=True ) self._conn.close # type: ignore @@ -387,6 +387,15 @@ async def get_user_token(self, user_id): self._conn.close # type: ignore return None + async def get_token_init_time(self, user_id): + if self._err: + return None + user_data = await self._db.access_token.find_one({"_id": user_id}) # type: ignore + if user_data: + return user_data.get("inittime") + self._conn.close # type: ignore + return None + async def delete_all_access_tokens(self): if self._err: return diff --git a/bot/helper/ext_utils/help_messages.py b/bot/helper/ext_utils/help_messages.py index 8fa91c403d32..4bf8d2b51537 100644 --- a/bot/helper/ext_utils/help_messages.py +++ b/bot/helper/ext_utils/help_messages.py @@ -1,5 +1,5 @@ mirror = """ -Send link along with command line or +Send link along with command line: /cmd link @@ -9,8 +9,6 @@ NOTE: 1. Commands that start with qb are ONLY for torrents. - -Join: @Z_Mirror """ yt = """ @@ -24,8 +22,6 @@ Check all supported SITES Check all yt-dlp API options from this FILE or use this script to convert CLI arguments to API options. - -Join: @Z_Mirror """ clone = """ @@ -34,25 +30,19 @@ Use -sync to use sync method in rclone. Example: /cmd rcl/rclone_path -up rcl/rclone_path/rc -sync - -Join: @Z_Mirror """ new_name = """ -New Name: -n +Rename: -n -/cmd link -n new name +/cmd link -n new_name Note: Doesn't work with torrents - -Join: @Z_Mirror """ multi_link = """ Multi links only by replying to the first link/file: -m /cmd -m 10(number of links/files) - -Join: @Z_Mirror """ same_dir = """ @@ -60,16 +50,12 @@ /cmd -m 10(number of links/files) -sd folder name (multi message) /cmd -b -sd folder name (bulk-message/file) - -Join: @Z_Mirror """ thumb = """ Thumbnail for the current task: -t /cmd link -t tg-message-link(doc or photo) - -Join: @Z_Mirror """ split_size = """ @@ -77,8 +63,6 @@ /cmd link -sp (500mb or 2gb or 4000000000) Note: Only mb and gb are supported or write in bytes without unit! - -Join: @Z_Mirror """ upload = """ @@ -94,8 +78,6 @@ In case you want to specify whether using token.pickle or service accounts you can add tp:gdrive_id or sa:gdrive_id or mtp:gdrive_id. DEFAULT_UPLOAD has no effect on leech cmds. - -Join: @Z_Mirror """ user_download = """ @@ -107,8 +89,6 @@ /cmd sa:gdrive_id to download using service account and file_id in case service account disabled. /cmd mtp:gdrive_id or mtp:link to download using user token.pickle uploaded from usetting /cmd mrcc:remote:path to download using user rclone config uploaded from usetting - -Join: @Z_Mirror """ rcf = """ @@ -117,8 +97,6 @@ /cmd link|path|rcl -up path|rcl -rcf --buffer-size:8M|--drive-starred-only|key|key:value This will override all other flags except --exclude. Check here all RcloneFlags. - -Join: @Z_Mirror """ bulk = """ @@ -133,8 +111,6 @@ Reply to this example by this cmd -> /cmd -b(bulk) or /cmd -b -sd folder name You can set the start and end of the links from the bulk like seed, with -b start:end or only end by -b :end or only start by -b start. The default start is from zero(first link) to infinity. - -Join: @Z_Mirror """ rlone_dl = """ @@ -145,19 +121,16 @@ Users can add their own rclone from user settings If you want to add a path manually from your config add mrcc: before the path without space /cmd mrcc:main:dump/ubuntu.iso - -Join: @Z_Mirror """ extract_zip = """ Extract/Zip: -e -z +/cmd link -e (extract) /cmd link -e password (extract password protected) -/cmd link -z password (zip password protected) + /cmd link -z password -e (extract and zip password protected) Note: When both extract and zip are added with cmd, it will extract first and then zip, so always extract first. - -Join: @Z_Mirror """ join = """ @@ -169,8 +142,6 @@ /cmd -b -j -sd folder name If you have a link(folder) that has split files: /cmd link -j - -Join: @Z_Mirror """ tg_links = """ @@ -185,8 +156,6 @@ Range: https://t.me/channel_name/first_message_id-last_message_id Range Example: tg://openmessage?user_id=xxxxxx&message_id=555-560 or https://t.me/channel_name/100-150 Note: Range link will work only by replying cmd to it. - -Join: @Z_Mirror """ sample_video = """ @@ -195,8 +164,6 @@ Create a sample video for one video or a folder of videos. /cmd -sv (it will take the default values which are 60sec sample duration and part duration is 4sec). You can control those values. Example: /cmd -sv 70:5(sample-duration:part-duration) or /cmd -sv :5 or /cmd -sv 70. - -Join: @Z_Mirror """ screenshot = """ @@ -205,8 +172,6 @@ Create up to 10 screenshots for one video or a folder of videos. /cmd -ss (it will take the default values which are 10 photos). You can control this value. Example: /cmd -ss 6. - -Join: @Z_Mirror """ seed = """ @@ -215,8 +180,6 @@ /cmd link -d ratio:seed_time or by replying to file/link To specify ratio and seed time add -d ratio:time. Example: -d 0.7:10 (ratio and time) or -d 0.7 (only ratio) or -d :10 (only time) where time is in minutes. - -Join: @Z_Mirror """ zip_arg = """ @@ -225,7 +188,8 @@ /cmd link -z (zip) /cmd link -z password (zip password protected) -Join: @Z_Mirror +/cmd link -z password -e (extract and zip password protected) +Note: When both extract and zip are added with cmd, it will extract first and then zip, so always extract first. """ qual = """ @@ -233,8 +197,6 @@ In case default quality is added from yt-dlp options using format option and you need to select quality for specific link or links with multi links feature. /cmd link -s - -Join: @Z_Mirror """ yt_opt = """ @@ -244,67 +206,59 @@ Note: Add `^` before integer or float, some values must be numeric and some string. Like playlist_items:10 works with string, so no need to add `^` before the number but playlistend works only with integer so you must add `^` before the number like example above. You can add tuple and dict also. Use double quotes inside dict. - -Join: @Z_Mirror """ convert_media = """ Convert Media: -ca -cv + /cmd link -ca mp3 -cv mp4 (convert all audios to mp3 and all videos to mp4) /cmd link -ca mp3 (convert all audios to mp3) /cmd link -cv mp4 (convert all videos to mp4) /cmd link -ca mp3 + flac ogg (convert only flac and ogg audios to mp3) /cmd link -cv mp4 - webm flv (convert all videos to mp4 except webm and flv) - -Join: @Z_Mirror """ force_start = """ Force Start: -f -fd -fu + /cmd link -f (force download and upload) /cmd link -fd (force download only) /cmd link -fu (force upload directly after download finishes) - -Join: @Z_Mirror """ gdrive = """ Gdrive: link If DEFAULT_UPLOAD is `rc` then you can pass up: `gd` to upload using gdrive tools to GDRIVE_ID. + /cmd gdriveLink or gdl or gdriveId -up gdl or gdriveId or gd /cmd tp:gdriveLink or tp:gdriveId -up tp:gdriveId or gdl or gd (to use token.pickle if service account enabled) /cmd sa:gdriveLink or sa:gdriveId -p sa:gdriveId or gdl or gd (to use service account if service account disabled) /cmd mtp:gdriveLink or mtp:gdriveId -up mtp:gdriveId or gdl or gd(if you have added upload gdriveId from usetting) (to use user token.pickle that uploaded by usetting) - -Join: @Z_Mirror """ rclone_cl = """ Rclone: path If DEFAULT_UPLOAD is `gd` then you can pass up: `rc` to upload to RCLONE_PATH. + /cmd rcl/rclone_path -up rcl/rclone_path/rc -rcf flagkey:flagvalue|flagkey|flagkey:flagvalue /cmd rcl or rclonePath -up rclonePath or rc or rcl /cmd mrcc:rclonePath -up rcl or rc(if you have added rclone path from usetting) (to use user config) - -Join: @Z_Mirror """ name_sub = """ Name Substitution: -ns + /cmd link -ns tea : coffee : s|ACC : : s|mP4 This will affect all files. Format: wordToReplace : wordToReplaceWith : sensitiveCase 1. tea will get replaced by coffee with sensitive case because I have added `s` last of the option. 2. ACC will get removed because I have added nothing between to replace with sensitive case because I have added `s` last of the option. 3. mP4 will get removed because I have added nothing to replace with - -Join: @Z_Mirror """ mixed_leech = """ Mixed Leech: -ml -/cmd link -ml (leech by user and bot session with respect to size) -Join: @Z_Mirror +/cmd link -ml (leech by user and bot session with respect to size) """ YT_HELP_DICT = { @@ -385,8 +339,6 @@ 3. You can add `or` and `|` as much as you want. 4. Take a look at the title if it has a static special character after or before the qualities or extensions or whatever and use them in the filter to avoid wrong match. Timeout: 60 sec. - -Join: @Z_Mirror """ PASSWORD_ERROR_MESSAGE = """ @@ -394,6 +346,4 @@ - Insert :: after the link and write the password after the sign. Example: link::my password - -Join: @Z_Mirror """ diff --git a/bot/helper/ext_utils/status_utils.py b/bot/helper/ext_utils/status_utils.py index 8067f66bd13e..5969a51377ed 100644 --- a/bot/helper/ext_utils/status_utils.py +++ b/bot/helper/ext_utils/status_utils.py @@ -320,26 +320,40 @@ async def get_readable_message( if len(msg) == 0: if status == "All": - return None, None + return ( + None, + None + ) else: msg = f"No Active {status} Tasks!\n\n" buttons = ButtonMaker() + if is_user: + buttons.ibutton( + "ʀᴇғʀᴇsʜ", + f"status {sid} ref", + position="header" + ) if not is_user: buttons.ibutton( - "Tasks Info", + "ᴛᴀsᴋs\nɪɴғᴏ", f"status {sid} ov" ) buttons.ibutton( - "System Info", + "sʏsᴛᴇᴍ\nɪɴғᴏ", f"status {sid} stats" ) if len(tasks) > STATUS_LIMIT: - msg += f"Page: {page_no}/{pages} | Tasks: {tasks_no} | Step: {page_step}\n" + msg += f"Tasks: {tasks_no} | Step: {page_step}\n" buttons.ibutton( "⫷", f"status {sid} pre", position="header" ) + buttons.ibutton( + f"ᴘᴀɢᴇs\n{page_no}/{pages}", + f"status {sid} ref", + position="header" + ) buttons.ibutton( "⫸", f"status {sid} nex", @@ -373,11 +387,6 @@ async def get_readable_message( label, f"status {sid} st {status_value}" ) - buttons.ibutton( - "Refresh", - f"status {sid} ref", - position="header" - ) button = buttons.build_menu(8) msg += ( f"CPU: {cpu_percent()}% | " diff --git a/bot/helper/ext_utils/token_manager.py b/bot/helper/ext_utils/token_manager.py index 67d2857917d3..389c089acf75 100644 --- a/bot/helper/ext_utils/token_manager.py +++ b/bot/helper/ext_utils/token_manager.py @@ -14,7 +14,7 @@ from bot.helper.telegram_helper.bot_commands import BotCommands from bot.helper.telegram_helper.button_build import ButtonMaker from bot.helper.telegram_helper.filters import CustomFilters -from bot.helper.telegram_helper.message_utils import sendMessage +from bot.helper.telegram_helper.message_utils import sendMessage, sendLogMessage from pyrogram.filters import command from pyrogram.handlers import MessageHandler @@ -22,8 +22,14 @@ async def checking_access(user_id, button=None): if not config_dict["TOKEN_TIMEOUT"]: - return None, button - user_data.setdefault(user_id, {}) + return ( + None, + button + ) + user_data.setdefault( + user_id, + {} + ) data = user_data[user_id] if DATABASE_URL: data["time"] = await DbManager().get_token_expire_time(user_id) @@ -40,13 +46,16 @@ async def checking_access(user_id, button=None): and "token" in data else str(uuid4()) ) + inittime = time() if expire is not None: del data["time"] data["token"] = token + data["inittime"] = inittime if DATABASE_URL: await DbManager().update_user_token( user_id, - token + token, + inittime ) user_data[user_id].update(data) if button is None: @@ -57,9 +66,7 @@ async def checking_access(user_id, button=None): ) tmsg = ( "Your Token is expired. Get a new one." - f"\nToken Validity: {get_readable_time(config_dict["TOKEN_TIMEOUT"])}\n\n" - "Your Limites:\n" - f"{config_dict["USER_MAX_TASKS"]} parallal tasks.\n" + f"\nToken Validity: {get_readable_time(config_dict["TOKEN_TIMEOUT"])}\n" ) return ( tmsg, @@ -72,6 +79,7 @@ async def checking_access(user_id, button=None): async def start(client, message): + tag = message.from_user.mention if ( len(message.command) > 1 and len(message.command[1]) == 36 @@ -90,6 +98,28 @@ async def start(client, message): message, "Invalid token.\n\nPlease generate a new one." ) + inittime = await DbManager().get_token_init_time(userid) + duration = time() - inittime # type: ignore + if ( + config_dict["MINIMUM_DURATOIN"] + and ( + duration < config_dict["MINIMUM_DURATOIN"] + ) + ): + await DbManager().update_user_tdata( + userid, + 0, + 0 + ) + await sendLogMessage( + message, + f"#BYPASS\n\nShortener bypass detected.", + tag + ) + return await sendMessage( + message, + "Shortener bypass detected.\n\nPlease generate a new token.\n\nDon't try to bypass it, next time ban." + ) if userid not in user_data: return await sendMessage( message, @@ -104,6 +134,23 @@ async def start(client, message): message, "Token already used!\n\nKindly generate a new one." ) + duration = time() - data["inittime"] + if ( + config_dict["MINIMUM_DURATOIN"] + and ( + duration < config_dict["MINIMUM_DURATOIN"] + ) + ): + del data["token"] + await sendLogMessage( + message, + f"#BYPASS\n\nShortener bypass detected.", + tag + ) + return await sendMessage( + message, + "Shortener bypass detected.\n\nPlease generate a new token.\n\nDon't try to bypass it, next time ban." + ) token = str(uuid4()) ttime = time() data["token"] = token @@ -135,20 +182,23 @@ async def start(client, message): elif ( not config_dict["DM_MODE"] and message.chat.type != message.chat.type.SUPERGROUP - and not await CustomFilters.authorized(client, message) + and not await CustomFilters.authorized( + client, + message + ) ): - start_string = "Sorry, you cannot use me here!\n" \ - "Join: @Z_Mirror to use me.\n" \ - "Thank You!" + start_string = "Sorry, you cannot use me in private!" elif ( not config_dict["DM_MODE"] and message.chat.type != message.chat.type.SUPERGROUP - and await CustomFilters.authorized(client, message) + and await CustomFilters.authorized( + client, + message + ) ): start_string = "There's nothing to Start here.\n" \ "Try something else or read HELP" else: - tag = message.from_user.mention start_string = "Start me in DM, not in the group.\n" \ f"cc: {tag}" await sendMessage( diff --git a/bot/modules/bot_settings.py b/bot/modules/bot_settings.py index a58c0e68f332..184e114a7b81 100644 --- a/bot/modules/bot_settings.py +++ b/bot/modules/bot_settings.py @@ -2416,6 +2416,15 @@ async def load_config(): else: TOKEN_TIMEOUT = "" + MINIMUM_DURATOIN = environ.get( + "MINIMUM_DURATOIN", + "" + ) + if MINIMUM_DURATOIN.isdigit(): + MINIMUM_DURATOIN = int(MINIMUM_DURATOIN) + else: + MINIMUM_DURATOIN = "" + FSUB_IDS = environ.get( "FSUB_IDS", "" @@ -2695,6 +2704,7 @@ async def load_config(): "CLONE_LIMIT": CLONE_LIMIT, "RCLONE_LIMIT": RCLONE_LIMIT, "MEGA_LIMIT": MEGA_LIMIT, + "MINIMUM_DURATOIN": MINIMUM_DURATOIN, "LEECH_LIMIT": LEECH_LIMIT, "JD_LIMIT": JD_LIMIT, "NZB_LIMIT": NZB_LIMIT, diff --git a/config_sample.env b/config_sample.env index bdd14bb5f87a..36b4097aaf8e 100644 --- a/config_sample.env +++ b/config_sample.env @@ -68,6 +68,7 @@ NAME_SUBSTITUTE = "" # Super Group Settings REQUEST_LIMITS = "4" # Enter only numbers in seconds TOKEN_TIMEOUT = "" # Enter only numbers in seconds +MINIMUM_DURATOIN = "" # Enter only numbers in seconds USER_MAX_TASKS = "" # Enter only numbers AUTO_DELETE_MESSAGE_DURATION = "120" # Enter only numbers in seconds ENABLE_MESSAGE_FILTER = "False" # True or False