diff --git a/README.md b/README.md
index 6cd20413a9..8fac249ffc 100644
--- a/README.md
+++ b/README.md
@@ -620,6 +620,7 @@ help - All cmds with description
M/L Buttons
- `SHOW_MEDIAINFO`: Mediainfo button of file. Default is `False`. `Bool`
+ - `SCREENSHOTS_MODE`: Enable or Diable generating Screenshots via -ss arg. Default is `False`. `Bool`
- `SAVE_MSG`: Save Button in each file and link so that every user direcly save it without forwarding. Default is `False`. `Bool`
- `SOURCE_LINK`: Source button of files and links. Default is `False`. `Bool`
diff --git a/bot/__init__.py b/bot/__init__.py
index 076fd005c2..f1e9ce4a7f 100644
--- a/bot/__init__.py
+++ b/bot/__init__.py
@@ -192,6 +192,21 @@ def changetz(*args):
x = x.lstrip('.')
GLOBAL_EXTENSION_FILTER.append(x.strip().lower())
+LINKS_LOG_ID = environ.get('LINKS_LOG_ID', '')
+LINKS_LOG_ID = '' if len(LINKS_LOG_ID) == 0 else int(LINKS_LOG_ID)
+
+MIRROR_LOG_ID = environ.get('MIRROR_LOG_ID', '')
+if len(MIRROR_LOG_ID) == 0:
+ MIRROR_LOG_ID = ''
+
+LEECH_LOG_ID = environ.get('LEECH_LOG_ID', '')
+if len(LEECH_LOG_ID) == 0:
+ LEECH_LOG_ID = ''
+
+EXCEP_CHATS = environ.get('EXCEP_CHATS', '')
+if len(EXCEP_CHATS) == 0:
+ EXCEP_CHATS = ''
+
IS_PREMIUM_USER = False
user = ''
USER_SESSION_STRING = environ.get('USER_SESSION_STRING', '')
@@ -354,6 +369,9 @@ def changetz(*args):
SHOW_MEDIAINFO = environ.get('SHOW_MEDIAINFO', '')
SHOW_MEDIAINFO = SHOW_MEDIAINFO.lower() == 'true'
+SCREENSHOTS_MODE = environ.get('SCREENSHOTS_MODE', '')
+SCREENSHOTS_MODE = SCREENSHOTS_MODE.lower() == 'true'
+
SOURCE_LINK = environ.get('SOURCE_LINK', '')
SOURCE_LINK = SOURCE_LINK.lower() == 'true'
@@ -437,21 +455,6 @@ def changetz(*args):
FSUB_IDS = environ.get('FSUB_IDS', '')
if len(FSUB_IDS) == 0:
FSUB_IDS = ''
-
-LINKS_LOG_ID = environ.get('LINKS_LOG_ID', '')
-LINKS_LOG_ID = '' if len(LINKS_LOG_ID) == 0 else int(LINKS_LOG_ID)
-
-MIRROR_LOG_ID = environ.get('MIRROR_LOG_ID', '')
-if len(MIRROR_LOG_ID) == 0:
- MIRROR_LOG_ID = ''
-
-LEECH_LOG_ID = environ.get('LEECH_LOG_ID', '')
-if len(LEECH_LOG_ID) == 0:
- LEECH_LOG_ID = ''
-
-EXCEP_CHATS = environ.get('EXCEP_CHATS', '')
-if len(EXCEP_CHATS) == 0:
- EXCEP_CHATS = ''
BOT_PM = environ.get('BOT_PM', '')
BOT_PM = BOT_PM.lower() == 'true'
@@ -671,6 +674,7 @@ def changetz(*args):
'SEARCH_PLUGINS': SEARCH_PLUGINS,
'SET_COMMANDS': SET_COMMANDS,
'SHOW_MEDIAINFO': SHOW_MEDIAINFO,
+ 'SCREENSHOTS_MODE': SCREENSHOTS_MODE,
'CLEAN_LOG_MSG': CLEAN_LOG_MSG,
'SHOW_EXTRA_CMDS': SHOW_EXTRA_CMDS,
'SOURCE_LINK': SOURCE_LINK,
diff --git a/bot/__main__.py b/bot/__main__.py
index 296e13828a..f862b3e67b 100644
--- a/bot/__main__.py
+++ b/bot/__main__.py
@@ -14,6 +14,7 @@
from aiofiles.os import path as aiopath, remove as aioremove
from aiofiles import open as aiopen
from pyrogram import idle
+from pyrogram.enums import ChatMemberStatus, ChatType
from pyrogram.handlers import MessageHandler, CallbackQueryHandler
from pyrogram.filters import command, private, regex
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton
@@ -211,8 +212,34 @@ async def send_incompelete_task_message(cid, msg):
await aioremove(".restartmsg")
+async def log_check():
+ if config_dict['LEECH_LOG_ID']:
+ for chat_id in config_dict['LEECH_LOG_ID'].split():
+ chat_id, *topic_id = chat_id.split(":")
+ try:
+ chat = await bot.get_chat(int(chat_id))
+ except Exception:
+ LOGGER.error(f"Not Connected Chat ID : {chat_id}, Make sure the Bot is Added!")
+ continue
+ if chat.type == ChatType.CHANNEL:
+ if not (await chat.get_member(bot.me.id)).privileges.can_post_messages:
+ LOGGER.error(f"Not Connected Chat ID : {chat_id}, Make the Bot is Admin in Channel to Connect!")
+ continue
+ if user and not (await chat.get_member(user.me.id)).privileges.can_post_messages:
+ LOGGER.error(f"Not Connected Chat ID : {chat_id}, Make the User is Admin in Channel to Connect!")
+ continue
+ elif chat.type == ChatType.SUPERGROUP:
+ if not (await chat.get_member(bot.me.id)).status in [ChatMemberStatus.OWNER, ChatMemberStatus.ADMINISTRATOR]:
+ LOGGER.error(f"Not Connected Chat ID : {chat_id}, Make the Bot is Admin in Group to Connect!")
+ continue
+ if user and not (await chat.get_member(user.me.id)).status in [ChatMemberStatus.OWNER, ChatMemberStatus.ADMINISTRATOR]:
+ LOGGER.error(f"Not Connected Chat ID : {chat_id}, Make the User is Admin in Group to Connect!")
+ continue
+ LOGGER.info(f"Connected Chat ID : {chat_id}")
+
+
async def main():
- await gather(start_cleanup(), torrent_search.initiate_search_tools(), restart_notification(), search_images(), set_commands(bot))
+ await gather(start_cleanup(), torrent_search.initiate_search_tools(), restart_notification(), search_images(), set_commands(bot), log_check())
await sync_to_async(start_aria2_listener, wait=False)
bot.add_handler(MessageHandler(
@@ -233,7 +260,7 @@ async def main():
BotCommands.StatsCommand) & CustomFilters.authorized & ~CustomFilters.blacklisted))
LOGGER.info(f"WZML-X Bot [@{bot_name}] Started!")
if user:
- LOGGER.info(f"WZ's User [@{user.me.first_name}] Ready!")
+ LOGGER.info(f"WZ's User [@{user.me.username}] Ready!")
signal(SIGINT, exit_clean_up)
async def stop_signals():
diff --git a/bot/helper/ext_utils/help_messages.py b/bot/helper/ext_utils/help_messages.py
index 2632cee10b..1090fe25e7 100644
--- a/bot/helper/ext_utils/help_messages.py
+++ b/bot/helper/ext_utils/help_messages.py
@@ -18,6 +18,8 @@
11. -index: Index url for gdrive_arg
12. -c or -category : Gdrive category to Upload, Specific Name (case insensitive)
13. -ud or -dump : Dump category to Upload, Specific Name (case insensitive) or chat_id or chat_username
+14. -ss or -screenshots : Generate Screenshots for Leeched Files
+15. -t or -thumb : Custom Thumb for Specific Leech
""", """
➲ Send link along with command line:
/cmd
link -s -n new name -opt x:y|x1:y1
@@ -29,6 +31,14 @@
/cmd
link -n new name
Note: Don't add file extension
+➲ Screenshot Generation: -ss or -screenshots
+/cmd
link -ss number ,Screenshots for each Video File
+
+➲ Custom Thumbnail: -t or -thumb
+/cmd
link -t tglink|dl_link
+Direct Link: dl_link specifies download link, where it is Image url
+Tg Link: Give Public/Private/Super Link to download Image from Tg
+
➲ Quality Buttons: -s or -select
Incase default quality 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
@@ -119,7 +129,8 @@
17. -index: Index url for gdrive_arg
18. -c or -category : Gdrive category to Upload, Specific Name (case insensitive)
19. -ud or -dump : Dump category to Upload, Specific Name (case insensitive) or chat_id or chat_username
-20. -ss or -screenshots : Generate Screenshots for Leeched Files, Specify 1, 3, .. after this.
+20. -ss or -screenshots : Generate Screenshots for Leeched Files
+21. -t or -thumb : Custom Thumb for Specific Leech
""", """
➲ By along the cmd:
/cmd
link -n new name
@@ -134,12 +145,17 @@
➲ Direct Link Authorization: -u -p or -user -pass
/cmd
link -u username -p password
-➲ Direct link custom headers: -h or -headers
+➲ Direct link custom headers: -h or -headers
/cmd
link -h key: value key1: value1
-➲ Screenshot Generation: -ss or -screenshots
+➲ Screenshot Generation: -ss or -screenshots
/cmd
link -ss number ,Screenshots for each Video File
+➲ Custom Thumbnail: -t or -thumb
+/cmd
link -t tglink|dl_link
+Direct Link: dl_link specifies download link, where it is Image url
+Tg Link: Give Public/Private/Super Link to download Image from Tg
+
➲ Extract / Zip: -uz -z or -zip -unzip or -e -extract
/cmd
link -e password (extract password protected)
/cmd
link -z password (zip password protected)
@@ -418,6 +434,8 @@
'AUTO_DELETE_MESSAGE_DURATION': "Interval of time (in seconds), after which the bot deletes it's message and command message which is expected to be viewed instantly.\n\n NOTE: Set to -1 to disable auto message deletion.",
'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',
+ 'BLACKLIST_USERS': 'Restrict User from Using the Bot. It will Display a BlackListed Msg. USER_ID separated by space. Str',
+ 'BOT_MAX_TASKS': 'Maximum number of Task Bot will Run parallel. (Queue Tasks Included). Int',
'STORAGE_THRESHOLD': 'To leave specific storage free and any download will lead to leave free storage less than this value will be cancelled the default unit is GB. Int',
'LEECH_LIMIT': 'To limit the Torrent/Direct/ytdlp leech size. the default unit is GB. Int',
'CLONE_LIMIT': 'To limit the size of Google Drive folder/file which you can clone. the default unit is GB. Int',
@@ -430,11 +448,17 @@
'IMG_SEARCH': 'Put Keyword to Download Images. Sperarte each name by , like anime, iron man, god of war',
'IMG_PAGE': 'Set the page value for downloading a image. Each page have approx 70 images. Deafult is 1. Int',
'IMDB_TEMPLATE': 'Set Bot Default IMDB Template. HTML Tags, Emojis supported. str',
- 'AUTHOR_NAME': 'Author name for Telegraph pages',
- 'AUTHOR_URL': 'Author URL for Telegraph page',
+ 'AUTHOR_NAME': 'Author name for Telegraph pages, Shown in Telegraph Page as by AUTHOR_NAME',
+ 'AUTHOR_URL': 'Author URL for Telegraph page, Put Channel URL to Show Join Channel. Str',
+ 'COVER_IMAGE': 'Cover Image for Telegraph Page. Put Telegraph Photo Link',
'TITLE_NAME': 'Title name for Telegraph pages (while using /list command)',
'GD_INFO': 'Description of file uploaded to gdrive using bot',
- 'BOT_THEME': 'Change the theme of bot. For now theme availabe is minimal. You can make your own theme checkout this link https://t.ly/9rVXq',
+ 'DELETE_LINKS': 'Delete TgLink/Magnet/File on Start of Task to Auto Clean Group. Default is False',
+ 'EXCEP_CHATS': 'Exception Chats which will not use Logging, chat_id separated by space. Str',
+ 'SAFE_MODE': 'Hide Task Name, Source Link and Indexing of Leech Link for Safety Precautions. Default is False',
+ 'SOURCE_LINK': 'Add a Extra Button of Source Link whether it is Magnet Link or File Link or DL Link. Default is False',
+ 'SHOW_EXTRA_CMDS': 'Add Extra Commands beside Arg Format for -z or -e. \n\nCOMMANDS: /unzipxxx or /zipxxx or /uzx or /zx',
+ 'BOT_THEME': 'Theme of the Bot to Switch. For now Deafault Theme Availabe is minimal. You can make your own Theme and Add in BSet. \n\nSample Format: https://t.ly/9rVXq',
'USER_MAX_TASKS': 'Limit the Maximum task for users of group at a time. use the Int',
'DAILY_TASK_LIMIT': 'Maximum task a user can do in one day. use the Int',
'DISABLE_DRIVE_LINK': 'Disable drive link button. Default is False. Bool',
@@ -445,11 +469,12 @@
'FSUB_IDS': 'Fill chat_id(-100xxxxxx) of groups/channel you want to force subscribe. Separate them by space. Int\n\nNote: Bot should be added in the filled chat_id as admin',
'BOT_PM': 'File/links send to the BOT PM also. Default is False',
'BOT_TOKEN': 'The Telegram Bot Token that you got from @BotFather',
- 'CMD_SUFFIX': 'commands index number. This number will added at the end all commands.',
+ 'CMD_SUFFIX': 'Telegram Bot Command Index number or Custom Text. This will added at the end all commands except Global Commands. Str',
'DATABASE_URL': "Your Mongo Database URL (Connection string). Follow this 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.\n\n NOTE: You can always edit all settings that saved in database from the official site -> (Browse collections)",
'DEFAULT_UPLOAD': 'Whether rc to upload to RCLONE_PATH or gd to upload to GDRIVE_ID or ddl to upload to DDLserver. Default is gd.',
'DOWNLOAD_DIR': 'The path to the local folder where the downloads should be downloaded to. ',
'MDL_TEMPLATE': 'Set Bot Custom Default MyDramaList Template. HTML Tags, Emojis Supported',
+ 'CLEAN_LOG_MSG': 'Clean Leech Log & Bot PM Task Start Message. Default is False',
'LEECH_LOG_ID': "Chat ID to where leeched files would be uploaded. Int. NOTE: Only available for superGroup/channel. Add -100 before channel/superGroup id. In short don't add bot id or your id!",
'MIRROR_LOG_ID': "Chat ID to where Mirror files would be Send. Int. NOTE: Only available for superGroup/channel. Add -100 before channel/superGroup id. In short don't add bot id or your id!. For Multiple id Separate them by space.",
'EQUAL_SPLITS': 'Split files larger than LEECH_SPLIT_SIZE into equal parts size (Not working with zip cmd). Default is False.',
@@ -459,6 +484,7 @@
'INDEX_URL': 'Refer to https://gitlab.com/ParveenBhadooOfficial/Google-Drive-Index.',
'IS_TEAM_DRIVE': 'Set True if uploading to TeamDrive using google-api-python-client. Default is False',
'SHOW_MEDIAINFO': 'Add Button to Show MediaInfo in Leeched file. Bool',
+ 'SCREENSHOTS_MODE': 'Enable or Diable generating Screenshots via -ss arg. Default is False. Bool',
'CAP_FONT': 'Add Custom Caption Font to Leeched Files, Available Values : b, i, u, s, code, spoiler. Reset Var to use Regular ( No Format )',
'LEECH_FILENAME_PREFIX': 'Add custom word prefix to leeched file name. Str',
'LEECH_FILENAME_SUFFIX': 'Add custom word suffix to leeched file name. Str',
@@ -500,6 +526,8 @@
'UPGRADE_PACKAGES': 'Install New Requirements File without thinking of Crash. Bool',
'SAVE_MSG': 'Add button of save message. Bool',
'SET_COMMANDS': 'Set bot command automatically. Bool',
+ 'USER_TD_MODE': 'Enable User GDrive TD to Use. Default is False',
+ 'USER_TD_SA': 'Add Global SA mail for User to give Permissions to Bot for UserTD Upload. Like wzmlx@googlegroups.com. Str',
'UPTOBOX_TOKEN': 'Uptobox token to mirror uptobox links. Get it from Uptobox Premium Account.',
'USER_SESSION_STRING': "To download/upload from your telegram account and to send rss. To generate session string use this command python3 generate_string_session.py
after mounting repo folder for sure.\n\nNOTE: You can't use bot with private message. Use it with superGroup.",
'USE_SERVICE_ACCOUNTS': 'Whether to use Service Accounts or not, with google-api-python-client. For this to work see Using Service Accounts section below. Default is False',
diff --git a/bot/helper/ext_utils/leech_utils.py b/bot/helper/ext_utils/leech_utils.py
index 1a2253dbf4..5ae048e3c7 100644
--- a/bot/helper/ext_utils/leech_utils.py
+++ b/bot/helper/ext_utils/leech_utils.py
@@ -61,13 +61,16 @@ async def get_media_info(path, metadata=False):
artist = tags.get('artist') or tags.get('ARTIST') or tags.get("Artist")
title = tags.get('title') or tags.get('TITLE') or tags.get("Title")
if metadata:
- lang, qual = "", ""
+ lang, qual, stitles = "", "", ""
if (streams := ffresult.get('streams')) and streams[0].get('codec_type') == 'video':
- qual = f"{streams[0].get('height')}p"
+ qual = streams[0].get('height')
+ qual = f"{480 if qual <= 480 else 540 if qual <= 540 else 720 if qual <= 720 else 1080 if qual <= 1080 else 2160 if qual <= 2160 else 4320 if qual <= 4320 else 8640}p"
for stream in streams:
if stream.get('codec_type') == 'audio' and (lc := stream.get('tags', {}).get('language')):
lang += Language.get(lc).display_name() + ", "
- return duration, qual, lang[:-2]
+ if stream.get('codec_type') == 'subtitle' and (st := stream.get('tags', {}).get('language')):
+ stitles += Language.get(st).display_name() + ", "
+ return duration, qual, lang[:-2], stitles[:-2]
return duration, artist, title
@@ -140,6 +143,7 @@ async def take_ss(video_file, duration=None, total=1, gen_ss=False):
if await task.wait() != 0 or not await aiopath.exists(ospath.join(des_dir, f"wz_thumb_{eq_thumb}.jpg")):
err = (await task.stderr.read()).decode().strip()
LOGGER.error(f'Error while extracting thumbnail no. {eq_thumb} from video. Name: {video_file} stderr: {err}')
+ await aiormtree(des_dir)
return None
return (des_dir, tstamps) if gen_ss else ospath.join(des_dir, "wz_thumb_1.jpg")
@@ -284,13 +288,14 @@ async def format_filename(file_, user_id, dirpath=None, isMirror=False):
lcaption = lcaption.replace('\|', '%%').replace('\s', ' ')
slit = lcaption.split("|")
up_path = ospath.join(dirpath, prefile_)
- dur, qual, lang = await get_media_info(up_path, True)
+ dur, qual, lang, subs = await get_media_info(up_path, True)
cap_mono = slit[0].format(
filename = nfile_,
size = get_readable_file_size(await aiopath.getsize(up_path)),
duration = get_readable_time(dur),
quality = qual,
languages = lang,
+ subtitles = subs,
md5_hash = get_md5_hash(up_path)
)
if len(slit) > 1:
diff --git a/bot/helper/ext_utils/task_manager.py b/bot/helper/ext_utils/task_manager.py
index 5cfbe022e4..ae3b28908e 100644
--- a/bot/helper/ext_utils/task_manager.py
+++ b/bot/helper/ext_utils/task_manager.py
@@ -219,7 +219,7 @@ async def task_utils(message):
if _msg:
msg.append(_msg)
user_dict = user_data.get(user_id, {})
- if config_dict['BOT_PM'] or user_dict.get('bot_pm'):
+ if config_dict['BOT_PM'] or user_dict.get('bot_pm') or config_dict['SAFE_MODE']:
_msg, button = await check_botpm(message, button)
if _msg:
msg.append(_msg)
diff --git a/bot/helper/listeners/tasks_listener.py b/bot/helper/listeners/tasks_listener.py
index 3d5613dfe9..10db50be41 100644
--- a/bot/helper/listeners/tasks_listener.py
+++ b/bot/helper/listeners/tasks_listener.py
@@ -463,10 +463,7 @@ async def onUploadComplete(self, link, size, files, folders, mime_type, name, rc
if config_dict['SAVE_MSG'] and not saved and self.isSuperGroup:
saved = True
buttons.ibutton(BotTheme('SAVE_MSG'), 'save', 'footer')
- if self.isPM:
- await sendMessage(self.message, message, buttons.build_menu(2), photo=self.random_pic)
- else:
- await sendMessage(self.message, message + BotTheme('L_PM_WARN'), buttons.build_menu(2), photo=self.random_pic)
+ await sendMessage(self.message, message, buttons.build_menu(2), photo=self.random_pic)
else:
await sendMessage(self.message, message + fmsg, buttons.build_menu(2), photo=self.random_pic)
else:
@@ -484,10 +481,7 @@ async def onUploadComplete(self, link, size, files, folders, mime_type, name, rc
if config_dict['SAVE_MSG'] and not saved and self.isSuperGroup:
saved = True
buttons.ibutton(BotTheme('SAVE_MSG'), 'save', 'footer')
- if self.isPM:
- await sendMessage(self.message, message, buttons.build_menu(2), photo=self.random_pic)
- else:
- await sendMessage(self.message, message + BotTheme('L_PM_WARN'), buttons.build_menu(2), photo=self.random_pic)
+ await sendMessage(self.message, message, buttons.build_menu(2), photo=self.random_pic)
else:
await sendMessage(self.message, message + fmsg, buttons.build_menu(2), photo=self.random_pic)
else:
diff --git a/bot/helper/mirror_utils/download_utils/direct_link_generator.py b/bot/helper/mirror_utils/download_utils/direct_link_generator.py
index 90bf237df7..098337db10 100644
--- a/bot/helper/mirror_utils/download_utils/direct_link_generator.py
+++ b/bot/helper/mirror_utils/download_utils/direct_link_generator.py
@@ -331,6 +331,8 @@ def mediafire(url, session=None):
return final_link[0]
if session is None:
session = Session()
+ parsed_url = urlparse(url)
+ url = f'{parsed_url.scheme}://{parsed_url.netloc}{parsed_url.path}'
try:
html = HTML(session.get(url).text)
except Exception as e:
@@ -1162,6 +1164,7 @@ def doods(url):
with create_scraper() as session:
try:
_res = session.get(url)
+ _res = session.get(_res.url)
html = HTML(_res.text)
except Exception as e:
raise DirectDownloadLinkException(f'ERROR: {e.__class__.__name__} While fetching token link') from e
@@ -1258,4 +1261,4 @@ def filelions(url):
elif version['name'] == "h":
error += f"\nHD"
error +=f" {url}_{version['name']}
"
- raise DirectDownloadLinkException(f'ERROR: {error}')
\ No newline at end of file
+ raise DirectDownloadLinkException(f'ERROR: {error}')
diff --git a/bot/helper/mirror_utils/upload_utils/pyrogramEngine.py b/bot/helper/mirror_utils/upload_utils/pyrogramEngine.py
index 79da4e0e1d..ce41aa71b8 100644
--- a/bot/helper/mirror_utils/upload_utils/pyrogramEngine.py
+++ b/bot/helper/mirror_utils/upload_utils/pyrogramEngine.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
from traceback import format_exc
from logging import getLogger, ERROR
-from aiofiles.os import remove as aioremove, path as aiopath, rename as aiorename, makedirs, rmdir
+from aiofiles.os import remove as aioremove, path as aiopath, rename as aiorename, makedirs, rmdir, mkdir
from os import walk, path as ospath
from time import time
from PIL import Image
@@ -16,9 +16,9 @@
from bot import config_dict, user_data, GLOBAL_EXTENSION_FILTER, bot, user, IS_PREMIUM_USER
from bot.helper.themes import BotTheme
from bot.helper.telegram_helper.button_build import ButtonMaker
-from bot.helper.telegram_helper.message_utils import sendCustomMsg, editReplyMarkup, sendMultiMessage, chat_info, deleteMessage
+from bot.helper.telegram_helper.message_utils import sendCustomMsg, editReplyMarkup, sendMultiMessage, chat_info, deleteMessage, get_tg_link_content
from bot.helper.ext_utils.fs_utils import clean_unwanted, is_archive, get_base_name
-from bot.helper.ext_utils.bot_utils import get_readable_file_size, sync_to_async
+from bot.helper.ext_utils.bot_utils import get_readable_file_size, is_telegram_link, is_url, sync_to_async, download_image_url
from bot.helper.ext_utils.leech_utils import get_audio_thumb, get_media_info, get_document_type, take_ss, get_ss, get_mediainfo_link, format_filename
LOGGER = getLogger(__name__)
@@ -56,11 +56,38 @@ def __init__(self, name=None, path=None, listener=None):
self.__user_id = listener.message.from_user.id
self.__leechmsg = {}
self.__leech_utils = self.__listener.leech_utils
+
+ async def get_custom_thumb(self, thumb):
+ if is_telegram_link(thumb):
+ try:
+ msg, client = await get_tg_link_content(thumb)
+ except Exception as e:
+ LOGGER.error(f"Thumb Access Error: {e}")
+ return None
+ if msg and not msg.photo:
+ LOGGER.error("Thumb TgLink Invalid: Provide Link to Photo Only !")
+ return None
+ _client = bot if client == 'bot' else user
+ photo_dir = await _client.download_media(msg)
+ elif is_url(thumb):
+ photo_dir = await download_image_url(thumb)
+ else:
+ LOGGER.error("Custom Thumb Invalid")
+ return None
+ if await aiopath.exists(photo_dir):
+ path = "Thumbnails"
+ if not await aiopath.isdir(path):
+ await mkdir(path)
+ des_dir = ospath.join(path, f'{time()}.jpg')
+ await sync_to_async(Image.open(photo_dir).convert("RGB").save, des_dir, "JPEG")
+ await aioremove(photo_dir)
+ return des_dir
+ return None
async def __buttons(self, up_path, is_video=False):
buttons = ButtonMaker()
try:
- if is_video and bool(self.__leech_utils['screenshots']):
+ if config_dict['SCREENSHOTS_MODE'] and is_video and bool(self.__leech_utils['screenshots']):
buttons.ubutton(BotTheme('SCREENSHOTS'), await get_ss(up_path, self.__leech_utils['screenshots']))
except Exception as e:
LOGGER.error(f"ScreenShots Error: {e}")
@@ -82,7 +109,7 @@ async def __copy_file(self):
chat_id=self.__user_id,
from_chat_id=self.__sent_msg.chat.id,
message_id=self.__sent_msg.id,
- reply_to_message_id=self.__listener.botpmmsg.id
+ reply_to_message_id=self.__listener.botpmmsg.id if self.__listener.botpmmsg else None
)
if copied and self.__has_buttons:
btn_markup = InlineKeyboardMarkup(BTN) if (BTN := self.__sent_msg.reply_markup.inline_keyboard[:-1]) else None
@@ -350,6 +377,9 @@ async def __upload_file(self, cap_mono, file, force_document=False):
try:
is_video, is_audio, is_image = await get_document_type(self.__up_path)
+ if self.__leech_utils['thumb']:
+ thumb = await self.get_custom_thumb(self.__leech_utils['thumb'])
+
if not is_image and thumb is None:
file_name = ospath.splitext(file)[0]
thumb_path = f"{self.__path}/yt-dlp-thumb/{file_name}.jpg"
diff --git a/bot/helper/themes/wzml_minimal.py b/bot/helper/themes/wzml_minimal.py
index db84d929fd..cf94b7edbb 100644
--- a/bot/helper/themes/wzml_minimal.py
+++ b/bot/helper/themes/wzml_minimal.py
@@ -148,7 +148,6 @@ class WZMLStyle:
PM_BOT_MSG = '➲ File(s) have been Sent above'
L_BOT_MSG = '➲ File(s) have been Sent to Bot PM (Private)'
L_LL_MSG = '➲ File(s) have been Sent. Access via Links...\n'
- L_PM_WARN = '➲ BOT PM is Off turn it ON to get the Leech Index Link'
# ----- MIRROR -------
M_TYPE = '┠ Type: {Mimetype}\n'
@@ -157,7 +156,6 @@ class WZMLStyle:
RCPATH = '┠ Path: {RCpath}
\n'
M_CC = '┖ By: {Tag}\n\n'
M_BOT_MSG = '➲ Link(s) have been Sent to Bot PM (Private)'
- M_PM_WARN = '➲ BOT PM is Off turn it ON to get the Mirror Link'
# ----- BUTTONS -------
CLOUD_LINK = '☁️ Cloud Link'
SAVE_MSG = '📨 Save Message'
diff --git a/bot/modules/bot_settings.py b/bot/modules/bot_settings.py
index 6ba243e031..924a5859b6 100644
--- a/bot/modules/bot_settings.py
+++ b/bot/modules/bot_settings.py
@@ -49,7 +49,7 @@
}
bool_vars = ['AS_DOCUMENT', 'BOT_PM', 'STOP_DUPLICATE', 'SET_COMMANDS', 'SAVE_MSG', 'SHOW_MEDIAINFO', 'SOURCE_LINK', 'SAFE_MODE', 'SHOW_EXTRA_CMDS',
'IS_TEAM_DRIVE', 'USE_SERVICE_ACCOUNTS', 'WEB_PINCODE', 'EQUAL_SPLITS', 'DISABLE_DRIVE_LINK', 'DELETE_LINKS', 'CLEAN_LOG_MSG', 'USER_TD_MODE',
- 'INCOMPLETE_TASK_NOTIFIER', 'UPGRADE_PACKAGES']
+ 'INCOMPLETE_TASK_NOTIFIER', 'UPGRADE_PACKAGES', 'SCREENSHOTS_MODE']
async def load_config():
@@ -307,6 +307,9 @@ async def load_config():
SHOW_MEDIAINFO = environ.get('SHOW_MEDIAINFO', '')
SHOW_MEDIAINFO = SHOW_MEDIAINFO.lower() == 'true'
+ SHOW_MEDIAINFO = environ.get('SHOW_MEDIAINFO', '')
+ SHOW_MEDIAINFO = SHOW_MEDIAINFO.lower() == 'true'
+
SOURCE_LINK = environ.get('SOURCE_LINK', '')
SOURCE_LINK = SOURCE_LINK.lower() == 'true'
@@ -668,6 +671,7 @@ async def load_config():
'SEARCH_PLUGINS': SEARCH_PLUGINS,
'SET_COMMANDS': SET_COMMANDS,
'SHOW_MEDIAINFO': SHOW_MEDIAINFO,
+ 'SCREENSHOTS_MODE': SCREENSHOTS_MODE,
'CLEAN_LOG_MSG': CLEAN_LOG_MSG,
'SHOW_EXTRA_CMDS': SHOW_EXTRA_CMDS,
'SOURCE_LINK': SOURCE_LINK,
diff --git a/bot/modules/users_settings.py b/bot/modules/users_settings.py
index cb7c9d66c6..58e8e075a1 100644
--- a/bot/modules/users_settings.py
+++ b/bot/modules/users_settings.py
@@ -4,6 +4,7 @@
from pyrogram.filters import command, regex, create
from aiofiles import open as aiopen
from aiofiles.os import remove as aioremove, path as aiopath, mkdir
+from langcodes import Language
from os import path as ospath, getcwd
from PIL import Image
from time import time
@@ -74,7 +75,7 @@ async def get_user_settings(from_user, key=None, edit_type=None, edit_mode=None)
buttons.ibutton("Reset Setting", f"userset {user_id} reset_all")
buttons.ibutton("Close", f"userset {user_id} close")
- text = BotTheme('USER_SETTING', NAME=name, ID=user_id, USERNAME=f'@{from_user.username}', LANG=from_user.language_code, DC=from_user.dc_id)
+ text = BotTheme('USER_SETTING', NAME=name, ID=user_id, USERNAME=f'@{from_user.username}', LANG=Language.get(lc).display_name() if (lc := from_user.language_code) else "N/A", DC=from_user.dc_id)
button = buttons.build_menu(1)
elif key == 'universal':
@@ -510,7 +511,7 @@ async def edit_user_settings(client, query):
handler_dict[user_id] = False
if data[2] == 'save_mode' and not user_dict.get(data[2], False) and not user_dict.get('ldump'):
return await query.answer("Set User Dump first to Change Save Msg Mode !", show_alert=True)
- elif data[2] == 'bot_pm' and config_dict['BOT_PM'] or data[2] == 'mediainfo' and config_dict['SHOW_MEDIAINFO'] or data[2] == 'td_mode' and not config_dict['USER_TD_MODE']:
+ elif data[2] == 'bot_pm' and (config_dict['BOT_PM'] or config_dict['SAFE_MODE']) or data[2] == 'mediainfo' and config_dict['SHOW_MEDIAINFO'] or data[2] == 'td_mode' and not config_dict['USER_TD_MODE']:
mode_up = "Disabled" if data[2] == 'td_mode' else "Enabled"
return await query.answer(f"Force {mode_up}! Can't Alter Settings", show_alert=True)
if data[2] == 'td_mode' and not user_dict.get('user_tds', False):
diff --git a/bot/version.py b/bot/version.py
index ed2a6621f5..4b9476d3ce 100644
--- a/bot/version.py
+++ b/bot/version.py
@@ -7,7 +7,7 @@ def get_version() -> str:
:rtype: str
'''
MAJOR = '1'
- MINOR = '2'
+ MINOR = '3'
PATCH = '2'
STATE = 'x'
return f"v{MAJOR}.{MINOR}.{PATCH}-{STATE}"
diff --git a/config_sample.env b/config_sample.env
index 3b24b559c5..54bcabcc55 100644
--- a/config_sample.env
+++ b/config_sample.env
@@ -135,6 +135,7 @@ BOT_THEME = "minimal"
EXCEP_CHATS = ""
# M/L Buttons
+SCREENSHOTS_MODE = "False"
SHOW_MEDIAINFO = "False"
SAVE_MSG = "False"
SOURCE_LINK = "False"