diff --git a/README.md b/README.md
index 3c65e7aa0..735e2eb0b 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
## [AnyDLBot](https://telegram.dog/AnyDLBot) - Clone
---
-
+https://heroku.com/deploy
An Open Source ALL-In-One Telegram RoBot, that can do lot of things.
**My Features**:
diff --git a/helper_funcs/display_progress.py b/helper_funcs/display_progress.py
index e2f1b32fb..a0a18b51d 100644
--- a/helper_funcs/display_progress.py
+++ b/helper_funcs/display_progress.py
@@ -43,8 +43,8 @@ async def progress_for_pyrogram(
estimated_total_time = TimeFormatter(milliseconds=estimated_total_time)
progress = "[{0}{1}] \nP: {2}%\n".format(
- ''.join(["█" for i in range(math.floor(percentage / 5))]),
- ''.join(["░" for i in range(20 - math.floor(percentage / 5))]),
+ ''.join(["▪" for i in range(math.floor(percentage / 5))]),
+ ''.join(["◻" for i in range(20 - math.floor(percentage / 5))]),
round(percentage, 2))
tmp = progress + "{0} of {1}\nSpeed: {2}/s\nETA: {3}\n".format(
diff --git a/plugins/FFMpegRoBot.py b/plugins/FFMpegRoBot.py
new file mode 100644
index 000000000..d5f8f2e77
--- /dev/null
+++ b/plugins/FFMpegRoBot.py
@@ -0,0 +1,264 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# (c) Shrimadhav U K
+
+# the logging things
+import logging
+logging.basicConfig(level=logging.DEBUG,
+ format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
+logger = logging.getLogger(__name__)
+
+import os
+import time
+
+# the secret configuration specific things
+if bool(os.environ.get("WEBHOOK", False)):
+ from sample_config import Config
+else:
+ from config import Config
+
+# the Strings used for this "thing"
+from translation import Translation
+
+import pyrogram
+logging.getLogger("pyrogram").setLevel(logging.WARNING)
+
+from helper_funcs.chat_base import TRChatBase
+from helper_funcs.display_progress import progress_for_pyrogram
+from helper_funcs.help_Nekmo_ffmpeg import take_screen_shot, cult_small_video
+
+from hachoir.metadata import extractMetadata
+from hachoir.parser import createParser
+
+
+@pyrogram.Client.on_message(pyrogram.Filters.command(["ffmpegrobot"]))
+async def ffmpegrobot_ad(bot, update):
+ if update.from_user.id not in Config.AUTH_USERS:
+ await bot.delete_messages(
+ chat_id=update.chat.id,
+ message_ids=update.message_id,
+ revoke=True
+ )
+ return
+ TRChatBase(update.from_user.id, update.text, "ffmpegrobot")
+ await bot.send_message(
+ chat_id=update.chat.id,
+ text=Translation.FF_MPEG_RO_BOT_AD_VER_TISE_MENT,
+ disable_web_page_preview=True,
+ reply_to_message_id=update.message_id
+ )
+
+
+@pyrogram.Client.on_message(pyrogram.Filters.command(["trim"]))
+async def trim(bot, update):
+ if update.from_user.id not in Config.AUTH_USERS:
+ await bot.delete_messages(
+ chat_id=update.chat.id,
+ message_ids=update.message_id,
+ revoke=True
+ )
+ return
+ TRChatBase(update.from_user.id, update.text, "trim")
+ saved_file_path = Config.DOWNLOAD_LOCATION + "/" + str(update.from_user.id) + ".FFMpegRoBot.mkv"
+ if os.path.exists(saved_file_path):
+ a = await bot.send_message(
+ chat_id=update.chat.id,
+ text=Translation.DOWNLOAD_START,
+ reply_to_message_id=update.message_id
+ )
+ commands = update.command
+ if len(commands) == 3:
+ # output should be video
+ cmd, start_time, end_time = commands
+ o = await cult_small_video(saved_file_path, Config.DOWNLOAD_LOCATION, start_time, end_time)
+ logger.info(o)
+ if o is not None:
+ await bot.edit_message_text(
+ chat_id=update.chat.id,
+ text=Translation.UPLOAD_START,
+ message_id=a.message_id
+ )
+ c_time = time.time()
+ await bot.send_video(
+ chat_id=update.chat.id,
+ video=o,
+ # caption=description,
+ # duration=duration,
+ # width=width,
+ # height=height,
+ supports_streaming=True,
+ # reply_markup=reply_markup,
+ # thumb=thumb_image_path,
+ reply_to_message_id=update.message_id,
+ progress=progress_for_pyrogram,
+ progress_args=(
+ Translation.UPLOAD_START,
+ a,
+ c_time
+ )
+ )
+ os.remove(o)
+ await bot.edit_message_text(
+ chat_id=update.chat.id,
+ text=Translation.AFTER_SUCCESSFUL_UPLOAD_MSG,
+ disable_web_page_preview=True,
+ message_id=a.message_id
+ )
+ elif len(commands) == 2:
+ # output should be screenshot
+ cmd, start_time = commands
+ o = await take_screen_shot(saved_file_path, Config.DOWNLOAD_LOCATION, start_time)
+ logger.info(o)
+ if o is not None:
+ await bot.edit_message_text(
+ chat_id=update.chat.id,
+ text=Translation.UPLOAD_START,
+ message_id=a.message_id
+ )
+ c_time = time.time()
+ await bot.send_document(
+ chat_id=update.chat.id,
+ document=o,
+ # thumb=thumb_image_path,
+ # caption=description,
+ # reply_markup=reply_markup,
+ reply_to_message_id=update.message_id,
+ progress=progress_for_pyrogram,
+ progress_args=(
+ Translation.UPLOAD_START,
+ a,
+ c_time
+ )
+ )
+ c_time = time.time()
+ await bot.send_photo(
+ chat_id=update.chat.id,
+ photo=o,
+ # caption=Translation.CUSTOM_CAPTION_UL_FILE,
+ reply_to_message_id=update.message_id,
+ progress=progress_for_pyrogram,
+ progress_args=(
+ Translation.UPLOAD_START,
+ a,
+ c_time
+ )
+ )
+ os.remove(o)
+ await bot.edit_message_text(
+ chat_id=update.chat.id,
+ text=Translation.AFTER_SUCCESSFUL_UPLOAD_MSG,
+ disable_web_page_preview=True,
+ message_id=a.message_id
+ )
+ else:
+ await bot.edit_message_text(
+ chat_id=update.chat.id,
+ text=Translation.FF_MPEG_RO_BOT_RE_SURRECT_ED,
+ message_id=a.message_id
+ )
+ else:
+ # reply help message
+ await bot.send_message(
+ chat_id=update.chat.id,
+ text=Translation.FF_MPEG_RO_BOT_STEP_TWO_TO_ONE,
+ reply_to_message_id=update.message_id
+ )
+
+
+@pyrogram.Client.on_message(pyrogram.Filters.command(["storageinfo"]))
+async def storage_info(bot, update):
+ if update.from_user.id not in Config.AUTH_USERS:
+ await bot.delete_messages(
+ chat_id=update.chat.id,
+ message_ids=update.message_id,
+ revoke=True
+ )
+ return
+ TRChatBase(update.from_user.id, update.text, "storageinfo")
+ saved_file_path = Config.DOWNLOAD_LOCATION + "/" + str(update.from_user.id) + ".FFMpegRoBot.mkv"
+ if os.path.exists(saved_file_path):
+ metadata = extractMetadata(createParser(saved_file_path))
+ duration = None
+ if metadata.has("duration"):
+ duration = metadata.get('duration')
+ await bot.send_message(
+ chat_id=update.chat.id,
+ text=Translation.FF_MPEG_RO_BOT_STOR_AGE_INFO.format(duration),
+ reply_to_message_id=update.message_id
+ )
+ else:
+ # reply help message
+ await bot.send_message(
+ chat_id=update.chat.id,
+ text=Translation.FF_MPEG_RO_BOT_STEP_TWO_TO_ONE,
+ reply_to_message_id=update.message_id
+ )
+
+
+@pyrogram.Client.on_message(pyrogram.Filters.command(["clearffmpegmedia"]))
+async def clear_media(bot, update):
+ if update.from_user.id not in Config.AUTH_USERS:
+ await bot.delete_messages(
+ chat_id=update.chat.id,
+ message_ids=update.message_id,
+ revoke=True
+ )
+ return
+ TRChatBase(update.from_user.id, update.text, "clearffmpegmedia")
+ saved_file_path = Config.DOWNLOAD_LOCATION + "/" + str(update.from_user.id) + ".FFMpegRoBot.mkv"
+ if os.path.exists(saved_file_path):
+ os.remove(saved_file_path)
+ await bot.send_message(
+ chat_id=update.chat.id,
+ text=Translation.FF_MPEG_DEL_ETED_CUSTOM_MEDIA,
+ reply_to_message_id=update.message_id
+ )
+
+
+@pyrogram.Client.on_message(pyrogram.Filters.command(["downloadmedia"]))
+async def download_media(bot, update):
+ if update.from_user.id not in Config.AUTH_USERS:
+ await bot.delete_messages(
+ chat_id=update.chat.id,
+ message_ids=update.message_id,
+ revoke=True
+ )
+ return
+ TRChatBase(update.from_user.id, update.text, "downloadmedia")
+ saved_file_path = Config.DOWNLOAD_LOCATION + "/" + str(update.from_user.id) + ".FFMpegRoBot.mkv"
+ if not os.path.exists(saved_file_path):
+ a = await bot.send_message(
+ chat_id=update.chat.id,
+ text=Translation.DOWNLOAD_START,
+ reply_to_message_id=update.message_id
+ )
+ try:
+ c_time = time.time()
+ await bot.download_media(
+ message=update.reply_to_message,
+ file_name=saved_file_path,
+ progress=progress_for_pyrogram,
+ progress_args=(
+ Translation.DOWNLOAD_START,
+ a,
+ c_time
+ )
+ )
+ except (ValueError) as e:
+ await bot.edit_message_text(
+ chat_id=update.chat.id,
+ text=str(e),
+ message_id=a.message_id
+ )
+ else:
+ await bot.edit_message_text(
+ chat_id=update.chat.id,
+ text=Translation.SAVED_RECVD_DOC_FILE,
+ message_id=a.message_id
+ )
+ else:
+ await bot.send_message(
+ chat_id=update.chat.id,
+ text=Translation.FF_MPEG_RO_BOT_STOR_AGE_ALREADY_EXISTS,
+ reply_to_message_id=update.message_id
+ )
diff --git a/plugins/Rename_file.py b/plugins/Rename_file.py
new file mode 100644
index 000000000..16267d62e
--- /dev/null
+++ b/plugins/Rename_file.py
@@ -0,0 +1,150 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# (c) Shrimadhav U K
+
+# the logging things
+import logging
+logging.basicConfig(level=logging.DEBUG,
+ format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
+logger = logging.getLogger(__name__)
+
+import os
+import time
+
+# the secret configuration specific things
+if bool(os.environ.get("WEBHOOK", False)):
+ from sample_config import Config
+else:
+ from config import Config
+
+# the Strings used for this "thing"
+from translation import Translation
+
+import pyrogram
+logging.getLogger("pyrogram").setLevel(logging.WARNING)
+from pyrogram import Client, Filters
+
+from helper_funcs.chat_base import TRChatBase
+from helper_funcs.display_progress import progress_for_pyrogram
+
+from hachoir.metadata import extractMetadata
+from hachoir.parser import createParser
+# https://stackoverflow.com/a/37631799/4723940
+from PIL import Image
+
+
+@pyrogram.Client.on_message(pyrogram.Filters.command(["rename"]))
+async def rename_doc(bot, update):
+ if update.from_user.id in Config.BANNED_USERS:
+ await bot.delete_messages(
+ chat_id=update.chat.id,
+ message_ids=update.message_id,
+ revoke=True
+ )
+ return
+ TRChatBase(update.from_user.id, update.text, "rename")
+ if (" " in update.text) and (update.reply_to_message is not None):
+ cmd, file_name = update.text.split(" ", 1)
+ if len(file_name) > 64:
+ await update.reply_text(
+ Translation.IFLONG_FILE_NAME.format(
+ alimit="64",
+ num=len(file_name)
+ )
+ )
+ return
+ description = Translation.CUSTOM_CAPTION_UL_FILE
+ download_location = Config.DOWNLOAD_LOCATION + "/"
+ a = await bot.send_message(
+ chat_id=update.chat.id,
+ text=Translation.DOWNLOAD_START,
+ reply_to_message_id=update.message_id
+ )
+ c_time = time.time()
+ the_real_download_location = await bot.download_media(
+ message=update.reply_to_message,
+ file_name=download_location,
+ progress=progress_for_pyrogram,
+ progress_args=(
+ Translation.DOWNLOAD_START,
+ a,
+ c_time
+ )
+ )
+ if the_real_download_location is not None:
+ try:
+ await bot.edit_message_text(
+ text=Translation.SAVED_RECVD_DOC_FILE,
+ chat_id=update.chat.id,
+ message_id=a.message_id
+ )
+ except:
+ pass
+ if "IndianMovie" in the_real_download_location:
+ await bot.edit_message_text(
+ text=Translation.RENAME_403_ERR,
+ chat_id=update.chat.id,
+ message_id=a.message_id
+ )
+ return
+ new_file_name = download_location + file_name
+ os.rename(the_real_download_location, new_file_name)
+ await bot.edit_message_text(
+ text=Translation.UPLOAD_START,
+ chat_id=update.chat.id,
+ message_id=a.message_id
+ )
+ logger.info(the_real_download_location)
+ thumb_image_path = Config.DOWNLOAD_LOCATION + "/" + str(update.from_user.id) + ".jpg"
+ if not os.path.exists(thumb_image_path):
+ thumb_image_path = None
+ else:
+ width = 0
+ height = 0
+ metadata = extractMetadata(createParser(thumb_image_path))
+ if metadata.has("width"):
+ width = metadata.get("width")
+ if metadata.has("height"):
+ height = metadata.get("height")
+ # resize image
+ # ref: https://t.me/PyrogramChat/44663
+ # https://stackoverflow.com/a/21669827/4723940
+ Image.open(thumb_image_path).convert("RGB").save(thumb_image_path)
+ img = Image.open(thumb_image_path)
+ # https://stackoverflow.com/a/37631799/4723940
+ # img.thumbnail((90, 90))
+ img.resize((320, height))
+ img.save(thumb_image_path, "JPEG")
+ # https://pillow.readthedocs.io/en/3.1.x/reference/Image.html#create-thumbnails
+ c_time = time.time()
+ await bot.send_document(
+ chat_id=update.chat.id,
+ document=new_file_name,
+ thumb=thumb_image_path,
+ caption=description,
+ # reply_markup=reply_markup,
+ reply_to_message_id=update.reply_to_message.message_id,
+ progress=progress_for_pyrogram,
+ progress_args=(
+ Translation.UPLOAD_START,
+ a,
+ c_time
+ )
+ )
+ try:
+ os.remove(new_file_name)
+ os.remove(thumb_image_path)
+ except:
+ pass
+ await bot.edit_message_text(
+ text=Translation.AFTER_SUCCESSFUL_UPLOAD_MSG,
+ chat_id=update.chat.id,
+ message_id=a.message_id,
+ disable_web_page_preview=True
+ )
+ else:
+ await bot.send_message(
+ chat_id=update.chat.id,
+ text=Translation.REPLY_TO_DOC_FOR_RENAME_FILE,
+ reply_to_message_id=update.message_id
+ )
diff --git a/plugins/convert_to_audio.py b/plugins/convert_to_audio.py
new file mode 100644
index 000000000..1545a5d2c
--- /dev/null
+++ b/plugins/convert_to_audio.py
@@ -0,0 +1,143 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# (c) Shrimadhav U K
+
+# the logging things
+import logging
+logging.basicConfig(level=logging.DEBUG,
+ format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
+logger = logging.getLogger(__name__)
+
+import os
+import time
+
+# the secret configuration specific things
+if bool(os.environ.get("WEBHOOK", False)):
+ from sample_config import Config
+else:
+ from config import Config
+
+# the Strings used for this "thing"
+from translation import Translation
+
+import pyrogram
+logging.getLogger("pyrogram").setLevel(logging.WARNING)
+
+from helper_funcs.chat_base import TRChatBase
+from helper_funcs.display_progress import progress_for_pyrogram
+
+from hachoir.metadata import extractMetadata
+from hachoir.parser import createParser
+# https://stackoverflow.com/a/37631799/4723940
+from PIL import Image
+
+
+@pyrogram.Client.on_message(pyrogram.Filters.command(["converttoaudio"]))
+async def convert_to_audio(bot, update):
+ if update.from_user.id not in Config.AUTH_USERS:
+ await bot.delete_messages(
+ chat_id=update.chat.id,
+ message_ids=update.message_id,
+ revoke=True
+ )
+ return
+ TRChatBase(update.from_user.id, update.text, "converttoaudio")
+ if (update.reply_to_message is not None) and (update.reply_to_message.media is not None) :
+ description = Translation.CUSTOM_CAPTION_UL_FILE
+ download_location = Config.DOWNLOAD_LOCATION + "/"
+ a = await bot.send_message(
+ chat_id=update.chat.id,
+ text=Translation.DOWNLOAD_START,
+ reply_to_message_id=update.message_id
+ )
+ c_time = time.time()
+ the_real_download_location = await bot.download_media(
+ message=update.reply_to_message,
+ file_name=download_location,
+ progress=progress_for_pyrogram,
+ progress_args=(
+ Translation.DOWNLOAD_START,
+ a,
+ c_time
+ )
+ )
+ if the_real_download_location is not None:
+ await bot.edit_message_text(
+ text=Translation.SAVED_RECVD_DOC_FILE,
+ chat_id=update.chat.id,
+ message_id=a.message_id
+ )
+ # don't care about the extension
+ # convert video to audio format
+ audio_file_location_path = the_real_download_location
+ await bot.edit_message_text(
+ text=Translation.UPLOAD_START,
+ chat_id=update.chat.id,
+ message_id=a.message_id
+ )
+ logger.info(the_real_download_location)
+ # get the correct width, height, and duration for videos greater than 10MB
+ # ref: message from @BotSupport
+ width = 0
+ height = 0
+ duration = 0
+ metadata = extractMetadata(createParser(the_real_download_location))
+ if metadata.has("duration"):
+ duration = metadata.get('duration').seconds
+ thumb_image_path = Config.DOWNLOAD_LOCATION + "/" + str(update.from_user.id) + ".jpg"
+ if not os.path.exists(thumb_image_path):
+ thumb_image_path = None
+ else:
+ metadata = extractMetadata(createParser(thumb_image_path))
+ if metadata.has("width"):
+ width = metadata.get("width")
+ if metadata.has("height"):
+ height = metadata.get("height")
+ # get the correct width, height, and duration for videos greater than 10MB
+ # resize image
+ # ref: https://t.me/PyrogramChat/44663
+ # https://stackoverflow.com/a/21669827/4723940
+ Image.open(thumb_image_path).convert("RGB").save(thumb_image_path)
+ img = Image.open(thumb_image_path)
+ # https://stackoverflow.com/a/37631799/4723940
+ # img.thumbnail((90, 90))
+ img.resize((90, height))
+ img.save(thumb_image_path, "JPEG")
+ # https://pillow.readthedocs.io/en/3.1.x/reference/Image.html#create-thumbnails
+ # try to upload file
+ c_time = time.time()
+ await bot.send_audio(
+ chat_id=update.chat.id,
+ audio=audio_file_location_path,
+ caption=description,
+ duration=duration,
+ # performer="",
+ # title="",
+ # reply_markup=reply_markup,
+ thumb=thumb_image_path,
+ reply_to_message_id=update.reply_to_message.message_id,
+ progress=progress_for_pyrogram,
+ progress_args=(
+ Translation.UPLOAD_START,
+ a,
+ c_time
+ )
+ )
+ try:
+ os.remove(thumb_image_path)
+ os.remove(the_real_download_location)
+ os.remove(audio_file_location_path)
+ except:
+ pass
+ await bot.edit_message_text(
+ text=Translation.AFTER_SUCCESSFUL_UPLOAD_MSG,
+ chat_id=update.chat.id,
+ message_id=a.message_id,
+ disable_web_page_preview=True
+ )
+ else:
+ await bot.send_message(
+ chat_id=update.chat.id,
+ text=Translation.REPLY_TO_DOC_FOR_C2V,
+ reply_to_message_id=update.message_id
+ )
diff --git a/plugins/convert_to_video.py b/plugins/convert_to_video.py
new file mode 100644
index 000000000..c26dbbea4
--- /dev/null
+++ b/plugins/convert_to_video.py
@@ -0,0 +1,151 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# (c) Shrimadhav U K
+
+# the logging things
+import logging
+logging.basicConfig(level=logging.DEBUG,
+ format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
+logger = logging.getLogger(__name__)
+
+import os
+import random
+import time
+
+# the secret configuration specific things
+if bool(os.environ.get("WEBHOOK", False)):
+ from sample_config import Config
+else:
+ from config import Config
+
+# the Strings used for this "thing"
+from translation import Translation
+
+import pyrogram
+logging.getLogger("pyrogram").setLevel(logging.WARNING)
+
+from helper_funcs.chat_base import TRChatBase
+from helper_funcs.display_progress import progress_for_pyrogram
+from helper_funcs.help_Nekmo_ffmpeg import take_screen_shot
+
+from hachoir.metadata import extractMetadata
+from hachoir.parser import createParser
+# https://stackoverflow.com/a/37631799/4723940
+from PIL import Image
+
+
+@pyrogram.Client.on_message(pyrogram.Filters.command(["converttovideo"]))
+async def convert_to_video(bot, update):
+ if update.from_user.id not in Config.AUTH_USERS:
+ await bot.delete_messages(
+ chat_id=update.chat.id,
+ message_ids=update.message_id,
+ revoke=True
+ )
+ return
+ TRChatBase(update.from_user.id, update.text, "converttovideo")
+ if update.reply_to_message is not None:
+ description = Translation.CUSTOM_CAPTION_UL_FILE
+ download_location = Config.DOWNLOAD_LOCATION + "/"
+ a = await bot.send_message(
+ chat_id=update.chat.id,
+ text=Translation.DOWNLOAD_START,
+ reply_to_message_id=update.message_id
+ )
+ c_time = time.time()
+ the_real_download_location = await bot.download_media(
+ message=update.reply_to_message,
+ file_name=download_location,
+ progress=progress_for_pyrogram,
+ progress_args=(
+ Translation.DOWNLOAD_START,
+ a,
+ c_time
+ )
+ )
+ if the_real_download_location is not None:
+ await bot.edit_message_text(
+ text=Translation.SAVED_RECVD_DOC_FILE,
+ chat_id=update.chat.id,
+ message_id=a.message_id
+ )
+ # don't care about the extension
+ await bot.edit_message_text(
+ text=Translation.UPLOAD_START,
+ chat_id=update.chat.id,
+ message_id=a.message_id
+ )
+ logger.info(the_real_download_location)
+ # get the correct width, height, and duration for videos greater than 10MB
+ # ref: message from @BotSupport
+ width = 0
+ height = 0
+ duration = 0
+ metadata = extractMetadata(createParser(the_real_download_location))
+ if metadata.has("duration"):
+ duration = metadata.get('duration').seconds
+ thumb_image_path = Config.DOWNLOAD_LOCATION + "/" + str(update.from_user.id) + ".jpg"
+ if not os.path.exists(thumb_image_path):
+ thumb_image_path = await take_screen_shot(
+ the_real_download_location,
+ os.path.dirname(the_real_download_location),
+ random.randint(
+ 0,
+ duration - 1
+ )
+ )
+ logger.info(thumb_image_path)
+ # 'thumb_image_path' will be available now
+ metadata = extractMetadata(createParser(thumb_image_path))
+ if metadata.has("width"):
+ width = metadata.get("width")
+ if metadata.has("height"):
+ height = metadata.get("height")
+ # get the correct width, height, and duration for videos greater than 10MB
+ # resize image
+ # ref: https://t.me/PyrogramChat/44663
+ # https://stackoverflow.com/a/21669827/4723940
+ Image.open(thumb_image_path).convert("RGB").save(thumb_image_path)
+ img = Image.open(thumb_image_path)
+ # https://stackoverflow.com/a/37631799/4723940
+ # img.thumbnail((90, 90))
+ img.resize((90, height))
+ img.save(thumb_image_path, "JPEG")
+ # https://pillow.readthedocs.io/en/3.1.x/reference/Image.html#create-thumbnails
+ # try to upload file
+ c_time = time.time()
+ await bot.send_video(
+ chat_id=update.chat.id,
+ video=the_real_download_location,
+ caption=description,
+ duration=duration,
+ width=width,
+ height=height,
+ supports_streaming=True,
+ # reply_markup=reply_markup,
+ thumb=thumb_image_path,
+ reply_to_message_id=update.reply_to_message.message_id,
+ progress=progress_for_pyrogram,
+ progress_args=(
+ Translation.UPLOAD_START,
+ a,
+ c_time
+ )
+ )
+ try:
+ os.remove(the_real_download_location)
+ os.remove(thumb_image_path)
+ except:
+ pass
+ await bot.edit_message_text(
+ text=Translation.AFTER_SUCCESSFUL_UPLOAD_MSG,
+ chat_id=update.chat.id,
+ message_id=a.message_id,
+ disable_web_page_preview=True
+ )
+ else:
+ await bot.send_message(
+ chat_id=update.chat.id,
+ text=Translation.REPLY_TO_DOC_FOR_C2V,
+ reply_to_message_id=update.message_id
+ )
diff --git a/plugins/download_stickers.py b/plugins/download_stickers.py
new file mode 100644
index 000000000..2288e2341
--- /dev/null
+++ b/plugins/download_stickers.py
@@ -0,0 +1,110 @@
+
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# (c) Shrimadhav U K
+
+# the logging things
+import logging
+logging.basicConfig(level=logging.DEBUG,
+ format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
+logger = logging.getLogger(__name__)
+
+import os
+import time
+
+# the secret configuration specific things
+if bool(os.environ.get("WEBHOOK", False)):
+ from sample_config import Config
+else:
+ from config import Config
+
+# the Strings used for this "thing"
+from translation import Translation
+
+import pyrogram
+logging.getLogger("pyrogram").setLevel(logging.WARNING)
+
+from helper_funcs.chat_base import TRChatBase
+from helper_funcs.display_progress import progress_for_pyrogram
+
+
+@pyrogram.Client.on_message(pyrogram.Filters.sticker)
+async def DownloadStickersBot(bot, update):
+ if update.from_user.id not in Config.AUTH_USERS:
+ await bot.delete_messages(
+ chat_id=update.chat.id,
+ message_ids=update.message_id,
+ revoke=True
+ )
+ return
+ TRChatBase(update.from_user.id, update.text, "DownloadStickersBot")
+ logger.info(update.from_user)
+ download_location = Config.DOWNLOAD_LOCATION + "/" + str(update.from_user.id) + "_DownloadStickersBot_" + str(update.from_user.id) + ".png"
+ a = await bot.send_message(
+ chat_id=update.chat.id,
+ text=Translation.DOWNLOAD_START,
+ reply_to_message_id=update.message_id
+ )
+ try:
+ c_time = time.time()
+ the_real_download_location = await bot.download_media(
+ message=update,
+ file_name=download_location,
+ progress=progress_for_pyrogram,
+ progress_args=(
+ Translation.DOWNLOAD_START,
+ a,
+ c_time
+ )
+ )
+ except (ValueError) as e:
+ await bot.edit_message_text(
+ text=str(e),
+ chat_id=update.chat.id,
+ message_id=a.message_id
+ )
+ return False
+ await bot.edit_message_text(
+ text=Translation.SAVED_RECVD_DOC_FILE,
+ chat_id=update.chat.id,
+ message_id=a.message_id
+ )
+ c_time = time.time()
+ await bot.send_document(
+ chat_id=update.chat.id,
+ document=the_real_download_location,
+ # thumb=thumb_image_path,
+ # caption=description,
+ # reply_markup=reply_markup,
+ reply_to_message_id=a.message_id,
+ progress=progress_for_pyrogram,
+ progress_args=(
+ Translation.UPLOAD_START,
+ a,
+ c_time
+ )
+ )
+ try:
+ await bot.send_photo(
+ chat_id=update.chat.id,
+ photo=the_real_download_location,
+ # thumb=thumb_image_path,
+ # caption=description,
+ # reply_markup=reply_markup,
+ reply_to_message_id=a.message_id,
+ progress=progress_for_pyrogram,
+ progress_args=(
+ Translation.UPLOAD_START,
+ a,
+ c_time
+ )
+ )
+ except:
+ pass
+ os.remove(the_real_download_location)
+ await bot.edit_message_text(
+ text=Translation.AFTER_SUCCESSFUL_UPLOAD_MSG,
+ chat_id=update.chat.id,
+ message_id=a.message_id,
+ disable_web_page_preview=True
+ )
diff --git a/plugins/generate_screen_shot.py b/plugins/generate_screen_shot.py
new file mode 100644
index 000000000..cb9c62355
--- /dev/null
+++ b/plugins/generate_screen_shot.py
@@ -0,0 +1,127 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# (c) Shrimadhav U K
+
+# the logging things
+import logging
+logging.basicConfig(level=logging.DEBUG,
+ format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
+logger = logging.getLogger(__name__)
+
+import os
+import shutil
+import time
+
+# the secret configuration specific things
+if bool(os.environ.get("WEBHOOK", False)):
+ from sample_config import Config
+else:
+ from config import Config
+
+# the Strings used for this "thing"
+from translation import Translation
+
+import pyrogram
+logging.getLogger("pyrogram").setLevel(logging.WARNING)
+
+from helper_funcs.chat_base import TRChatBase
+from helper_funcs.help_Nekmo_ffmpeg import generate_screen_shots
+from helper_funcs.display_progress import progress_for_pyrogram
+
+
+@pyrogram.Client.on_message(pyrogram.Filters.command(["generatescss"]))
+async def generate_screen_shot(bot, update):
+ if update.from_user.id not in Config.AUTH_USERS:
+ await bot.delete_messages(
+ chat_id=update.chat.id,
+ message_ids=update.message_id,
+ revoke=True
+ )
+ return
+ TRChatBase(update.from_user.id, update.text, "generatescss")
+ if update.reply_to_message is not None:
+ download_location = Config.DOWNLOAD_LOCATION + "/"
+ a = await bot.send_message(
+ chat_id=update.chat.id,
+ text=Translation.DOWNLOAD_START,
+ reply_to_message_id=update.message_id
+ )
+ c_time = time.time()
+ the_real_download_location = await bot.download_media(
+ message=update.reply_to_message,
+ file_name=download_location,
+ progress=progress_for_pyrogram,
+ progress_args=(
+ Translation.DOWNLOAD_START,
+ a,
+ c_time
+ )
+ )
+ if the_real_download_location is not None:
+ await bot.edit_message_text(
+ text=Translation.SAVED_RECVD_DOC_FILE,
+ chat_id=update.chat.id,
+ message_id=a.message_id
+ )
+ tmp_directory_for_each_user = Config.DOWNLOAD_LOCATION + "/" + str(update.from_user.id)
+ if not os.path.isdir(tmp_directory_for_each_user):
+ os.makedirs(tmp_directory_for_each_user)
+ images = await generate_screen_shots(
+ the_real_download_location,
+ tmp_directory_for_each_user,
+ False,
+ Config.DEF_WATER_MARK_FILE,
+ 5,
+ 9
+ )
+ logger.info(images)
+ await bot.edit_message_text(
+ text=Translation.UPLOAD_START,
+ chat_id=update.chat.id,
+ message_id=a.message_id
+ )
+ media_album_p = []
+ if images is not None:
+ i = 0
+ caption = "© @NRbotsZ"
+ for image in images:
+ if os.path.exists(image):
+ if i == 0:
+ media_album_p.append(
+ pyrogram.InputMediaPhoto(
+ media=image,
+ caption=caption,
+ parse_mode="html"
+ )
+ )
+ else:
+ media_album_p.append(
+ pyrogram.InputMediaPhoto(
+ media=image
+ )
+ )
+ i = i + 1
+ await bot.send_media_group(
+ chat_id=update.chat.id,
+ disable_notification=True,
+ reply_to_message_id=a.message_id,
+ media=media_album_p
+ )
+ #
+ try:
+ shutil.rmtree(tmp_directory_for_each_user)
+ os.remove(the_real_download_location)
+ except:
+ pass
+ await bot.edit_message_text(
+ text=Translation.AFTER_SUCCESSFUL_UPLOAD_MSG,
+ chat_id=update.chat.id,
+ message_id=a.message_id,
+ disable_web_page_preview=True
+ )
+ else:
+ await bot.send_message(
+ chat_id=update.chat.id,
+ text=Translation.REPLY_TO_DOC_FOR_SCSS,
+ reply_to_message_id=update.message_id
+ )
diff --git a/plugins/get_external_link.py b/plugins/get_external_link.py
new file mode 100644
index 000000000..04c4778c8
--- /dev/null
+++ b/plugins/get_external_link.py
@@ -0,0 +1,115 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# (c) Shrimadhav U K
+
+# the logging things
+import logging
+logging.basicConfig(level=logging.DEBUG,
+ format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
+logger = logging.getLogger(__name__)
+
+from datetime import datetime
+import os
+import requests
+import subprocess
+import time
+
+# the secret configuration specific things
+if bool(os.environ.get("WEBHOOK", False)):
+ from sample_config import Config
+else:
+ from config import Config
+
+# the Strings used for this "thing"
+from translation import Translation
+
+import pyrogram
+logging.getLogger("pyrogram").setLevel(logging.WARNING)
+
+from helper_funcs.chat_base import TRChatBase
+from helper_funcs.display_progress import progress_for_pyrogram
+
+
+@pyrogram.Client.on_message(pyrogram.Filters.command(["getlink"]))
+async def get_link(bot, update):
+ if update.from_user.id not in Config.AUTH_USERS:
+ await bot.delete_messages(
+ chat_id=update.chat.id,
+ message_ids=update.message_id,
+ revoke=True
+ )
+ return
+ TRChatBase(update.from_user.id, update.text, "getlink")
+ logger.info(update.from_user)
+ if update.reply_to_message is not None:
+ reply_message = update.reply_to_message
+ download_location = Config.DOWNLOAD_LOCATION + "/"
+ start = datetime.now()
+ a = await bot.send_message(
+ chat_id=update.chat.id,
+ text=Translation.DOWNLOAD_START,
+ reply_to_message_id=update.message_id
+ )
+ c_time = time.time()
+ after_download_file_name = await bot.download_media(
+ message=reply_message,
+ file_name=download_location,
+ progress=progress_for_pyrogram,
+ progress_args=(
+ Translation.DOWNLOAD_START,
+ a,
+ c_time
+ )
+ )
+ download_extension = after_download_file_name.rsplit(".", 1)[-1]
+ await bot.edit_message_text(
+ text=Translation.SAVED_RECVD_DOC_FILE,
+ chat_id=update.chat.id,
+ message_id=a.message_id
+ )
+ end_one = datetime.now()
+ url = "https://transfer.sh/{}.{}".format(str(update.from_user.id), str(download_extension))
+ max_days = "5"
+ command_to_exec = [
+ "curl",
+ # "-H", 'Max-Downloads: 1',
+ "-H", 'Max-Days: 5', # + max_days + '',
+ "--upload-file", after_download_file_name,
+ url
+ ]
+ await bot.edit_message_text(
+ text=Translation.UPLOAD_START,
+ chat_id=update.chat.id,
+ message_id=a.message_id
+ )
+ try:
+ logger.info(command_to_exec)
+ t_response = subprocess.check_output(command_to_exec, stderr=subprocess.STDOUT)
+ except subprocess.CalledProcessError as exc:
+ logger.info("Status : FAIL", exc.returncode, exc.output)
+ await bot.edit_message_text(
+ chat_id=update.chat.id,
+ text=exc.output.decode("UTF-8"),
+ message_id=a.message_id
+ )
+ return False
+ else:
+ logger.info(t_response)
+ t_response_arry = t_response.decode("UTF-8").split("\n")[-1].strip()
+ await bot.edit_message_text(
+ chat_id=update.chat.id,
+ text=Translation.AFTER_GET_DL_LINK.format(t_response_arry, max_days),
+ parse_mode="html",
+ message_id=a.message_id,
+ disable_web_page_preview=True
+ )
+ try:
+ os.remove(after_download_file_name)
+ except:
+ pass
+ else:
+ await bot.send_message(
+ chat_id=update.chat.id,
+ text=Translation.REPLY_TO_DOC_GET_LINK,
+ reply_to_message_id=update.message_id
+ )
diff --git a/plugins/youtube_dl_button.py b/plugins/youtube_dl_button.py
index 706a0615f..2522ae9ce 100644
--- a/plugins/youtube_dl_button.py
+++ b/plugins/youtube_dl_button.py
@@ -322,7 +322,7 @@ async def youtube_dl_call_back(bot, update):
media_album_p = []
if images is not None:
i = 0
- caption = "© @TGBotsZ"
+ caption = "© @NRBotsZ"
if is_w_f:
caption = "/upgrade to Plan D to remove the watermark\n© @AnyDLBot"
for image in images:
diff --git a/translation.py b/translation.py
index 76a195fca..da896f398 100644
--- a/translation.py
+++ b/translation.py
@@ -1,28 +1,27 @@
class Translation(object):
START_TEXT = """Hello,
-This is a Telegram URL Upload Bot!
-
-Please send me any direct download URL Link, i can upload to telegram as File/Video
-
+This is a Telegram File To Video Converter Bot!
+
/help for more details..
-Support Group : @InFoTelGroup
-© @SpEcHlDe , @TGBotsZ & @CWProjects"""
+Support Group :
+ @ALL_MOVIES_LIABRARY
+"""
RENAME_403_ERR = "Sorry. You are not permitted to rename this file."
ABS_TEXT = " Please don't be selfish."
- UPGRADE_TEXT = "👉 Create own Clone Bot.. /help for Details"
+ UPGRADE_TEXT = " /help for Details"
FORMAT_SELECTION = "Select the desired format: file size might be approximate \nIf you want to set custom thumbnail, send photo before or quickly after tapping on any of the below buttons.\nYou can use /deletethumbnail to delete the auto-generated thumbnail."
SET_CUSTOM_USERNAME_PASSWORD = """If you want to download premium videos, provide in the following format:
URL | filename | username | password"""
NOYES_URL = "@robot URL detected. Please use https://shrtz.me/PtsVnf6 and get me a fast URL so that I can upload to Telegram, without me slowing down for other users."
- DOWNLOAD_START = "trying to download"
- UPLOAD_START = "trying to upload"
+ DOWNLOAD_START = "Trying To Download"
+ UPLOAD_START = "Trying To Upload"
RCHD_BOT_API_LIMIT = "size greater than maximum allowed size (50MB). Neverthless, trying to upload."
RCHD_TG_API_LIMIT = "Downloaded in {} seconds.\nDetected File Size: {}\nSorry. But, I cannot upload files greater than 1.5GB due to Telegram API limitations."
- AFTER_SUCCESSFUL_UPLOAD_MSG = "Please rate me if you find me useful. Join : @TGBotsZ"
- AFTER_SUCCESSFUL_UPLOAD_MSG_WITH_TS = "Downloaded in {} seconds. \nJoin : @TGBotsZ \nUploaded in {} seconds."
+ AFTER_SUCCESSFUL_UPLOAD_MSG = "Please rate me if you find me useful. Join : @ALL_MOVIES_LIABRARY"
+ AFTER_SUCCESSFUL_UPLOAD_MSG_WITH_TS = "Downloaded in {} seconds. \nJoin : @ALL_MOVIES_LIABRARY \nUploaded in {} seconds."
NOT_AUTH_USER_TEXT = "Please /upgrade your subscription."
- NOT_AUTH_USER_TEXT_FILE_SIZE = "Detected File Size: {}. Free Users can only upload: {}\nPlease /upgrade your subscription.\nIf you think this is a bug, please contact @SpEcHlDe"
+ NOT_AUTH_USER_TEXT_FILE_SIZE = "Detected File Size: {}. Free Users can only upload: {}\nPlease /upgrade your subscription.\nIf you think this is a bug, please contact @NGYNY"
SAVED_CUSTOM_THUMB_NAIL = "Custom video / file thumbnail saved. This image will be used in the video / file."
DEL_ETED_CUSTOM_THUMB_NAIL = "✅ Custom thumbnail cleared succesfully."
FF_MPEG_DEL_ETED_CUSTOM_MEDIA = "✅ Media cleared succesfully."
@@ -34,30 +33,24 @@ class Translation(object):
CURENT_PLAN_DETAILS = """Current plan details
--------
Telegram ID: {}
-Plan name: Free Cloned User
+Plan Free User
Expires on: 31/12/2020"""
- HELP_USER = """Hai am URL Uploader bot..
+ HELP_USER = """Hai am File to video converter bot...
-1. Send url (Link|New Name with Extension).
-2. Send Custom Thumbnail (Optional).
-3. Select the button.
- SVideo - Give File as video with Screenshots
- DFile - Give File with Screenshots
- Video - Give File as video without Screenshots
- DFile - Give File without Screenshots
+1.send me a file and just reply to file as /converttovideo
-👉 Create own Clone Bot : 👉 Diploy
+Join: @ALL_MOVIES_LIABRARY
--------
Send /me to know current plan details
-Support Group : @InFoTelGroup
-© @TGBotsZ & @CWProjects"""
+Support Group : @ALL_MOVIES_LIABRARY
+"""
REPLY_TO_DOC_GET_LINK = "Reply to a Telegram media to get High Speed Direct Download Link"
REPLY_TO_DOC_FOR_C2V = "Reply to a Telegram media to convert"
REPLY_TO_DOC_FOR_SCSS = "Reply to a Telegram media to get screenshots"
REPLY_TO_DOC_FOR_RENAME_FILE = "Reply to a Telegram media to /rename with custom thumbnail support"
- AFTER_GET_DL_LINK = "Direct Link Generated valid for {} days.\n© @AnyDLBot"
+ AFTER_GET_DL_LINK = "Direct Link Generated valid for {} days.\n© @ALL_MOVIES_LIABRARY"
FF_MPEG_RO_BOT_RE_SURRECT_ED = """Syntax: /trim HH:MM:SS [HH:MM:SS]"""
FF_MPEG_RO_BOT_STEP_TWO_TO_ONE = "First send /downloadmedia to any media so that it can be downloaded to my local. \nSend /storageinfo to know the media, that is currently downloaded."
FF_MPEG_RO_BOT_STOR_AGE_INFO = "Video Duration: {}\nSend /clearffmpegmedia to delete this media, from my storage.\nSend /trim HH:MM:SS [HH:MM:SS] to cu[l]t a small photo / video, from the above media."
@@ -68,16 +61,14 @@ class Translation(object):
ERR_ONLY_TWO_MEDIA_IN_ALBUM = "Media Album should contain only two photos. Please re-send the media album, and then try again, or send only two photos in an album."
INVALID_UPLOAD_BOT_URL_FORMAT = "URL format is incorrect. make sure your url starts with either http:// or https://. You can set custom file name using the format link | file_name.extension"
ABUSIVE_USERS = "You are not allowed to use this bot. If you think this is a mistake, please check /me to remove this restriction."
- FF_MPEG_RO_BOT_AD_VER_TISE_MENT = "https://telegram.dog/FFMpegRoBot"
+ FF_MPEG_RO_BOT_AD_VER_TISE_MENT = "https://telegram.dog/NRbotsZ"
EXTRACT_ZIP_INTRO_ONE = "Send a compressed file first, Then reply /unzip command to the file."
EXTRACT_ZIP_INTRO_THREE = "Analyzing received file. ⚠️ This might take some time. Please be patient. "
UNZIP_SUPPORTED_EXTENSIONS = ("zip", "rar")
- EXTRACT_ZIP_ERRS_OCCURED = "Sorry. Errors occurred while processing compressed file. Please check everything again twice, and if the issue persists, report this to @SpEcHlDe"
+ EXTRACT_ZIP_ERRS_OCCURED = "Sorry. Errors occurred while processing compressed file. Please check everything again twice, and if the issue persists, report this to @ALL_MOVIES_LIABRARY"
EXTRACT_ZIP_STEP_TWO = """Select file_name to upload from the below options.
You can use /rename command after receiving file to rename it with custom thumbnail support."""
CANCEL_STR = "Process Cancelled"
ZIP_UPLOADED_STR = "Uploaded {} files in {} seconds"
- FREE_USER_LIMIT_Q_SZE = """Cannot Process.
-Free users only 1 request per 30 minutes.
-/upgrade or Try 1800 seconds later."""
+ FREE_USER_LIMIT_Q_SZE = """No one Gonna Help you."""
SLOW_URL_DECED = "Gosh that seems to be a very slow URL. Since you were screwing my home, I am in no mood to download this file. Meanwhile, why don't you try this:==> https://shrtz.me/PtsVnf6 and get me a fast URL so that I can upload to Telegram, without me slowing down for other users."