Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
bffce95
Create batch.py
vasusen-code Feb 10, 2022
673eadd
Update batch.py
vasusen-code Feb 10, 2022
af0ea45
Update batch.py
vasusen-code Feb 10, 2022
a9d6cba
Update batch.py
vasusen-code Feb 10, 2022
85808fa
Update batch.py
vasusen-code Feb 11, 2022
573988a
Rename batch.py to _batch.py
vasusen-code Feb 11, 2022
847bdaa
Update _batch.py
vasusen-code Feb 11, 2022
b9732f5
Update _batch.py
vasusen-code Feb 11, 2022
c04ba60
Update _batch.py
vasusen-code Feb 11, 2022
ad3c7fd
Update _batch.py
vasusen-code Feb 11, 2022
71b4092
Update _batch.py
vasusen-code Feb 11, 2022
7401f6b
Update _batch.py
vasusen-code Feb 11, 2022
780c5e8
Update _batch.py
vasusen-code Feb 11, 2022
59f70a0
Update _batch.py
vasusen-code Feb 11, 2022
007ec74
Update _batch.py
vasusen-code Feb 11, 2022
89abc7f
Update _batch.py
vasusen-code Feb 11, 2022
190fa16
Update __init__.py
vasusen-code Feb 11, 2022
958f9e2
Update __init__.py
vasusen-code Feb 11, 2022
04c256e
Update _batch.py
vasusen-code Feb 11, 2022
cb3a6fb
Update _batch.py
vasusen-code Feb 11, 2022
3d730d6
Update _batch.py
vasusen-code Feb 11, 2022
49f8ef2
Update _batch.py
vasusen-code Feb 11, 2022
9f00ea3
Update _batch.py
vasusen-code Feb 11, 2022
597780f
Update _batch.py
vasusen-code Feb 11, 2022
7754469
Update _batch.py
vasusen-code Feb 11, 2022
d0796c0
Update _batch.py
vasusen-code Feb 11, 2022
492f2db
Update _batch.py
vasusen-code Feb 11, 2022
e74f520
Update _batch.py
vasusen-code Feb 11, 2022
48b5b40
Update _batch.py
vasusen-code Feb 11, 2022
724115a
Update main.py
vasusen-code Feb 11, 2022
4fc280e
Update _batch.py
vasusen-code Feb 11, 2022
5cf44a3
Update _batch.py
vasusen-code Feb 11, 2022
2f3ecf1
Update _batch.py
vasusen-code Feb 11, 2022
348da68
Update _batch.py
vasusen-code Feb 11, 2022
76d45f5
Update main.py
vasusen-code Feb 11, 2022
526c671
Update main.py
vasusen-code Feb 11, 2022
ca6f3b8
Update main.py
vasusen-code Feb 11, 2022
b51e676
Update _batch.py
vasusen-code Feb 11, 2022
c976be3
Update _start.py
vasusen-code Feb 11, 2022
0a22214
Update main.py
vasusen-code Feb 11, 2022
6ad6e7b
Update _batch.py
vasusen-code Feb 11, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions main/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
BOT_TOKEN = config("BOT_TOKEN", default=None)
SESSION = config("SESSION", default=None)
FORCESUB = config("FORCESUB", default=None)
AUTH = config("AUTH", default=None, cast=int)

bot = TelegramClient('bot', API_ID, API_HASH).start(bot_token=BOT_TOKEN)

Expand Down
145 changes: 145 additions & 0 deletions main/plugins/_batch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
#Tg:MaheshChauhan/DroneBots
#Github.com/Vasusen-code

import time, os

from .. import bot as Drone
from .. import userbot, AUTH
from .. import FORCESUB as fs

from telethon import events, Button, errors
from telethon.tl.types import DocumentAttributeVideo

from ethon.pyfunc import video_metadata
from ethon.telefunc import fast_upload, fast_download, force_sub

from main.plugins.helpers import get_link, screenshot

ft = f"To use this bot you've to join @{fs}."

async def get_pvt_content(event, chat, id):
msg = await userbot.get_messages(chat, ids=id)
await event.client.send_message(event.chat_id, msg)

@Drone.on(events.NewMessage(incoming=True, from_users=AUTH, pattern='/batch'))
async def batch(event):
if not event.is_private:
return
s, r = await force_sub(event.client, fs, event.sender_id, ft)
if s == True:
await event.reply(r)
return
async with Drone.conversation(event.chat_id) as conv:
if s != True:
await conv.send_message("Send me the message link you want to start saving from, as a reply to this message.", buttons=Button.force_reply())
try:
link = await conv.get_reply()
except Exception as e:
print(e)
return await conv.send_message("Cannot wait more longer for your response!")
if not 't.me/c/' in link.text:
return await conv.send_message("Batch supported only for private restricted channels only!")
try:
_link = get_link(link.text)
chat = int('-100' + (str(_link)).split("/")[-2])
id = int((str(_link)).split("/")[-1])
except Exception as e:
print(e)
return await conv.send_message("**Invalid link!**")
await conv.send_message("Send me the number of files/range you want to save after the given message, as a reply to this message.", buttons=Button.force_reply())
try:
_range = await conv.get_reply()
except Exception as e:
print(e)
return await conv.send_message("Cannot wait more longer for your response!")
try:
value = int(_range.text)
if value > 100:
return await conv.send_message("You can only get 100 files in a single batch.")
except ValueError:
return await conv.send_message("Range must be an integer!")
try:
await userbot.get_messages(chat, ids=id)
except Exception as e:
print(e)
return await conv.send_message("Have you joined the channel?")
try:
await private_batch(event, chat, id, value)
conv.cancel()
except Exception as e:
print(e)
pass

async def private_batch(event, chat, offset, _range):
for i in range(_range):
timer = 60
if i < 25:
timer = 5
if i < 50 and i > 25:
timer = 10
if i < 100 and i > 50:
timer = 15
try:
try:
await get_pvt_content(event, chat, int(offset + i))
except Exception:
await get_res_content(event, chat, int(offset + i))
except errors.FloodWaitError as fw:
await asyncio.sleep(fw.seconds + 10)
try:
await get_pvt_content(event, chat, int(offset + i))
except Exception:
await get_res_content(event, chat, int(offset + i))
protection = await event.client.send_message(event.chat_id, f"Sleeping for `{timer}` seconds to avoid Floodwaits and Protect account!")
time.sleep(timer)
await protection.delete()

async def get_res_content(event, chat, id):
msg = await userbot.get_messages(chat, ids=id)
if msg is None:
await event.client.send_message(event.chat_id, f"Couldn't get this message:\n\nchannel:` {chat}`\nid: `{id}`")
return
try:
if msg.text and not msg.media:
await event.client.send_message(event.chat_id, msg.text)
if msg.media.webpage:
await event.client.send_message(event.chat_id, msg.text)
except Exception:
pass
name = msg.file.name
if not name:
if not msg.file.mime_type:
await event.client.send_message(event.chat_id, f"Couldn't get this message:\n\nchannel:` {chat}`\nid: `{id}`")
return
else:
if 'mp4' or 'x-matroska' in msg.file.mime_type:
name = f'{chat}' + '-' + f'{id}' + '.mp4'
edit = await event.client.send_message(event.chat_id, "Preparing to Download!")
await fast_download(name, msg.document, userbot, edit, time.time(), '**DOWNLOADING:**')
await edit.edit("Preparing to upload.")
if 'mp4' in msg.file.mime_type or 'x-matroska' in msg.file.mime_type:
metadata = video_metadata(name)
height = metadata["height"]
width = metadata["width"]
duration = metadata["duration"]
attributes = [DocumentAttributeVideo(duration=duration, w=width, h=height, supports_streaming=True)]
thumb = await screenshot(name, duration/2, event.sender_id)
caption = name
if msg.text:
caption=msg.text
uploader = await fast_upload(name, name, time.time(), event.client, edit, '**UPLOADING:**')
await event.client.send_file(event.chat_id, uploader, caption=caption, thumb=thumb, attributes=attributes, force_document=False)
await edit.delete()
os.remove(name)
else:
caption = name
if msg.text:
caption=msg.text
thumb=None
if os.path.exists(f'{event.sender_id}.jpg'):
thumb = f'{event.sender_id}.jpg'
uploader = await fast_upload(name, name, time.time(), event.client, edit, '**UPLOADING:**')
await event.client.send_file(event.chat_id, uploader, caption=caption, thumb=thumb, force_document=True)
await edit.delete()
os.remove(name)

3 changes: 2 additions & 1 deletion main/plugins/_start.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@ async def remt(event):

@Drone.on(events.NewMessage(incoming=True, pattern=f"{S}"))
async def start(event):
await start_srb(event)
text = "Send me Link of any message to clone it here, For private channel message, send invite link first.\n\n**SUPPORT:** @TeamDrone"
await start_srb(event, text)

22 changes: 11 additions & 11 deletions main/plugins/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,19 @@

from main.plugins.helpers import get_link, join, screenshot

ft = f"To use this bot you've to join @{fs}."

@Drone.on(events.NewMessage(incoming=True, func=lambda e: e.is_private))
async def clone(event):
if event.is_reply:
return
try:
link = get_link(event.text)
if not link:
return
except TypeError:
return
s, r = await force_sub(event.client, fs, event.sender_id)
s, r = await force_sub(event.client, fs, event.sender_id, ft)
if s == True:
await event.reply(r)
return
Expand All @@ -46,16 +50,12 @@ async def clone(event):
return
if file and file.text:
try:
if not file.media:
await edit.edit(file.text)
return
if not file.file.name:
await edit.edit(file.text)
return
except:
if file.media.webpage:
await edit.edit(file.text)
return
if msg.text and not msg.media:
await event.client.send_message(event.chat_id, msg.text)
if msg.media.webpage:
await event.client.send_message(event.chat_id, msg.text)
except Exception:
pass
name = file.file.name
if not name:
if not file.file.mime_type:
Expand Down