Signed-off-by: anasty17 <e.anastayyar@gmail.com>
This commit is contained in:
anasty17 2021-11-28 16:39:36 +02:00
parent f8e70fbc6f
commit b83177f42b
3 changed files with 82 additions and 71 deletions

View File

@ -25,6 +25,7 @@ This is a Telegram Bot written in Python for mirroring files on the Internet to
- Search for torrents with Torrent Search API
- Docker image support for `linux/amd64, linux/arm64, linux/arm/v7, linux/arm/v6` (**Note**: Use `anasty17/mltb-oracle:latest` for oracle or if u faced problem with arm64 docker run)
- Update bot at startup and with restart command using `UPSTREAM_REPO`
- Clone/zip/unzip from gdtot links (main script from [Yusuf](https://github.com/oxosec)) and delete first cloned file from main drive or TeamDrive
- Many bugs have been fixed
## From Other Repositories
@ -125,8 +126,8 @@ Fill up rest of the fields. Meaning of each field is discussed below:
- `USE_SERVICE_ACCOUNTS`: (Leave empty if unsure) Whether to use Service Accounts or not. For this to work see [Using Service Accounts](https://github.com/anasty17/mirror-leech-telegram-bot#generate-service-accounts-what-is-service-account) section below.
- `INDEX_URL`: Refer to https://gitlab.com/ParveenBhadooOfficial/Google-Drive-Index The URL should not have any trailing '/'
- `MEGA_API_KEY`: Mega.nz API key to mirror mega.nz links. Get it from [Mega SDK Page](https://mega.nz/sdk)
- `MEGA_EMAIL_ID`: Your E-Mail ID used to sign up on mega.nz for using premium account (Leave though)
- `MEGA_PASSWORD`: Your Password for your mega.nz account
- `MEGA_EMAIL_ID`: E-Mail ID used to sign up on mega.nz for using premium account (Leave though)
- `MEGA_PASSWORD`: Password for mega.nz account
- `BLOCK_MEGA_FOLDER`: If you want to remove mega.nz folder support, set it to `True`. `Bool`
- `BLOCK_MEGA_LINKS`: If you want to remove mega.nz mirror support, set it to `True`. `Bool`
- `STOP_DUPLICATE`: (Leave empty if unsure) if this field is set to `True`, bot will check file in Drive, if it is present in Drive, downloading or cloning will be stopped. (**NOTE**: File will be checked using filename not file hash, so this feature is not perfect yet). `Bool`
@ -134,17 +135,17 @@ Fill up rest of the fields. Meaning of each field is discussed below:
- `MEGA_LIMIT`: To limit the size of Mega download. Don't add unit, the default unit is `GB`.
- `TORRENT_DIRECT_LIMIT`: To limit the Torrent/Direct mirror size. Don't add unit, the default unit is `GB`.
- `ZIP_UNZIP_LIMIT`: To limit the size of mirroring as Zip or unzipmirror. Don't add unit, the default unit is `GB`.
- `VIEW_LINK`: View Link button to open file Index Link in browser instead of direct download link, you can figure out if it's compatible with your Index code or not, open any video from you Index and check if its URL ends with `?a=view`, if yes make it `True` it will work (Compatible with https://gitlab.com/ParveenBhadooOfficial/Google-Drive-Index Code). `Bool`
- `VIEW_LINK`: View Link button to open file Index Link in browser instead of direct download link, you can figure out if it's compatible with your Index code or not, open any video from you Index and check if its URL ends with `?a=view`, if yes make it `True` compatible with [BhadooIndex](https://gitlab.com/ParveenBhadooOfficial/Google-Drive-Index Code). `Bool`
- `UPTOBOX_TOKEN`: Uptobox token to mirror uptobox links. Get it from [Uptobox Premium Account](https://uptobox.com/my_account).
- `IGNORE_PENDING_REQUESTS`: If you want the bot to ignore pending requests after it restarts, set this to `True`. `Bool`
- `STATUS_LIMIT`: Limit the no. of tasks shown in status message with button. (**NOTE**: Recommended limit is `4` tasks).
- `IS_VPS`: (Only for VPS) Don't set this to `True` even if you are using VPS, unless facing error with web server. `Bool`
- `SERVER_PORT`: Only For VPS even if `IS_VPS` is `False` --> Base URL Port
- `SERVER_PORT`: Only For VPS even if `IS_VPS` is `False` --> Base URL Port.
- `TG_SPLIT_SIZE`: Size of split in bytes, leave it empty for max size `2GB`.
- `AS_DOCUMENT`: Default Telegram file type upload. Empty or `False` means as media. `Bool`
- `EQUAL_SPLITS`: Split files larger than **TG_SPLIT_SIZE** into equal parts size (Not working with zip cmd). `Bool`
- `CUSTOM_FILENAME`: Add custom word to leeched file name.
- `UPSTREAM_REPO`: Your github repository link, If your repo is private add `https://{githubtoken}@github.com/{username}/{reponame}` format. Get token from [Github settings](https://github.com/settings/tokens). (**NOTE**: Any change in docker or requirements you need to deploy again with updated repo to take effect)
- `UPSTREAM_REPO`: Your github repository link, If your repo is private add `https://{githubtoken}@github.com/{username}/{reponame}` format. Get token from [Github settings](https://github.com/settings/tokens). (**NOTE**: Any change in docker or requirements you need to deploy/build again with updated repo to take effect)
- `SHORTENER_API`: Fill your Shortener API key.
- `SHORTENER`: Shortener URL.
- Supported URL Shorteners:
@ -152,7 +153,7 @@ Fill up rest of the fields. Meaning of each field is discussed below:
- `SEARCH_API_LINK`: Search api app link. Get your api from deploying this [repository](https://github.com/Ryuk-me/Torrents-Api). **Note**: Don't add slash at the end.
- Supported Sites:
>rarbg, 1337x, yts, etzv, tgx, torlock, piratebay, nyaasi, ettv
- `PHPSESSID` and `CRYPT`: Cookies for gdtot google drive link generator. Check setup [here](https://github.com/anasty17/mirror-leech-telegram-bot/tree/master#Gdtot Cookies).
- `PHPSESSID` and `CRYPT`: Cookies for gdtot google drive link generator. Follow these [steps](https://github.com/anasty17/mirror-leech-telegram-bot/tree/master#Gdtot Cookies).
Three buttons are already added including Drive Link, Index Link, and View Link, you can add extra buttons, if you don't know what are the below entries, simply leave them empty.
- `BUTTON_FOUR_NAME`:
@ -268,35 +269,35 @@ sudo docker image prune -a
## Bot commands to be set in [@BotFather](https://t.me/BotFather)
```
mirror - Start mirroring
zipmirror - Start mirroring and upload as .zip
unzipmirror - Extract files
qbmirror - Start mirroring using qBittorrent
qbzipmirror - Start mirroring and upload as .zip using qb
qbunzipmirror - Extract files using qBittorrent
leech - Leech Torrent/Direct link
zipleech - Leech Torrent/Direct link and upload as .zip
unzipleech - Leech Torrent/Direct link and extract
qbleech - Leech Torrent/Magnet using qBittorrent
qbzipleech - Leech Torrent/Magnet and upload as .zip using qb
qbunzipleech - Leech Torrent and extract using qb
mirror - Mirror
zipmirror - Mirror and upload as zip
unzipmirror - Mirror and extract files
qbmirror - Mirror torrent using qBittorrent
qbzipmirror - Mirror torrent and upload as zip using qb
qbunzipmirror - Mirror torrent and extract files using qb
leech - Leech
zipleech - Leech and upload as zip
unzipleech - Leech and extract files
qbleech - Leech torrent using qBittorrent
qbzipleech - Leech torrent and upload as zip using qb
qbunzipleech - Leech torrent and extract using qb
clone - Copy file/folder to Drive
count - Count file/folder of Drive
watch - Mirror yt-dlp supported link
zipwatch - Mirror playlist link and upload as .zip
zipwatch - Mirror yt-dlp supported link as zip
leechwatch - Leech through yt-dlp supported link
leechzipwatch - Leech playlist link and upload as .zip
leechzipwatch - Leech yt-dlp support link as zip
leechset - Leech settings
setthumb - Set Thumbnail
setthumb - Set thumbnail
status - Get Mirror Status message
list - [query] Search files in Drive
search - [query] Search for torrents with API
list - Search files in Drive
search - Search for torrents with API
cancel - Cancel a task
cancelall - Cancel all tasks
del - [drive_url] Delete file from Drive
log - Get the Bot Log [owner/sudo only]
shell - Run commands in Shell [owner only]
restart - Restart the Bot [owner/sudo only]
del - Delete file/folder from Drive
log - Get the Bot Log
shell - Run commands in Shell
restart - Restart the Bot
stats - Bot Usage Stats
ping - Ping the Bot
help - All cmds with description

View File

@ -105,55 +105,55 @@ def log(update, context):
help_string_telegraph = f'''<br>
<b>/{BotCommands.HelpCommand}</b>: To get this message
<br><br>
<b>/{BotCommands.MirrorCommand}</b> [download_url][magnet_link]: Start mirroring the link to Google Drive.
<b>/{BotCommands.MirrorCommand}</b> [download_url][magnet_link]: Start mirroring to Google Drive. Send <b>/{BotCommands.MirrorCommand}</b> for more help
<br><br>
<b>/{BotCommands.ZipMirrorCommand}</b> [download_url][magnet_link]: Start mirroring and upload the archived (.zip) version of the download
<b>/{BotCommands.ZipMirrorCommand}</b> [download_url][magnet_link]: Start mirroring and upload the file/folder compressed with zip extension
<br><br>
<b>/{BotCommands.UnzipMirrorCommand}</b> [download_url][magnet_link]: Start mirroring and if downloaded file is any archive, extracts it to Google Drive
<b>/{BotCommands.UnzipMirrorCommand}</b> [download_url][magnet_link]: Start mirroring and upload the file/folder extracted from any archive extension
<br><br>
<b>/{BotCommands.QbMirrorCommand}</b> [magnet_link]: Start Mirroring using qBittorrent, Use <b>/{BotCommands.QbMirrorCommand} s</b> to select files before downloading
<b>/{BotCommands.QbMirrorCommand}</b> [magnet_link][torrent_file][torrent_file_url]: Start Mirroring using qBittorrent, Use <b>/{BotCommands.QbMirrorCommand} s</b> to select files before downloading
<br><br>
<b>/{BotCommands.QbZipMirrorCommand}</b> [magnet_link]: Start mirroring using qBittorrent and upload the archived (.zip) version of the download
<b>/{BotCommands.QbZipMirrorCommand}</b> [magnet_link][torrent_file][torrent_file_url]: Start mirroring using qBittorrent and upload the file/folder compressed with zip extension
<br><br>
<b>/{BotCommands.QbUnzipMirrorCommand}</b> [magnet_link]: Start mirroring using qBittorrent and if downloaded file is any archive, extracts it to Google Drive
<b>/{BotCommands.QbUnzipMirrorCommand}</b> [magnet_link][torrent_file][torrent_file_url]: Start mirroring using qBittorrent and upload the file/folder extracted from any archive extension
<br><br>
<b>/{BotCommands.LeechCommand}</b> [download_url][magnet_link]: Start leeching to Telegram, Use <b>/{BotCommands.LeechCommand} s</b> to select files before leeching
<br><br>
<b>/{BotCommands.ZipLeechCommand}</b> [download_url][magnet_link]: Start leeching to Telegram and upload it as (.zip)
<b>/{BotCommands.ZipLeechCommand}</b> [download_url][magnet_link]: Start leeching to Telegram and upload the file/folder compressed with zip extension
<br><br>
<b>/{BotCommands.UnzipLeechCommand}</b> [download_url][magnet_link]: Start leeching to Telegram and if downloaded file is any archive, extracts it to Telegram
<b>/{BotCommands.UnzipLeechCommand}</b> [download_url][magnet_link][torent_file]: Start leeching to Telegram and upload the file/folder extracted from any archive extension
<br><br>
<b>/{BotCommands.QbLeechCommand}</b> [magnet_link]: Start leeching to Telegram using qBittorrent, Use <b>/{BotCommands.QbLeechCommand} s</b> to select files before leeching
<b>/{BotCommands.QbLeechCommand}</b> [magnet_link][torrent_file][torrent_file_url]: Start leeching to Telegram using qBittorrent, Use <b>/{BotCommands.QbLeechCommand} s</b> to select files before leeching
<br><br>
<b>/{BotCommands.QbZipLeechCommand}</b> [magnet_link]: Start leeching to Telegram using qBittorrent and upload it as (.zip)
<b>/{BotCommands.QbZipLeechCommand}</b> [magnet_link][torrent_file][torrent_file_url]: Start leeching to Telegram using qBittorrent and upload the file/folder compressed with zip extension
<br><br>
<b>/{BotCommands.QbUnzipLeechCommand}</b> [magnet_link]: Start leeching to Telegram using qBittorrent and if downloaded file is any archive, extracts it to Telegram
<b>/{BotCommands.QbUnzipLeechCommand}</b> [magnet_link][torrent_file][torrent_file_url]: Start leeching to Telegram using qBittorrent and upload the file/folder extracted from any archive extension
<br><br>
<b>/{BotCommands.CloneCommand}</b> [drive_url]: Copy file/folder to Google Drive
<b>/{BotCommands.CloneCommand}</b> [drive_url][gdtot_url]: Copy file/folder to Google Drive
<br><br>
<b>/{BotCommands.CountCommand}</b> [drive_url]: Count file/folder of Google Drive Links
<b>/{BotCommands.CountCommand}</b> [drive_url][gdtot_url]: Count file/folder of Google Drive
<br><br>
<b>/{BotCommands.DeleteCommand}</b> [drive_url]: Delete file from Google Drive (Only Owner & Sudo)
<b>/{BotCommands.DeleteCommand}</b> [drive_url]: Delete file/folder from Google Drive (Only Owner & Sudo)
<br><br>
<b>/{BotCommands.WatchCommand}</b> [youtube-dl supported link]: Mirror through youtube-dl. Click <b>/{BotCommands.WatchCommand}</b> for more help
<b>/{BotCommands.WatchCommand}</b> [yt-dlp supported link]: Mirror yt-dlp supported link. Send <b>/{BotCommands.WatchCommand}</b> for more help
<br><br>
<b>/{BotCommands.ZipWatchCommand}</b> [youtube-dl supported link]: Mirror through youtube-dl and zip before uploading
<b>/{BotCommands.ZipWatchCommand}</b> [yt-dlp supported link]: Mirror yt-dlp supported link as zip
<br><br>
<b>/{BotCommands.LeechWatchCommand}</b> [youtube-dl supported link]: Leech through youtube-dl
<b>/{BotCommands.LeechWatchCommand}</b> [yt-dlp supported link]: Leech yt-dlp supported link
<br><br>
<b>/{BotCommands.LeechZipWatchCommand}</b> [youtube-dl supported link]: Leech through youtube-dl and zip before uploading
<b>/{BotCommands.LeechZipWatchCommand}</b> [yt-dlp supported link]: Leech yt-dlp supported link as zip
<br><br>
<b>/{BotCommands.LeechSetCommand}</b>: Leech Settings
<b>/{BotCommands.LeechSetCommand}</b>: Leech settings
<br><br>
<b>/{BotCommands.SetThumbCommand}</b>: Reply photo to set it as Thumbnail
<br><br>
<b>/{BotCommands.CancelMirror}</b>: Reply to the message by which the download was initiated and that download will be cancelled
<br><br>
<b>/{BotCommands.CancelAllCommand}</b>: Cancel all running tasks
<b>/{BotCommands.CancelAllCommand}</b>: Cancel all downloading tasks
<br><br>
<b>/{BotCommands.ListCommand}</b> [query]: Search in Google Drive
<b>/{BotCommands.ListCommand}</b> [query]: Search in Google Drive(s)
<br><br>
<b>/{BotCommands.SearchCommand}</b> [site](optional) [query]: Search for torrents with API
<b>/{BotCommands.SearchCommand}</b> [query]: Search for torrents with API
<br>sites: <code>rarbg, 1337x, yts, etzv, tgx, torlock, piratebay, nyaasi, ettv</code><br><br>
<b>/{BotCommands.StatusCommand}</b>: Shows a status of all the downloads
<br><br>
@ -195,33 +195,42 @@ def bot_help(update, context):
reply_markup = InlineKeyboardMarkup(button.build_menu(1))
sendMarkup(help_string, context.bot, update, reply_markup)
'''
botcmds = [
(f'{BotCommands.MirrorCommand}', 'Start Mirroring'),
(f'{BotCommands.ZipMirrorCommand}','Start mirroring and upload as .zip'),
(f'{BotCommands.UnzipMirrorCommand}','Extract files'),
(f'{BotCommands.QbMirrorCommand}','Start Mirroring using qBittorrent'),
(f'{BotCommands.QbZipMirrorCommand}','Start mirroring and upload as .zip using qb'),
(f'{BotCommands.QbUnzipMirrorCommand}','Extract files using qBitorrent'),
(f'{BotCommands.MirrorCommand}', 'Mirror'),
(f'{BotCommands.ZipMirrorCommand}','Mirror and upload as zip'),
(f'{BotCommands.UnzipMirrorCommand}','Mirror and extract files'),
(f'{BotCommands.QbMirrorCommand}','Mirror torrent using qBittorrent'),
(f'{BotCommands.QbZipMirrorCommand}','Mirror torrent and upload as zip using qb'),
(f'{BotCommands.QbUnzipMirrorCommand}','Mirror torrent and extract files using qb'),
(f'{BotCommands.WatchCommand}','Mirror yt-dlp supported link'),
(f'{BotCommands.ZipWatchCommand}','Mirror yt-dlp supported link as zip'),
(f'{BotCommands.CloneCommand}','Copy file/folder to Drive'),
(f'{BotCommands.CountCommand}','Count file/folder of Drive link'),
(f'{BotCommands.DeleteCommand}','Delete file from Drive'),
(f'{BotCommands.WatchCommand}','Mirror Youtube-dl support link'),
(f'{BotCommands.ZipWatchCommand}','Mirror Youtube playlist link as .zip'),
(f'{BotCommands.LeechCommand}','Leech'),
(f'{BotCommands.ZipLeechCommand}','Leech and upload as zip'),
(f'{BotCommands.UnzipLeechCommand}','Leech and extract files'),
(f'{BotCommands.QbLeechCommand}','Leech torrent using qBittorrent'),
(f'{BotCommands.QbZipLeechCommand}','Leech torrent and upload as zip using qb'),
(f'{BotCommands.QbUnzipLeechCommand}','Leech torrent and extract using qb'),
(f'{BotCommands.LeechWatchCommand}','Leech yt-dlp supported link'),
(f'{BotCommands.LeechZipWatchCommand}','Leech yt-dlp supported link as zip'),
(f'{BotCommands.CountCommand}','Count file/folder of Drive'),
(f'{BotCommands.DeleteCommand}','Delete file/folder from Drive'),
(f'{BotCommands.CancelMirror}','Cancel a task'),
(f'{BotCommands.CancelAllCommand}','Cancel all tasks'),
(f'{BotCommands.ListCommand}','Searches files in Drive'),
(f'{BotCommands.StatusCommand}','Get Mirror Status message'),
(f'{BotCommands.StatsCommand}','Bot Usage Stats'),
(f'{BotCommands.PingCommand}','Ping the Bot'),
(f'{BotCommands.RestartCommand}','Restart the bot [owner/sudo only]'),
(f'{BotCommands.LogCommand}','Get the Bot Log [owner/sudo only]'),
(f'{BotCommands.HelpCommand}','Get Detailed Help')
(f'{BotCommands.CancelAllCommand}','Cancel all downloading tasks'),
(f'{BotCommands.ListCommand}','Search in Drive'),
(f'{BotCommands.LeechSetCommand}','Leech settings'),
(f'{BotCommands.SetThumbCommand}','Set thumbnail'),
(f'{BotCommands.StatusCommand}','Get mirror status message'),
(f'{BotCommands.StatsCommand}','Bot usage stats'),
(f'{BotCommands.PingCommand}','Ping the bot'),
(f'{BotCommands.RestartCommand}','Restart the bot'),
(f'{BotCommands.LogCommand}','Get the bot Log'),
(f'{BotCommands.HelpCommand}','Get detailed help')
]
'''
def main():
# bot.set_my_commands(botcmds)
fs_utils.start_cleanup()
if IS_VPS:
asyncio.new_event_loop().run_until_complete(start_server_async(PORT))
@ -240,7 +249,7 @@ def main():
bot.sendMessage(chat_id=i, text=text, parse_mode=ParseMode.HTML)
except Exception as e:
LOGGER.warning(e)
# bot.set_my_commands(botcmds)
start_handler = CommandHandler(BotCommands.StartCommand, start, run_async=True)
ping_handler = CommandHandler(BotCommands.PingCommand, ping,
filters=CustomFilters.authorized_chat | CustomFilters.authorized_user, run_async=True)

View File

@ -390,7 +390,8 @@ def _mirror(bot, update, isZip=False, extract=False, isQbit=False, isLeech=False
help_msg = "Send link along with command line or by reply\n"
help_msg += "<b>Examples:</b> \n<code>/command</code> link |newname(TG files or Direct inks) pswd: mypassword(zip/unzip)"
help_msg += "\nBy replying to link: <code>/command</code> |newname(TG files or Direct inks) pswd: mypassword(zip/unzip)"
help_msg += "\nFor Direct Links Authorization: <code>/command</code> link |newname pswd: mypassword\nusername\npassword (Same with by reply)"
help_msg += "\nFor Direct Links Authorization: <code>/command</code> link |newname pswd: mypassword\nusername\npassword (Same by replying to link)"
help_msg += "\nFor Selection: <code>/qbcommand</code> s link (Same by replying to link)"
return sendMessage(help_msg, bot, update)
elif bot_utils.is_url(link) and not bot_utils.is_magnet(link) and not os.path.exists(link) and isQbit:
try: