Skip to content
Open

. #1

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
3e3adf3
Merge pull request #1 from V-Ujjwal/main
Ujjwalm2004 Apr 22, 2023
f54b163
Update send_file.py
Ujjwalm2004 Apr 22, 2023
6686853
Update send_file.py
Ujjwalm2004 Apr 22, 2023
1d89166
Update send_file.py
Ujjwalm2004 Apr 22, 2023
5c228e0
Update send_file.py
Ujjwalm2004 Apr 22, 2023
cbacadc
Update send_file.py
Ujjwalm2004 Apr 22, 2023
02b4fe4
Update send_file.py
Ujjwalm2004 Apr 22, 2023
6879c03
Update send_file.py
Ujjwalm2004 Apr 22, 2023
acc269a
Update send_file.py
Ujjwalm2004 Apr 22, 2023
5c2f070
Update send_file.py
Ujjwalm2004 Apr 22, 2023
a1bf395
Update send_file.py
Ujjwalm2004 Apr 22, 2023
e5ee2b7
Update send_file.py
Ujjwalm2004 Apr 22, 2023
63edc80
Update send_file.py
Ujjwalm2004 Apr 22, 2023
dda95da
Update send_file.py
Ujjwalm2004 Apr 22, 2023
ef6f57c
Update send_file.py
Ujjwalm2004 Apr 22, 2023
9602dff
Update send_file.py
Ujjwalm2004 Apr 22, 2023
7006423
Update bot.py
Ujjwalm2004 Apr 22, 2023
affaf38
Update bot.py
Ujjwalm2004 Apr 22, 2023
e74fa08
Update bot.py
Ujjwalm2004 Apr 22, 2023
6560add
Update bot.py
Ujjwalm2004 Apr 22, 2023
fafab4f
Update bot.py
Ujjwalm2004 Apr 22, 2023
2a93220
Update bot.py
Ujjwalm2004 Apr 22, 2023
293e4af
Update send_file.py
Ujjwalm2004 Apr 22, 2023
b7dc7f4
Update send_file.py
Ujjwalm2004 Apr 22, 2023
313ee7b
Update send_file.py
Ujjwalm2004 Apr 22, 2023
a03072a
Update bot.py
Ujjwalm2004 Apr 22, 2023
1ba883c
Update bot.py
Ujjwalm2004 Apr 22, 2023
51d28ec
Update send_file.py
Ujjwalm2004 Apr 22, 2023
499297a
Update bot.py
Ujjwalm2004 Apr 22, 2023
0dc2f61
Update bot.py
Ujjwalm2004 Apr 22, 2023
2b83436
Update send_file.py
Ujjwalm2004 Apr 22, 2023
f6dd8b2
Update send_file.py
Ujjwalm2004 Apr 22, 2023
ca735d5
Update send_file.py
Ujjwalm2004 Apr 22, 2023
8b63c15
Update send_file.py
Ujjwalm2004 Apr 22, 2023
b24a654
Update send_file.py
Ujjwalm2004 Apr 23, 2023
c638bf0
Update send_file.py
Ujjwalm2004 Apr 23, 2023
0807ce0
Update send_file.py
Ujjwalm2004 Apr 23, 2023
b9142bf
Update send_file.py
Ujjwalm2004 Apr 23, 2023
cd7dabf
Update send_file.py
Ujjwalm2004 Apr 23, 2023
b81f4e9
Update send_file.py
Ujjwalm2004 Apr 23, 2023
0ff3c5f
Update send_file.py
Ujjwalm2004 Apr 23, 2023
a467fed
Update send_file.py
Ujjwalm2004 Apr 23, 2023
c28b1f7
Update send_file.py
Ujjwalm2004 Apr 23, 2023
f360aea
Update send_file.py
Ujjwalm2004 Apr 23, 2023
9b4313e
Update send_file.py
Ujjwalm2004 Apr 23, 2023
a037860
Update send_file.py
Ujjwalm2004 Apr 23, 2023
1d4bdbd
Update send_file.py
Ujjwalm2004 Apr 23, 2023
15ca27a
Update send_file.py
Ujjwalm2004 Apr 23, 2023
559f5d2
Update send_file.py
Ujjwalm2004 Apr 23, 2023
4f7c6d6
Update send_file.py
Ujjwalm2004 Apr 23, 2023
87fed8d
Update send_file.py
Ujjwalm2004 Apr 23, 2023
fe58e3d
Update send_file.py
Ujjwalm2004 Apr 23, 2023
cbc7dfd
Update bot.py
Ujjwalm2004 Apr 23, 2023
2ec16f9
Update send_file.py
Ujjwalm2004 Apr 23, 2023
f5f4260
Update bot.py
Ujjwalm2004 Apr 23, 2023
da74031
Update bot.py
Ujjwalm2004 Apr 23, 2023
b52303c
Update bot.py
Ujjwalm2004 Apr 23, 2023
7e3ede0
Update bot.py
Ujjwalm2004 Apr 23, 2023
b21f24c
Update bot.py
Ujjwalm2004 Apr 23, 2023
ee3eb43
Update bot.py
Ujjwalm2004 Apr 23, 2023
39ca91f
Update bot.py
Ujjwalm2004 Apr 23, 2023
84c8cbe
Update bot.py
Ujjwalm2004 Apr 23, 2023
5434fc7
Update send_file.py
Ujjwalm2004 Apr 23, 2023
c1db8d8
Update bot.py
Ujjwalm2004 Apr 23, 2023
ba7904c
Update bot.py
Ujjwalm2004 Apr 23, 2023
ced3701
Update bot.py
Ujjwalm2004 Apr 23, 2023
03e415f
Update bot.py
Ujjwalm2004 Apr 23, 2023
efc7cc6
Update bot.py
Ujjwalm2004 Apr 23, 2023
b92622c
Update bot.py
Ujjwalm2004 Apr 23, 2023
85b8004
Update bot.py
Ujjwalm2004 Apr 23, 2023
f4615a3
Update bot.py
Ujjwalm2004 Apr 23, 2023
7f795ff
Update bot.py
Ujjwalm2004 Apr 23, 2023
54a7ac9
Update bot.py
Ujjwalm2004 Apr 23, 2023
08ac321
Update bot.py
Ujjwalm2004 Apr 23, 2023
4488c6a
Update bot.py
Ujjwalm2004 Apr 23, 2023
03bd4ee
Update bot.py
Ujjwalm2004 Apr 23, 2023
1e4ae0c
Update bot.py
Ujjwalm2004 Apr 23, 2023
766f38f
Update bot.py
Ujjwalm2004 Apr 23, 2023
663010e
Rename send_file.py to Ntg.txt
Ujjwalm2004 May 1, 2023
bb8f04b
Add files via upload
Ujjwalm2004 May 1, 2023
7fd42ae
Update send_file.py
Ujjwalm2004 May 1, 2023
f6bef89
Update bot.py
Ujjwalm2004 May 2, 2023
d2bc28f
Update bot.py
Ujjwalm2004 May 2, 2023
300d5d5
Update send_file.py
Ujjwalm2004 May 2, 2023
ce42d91
Update bot.py
Ujjwalm2004 May 2, 2023
ec147ef
Update send_file.py
Ujjwalm2004 May 2, 2023
63ed894
Update bot.py
Ujjwalm2004 May 2, 2023
2b78291
Update bot.py
Ujjwalm2004 May 2, 2023
a1e865b
Update bot.py
Ujjwalm2004 May 2, 2023
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
34 changes: 24 additions & 10 deletions bot.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#@MxA_Bots | @iSmartBoi_Ujjwal

import os
import time
import asyncio
import traceback
from binascii import (
Expand All @@ -25,7 +26,7 @@
from configs import Config
from handlers.database import db
from handlers.add_user_to_db import add_user_to_database
from handlers.send_file import send_media_and_reply
from handlers.send_file import send_media
from handlers.helpers import b64_to_str, str_to_b64
from handlers.check_user_status import handle_user_status
from handlers.force_sub_handler import (
Expand All @@ -48,6 +49,7 @@
api_hash=Config.API_HASH
)

DELETE_TIME = 20

@Bot.on_message(filters.private)
async def _(bot: Client, cmd: Message):
Expand Down Expand Up @@ -98,18 +100,30 @@ async def start(bot: Client, cmd: Message):
message_ids = []
if GetMessage.text:
message_ids = GetMessage.text.split(" ")
_response_msg = await cmd.reply_text(
text=f"**Total Files:** `{len(message_ids)}`",
quote=True,
disable_web_page_preview=True
)
#_response_msg = await cmd.reply_text(
#text=f"**Total Files:** `{len(message_ids)}`",
# quote=True,
# disable_web_page_preview=True
# )
# else:
#message_ids.append(int(GetMessage.id))
# for i in range(len(message_ids)):
#await send_media_and_reply(bot, user_id=cmd.from_user.id, file_id=int(message_ids[i]))
# except Exception as err:
# await cmd.reply_text('files will delete after few seconds')
else:
message_ids.append(int(GetMessage.id))
files = reply_message.media
sent_messages = []
for i in range(len(message_ids)):
await send_media_and_reply(bot, user_id=cmd.from_user.id, file_id=int(message_ids[i]))
except Exception as err:
await cmd.reply_text(f"Something went wrong!\n\n**Error:** `{err}`")

# for file in files:
sent_message = await message.send_media(bot, user_id=cmd.from_user.id, file_id=int(message_ids[i]))
sent_messages.append(sent_message) # for batch files
await asyncio.sleep(DELETE_TIME) # Wait for 20 seconds
for sent_message in sent_messages:
await sent_message.delete() # Delete all files
except:
pass

@Bot.on_message((filters.document | filters.video | filters.audio) & ~filters.chat(Config.DB_CHANNEL))
async def main(bot: Client, message: Message):
Expand Down
56 changes: 56 additions & 0 deletions handlers/Ntg.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#@MxA_Bots | @iSmartBoi_Ujjwal

import asyncio
from configs import Config
from pyrogram import Client
from pyrogram.types import Message
from pyrogram.errors import FloodWait
from handlers.helpers import str_to_b64
import time

async def reply_forward(message: Message, file_id: int):
try:
await message.reply_text(
f"**Files will be Deleted After few seconds ⏰**\n",
disable_web_page_preview=True, quote=True)
except FloodWait as e:
await asyncio.sleep(e.value)
await reply_forward(message, file_id)


async def media_forward(bot: Client, user_id: int, file_id: int):
try:
if Config.FORWARD_AS_COPY is True:
return await bot.copy_message(chat_id=user_id, from_chat_id=Config.DB_CHANNEL,
message_id=file_id)
elif Config.FORWARD_AS_COPY is False:
return await bot.forward_messages(chat_id=user_id, from_chat_id=Config.DB_CHANNEL,
message_ids=file_id)
except FloodWait as e:
await asyncio.sleep(e.value)
return media_forward(bot, user_id, file_id)


async def delete_file(file_id: int):
await asyncio.sleep(10) # wait for 20 seconds
# Delete the file using the file ID
# Code to delete the file goes here


async def send_media_and_reply(bot: Client, user_id: int, file_id: int):
sent_message = await media_forward(bot, user_id, file_id)
# await reply_forward(message=sent_message, file_id=file_id)
time.sleep(1)
return sent_message
#await sent_message.delete(delete_file(file_id=file_id)) # schedule the file deletion task

#async def send_files(bot, user_id, file_ids):
#for file_id in file_ids:
# bot.send_chat_action(user_id=user_id, action=telegram.ChatAction.SEND_DOCUMENT)
# bot.send_document(user_id=user_id, document=file_id)
# Wait for 30 seconds before deleting files
# time.sleep(30)

# # Delete all files after the last file has been sent
# for file_id in file_ids:
# bot.delete_message(user_id=user_id, message_id=file_id)
41 changes: 30 additions & 11 deletions handlers/send_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
from pyrogram.errors import FloodWait
from handlers.helpers import str_to_b64


async def reply_forward(message: Message, file_id: int):
try:
await message.reply_text(
f"**Files will be Deleted After few seconds ⏰**\n",
f"**Files will be Deleted After 1 min**\n"
f"💡Forward it to saved massages or anywhere before downloading.😁\n"
f"😇Join @Movies_X_Animes",
disable_web_page_preview=True, quote=True)
except FloodWait as e:
await asyncio.sleep(e.value)
Expand All @@ -23,6 +24,7 @@ async def media_forward(bot: Client, user_id: int, file_id: int):
if Config.FORWARD_AS_COPY is True:
return await bot.copy_message(chat_id=user_id, from_chat_id=Config.DB_CHANNEL,
message_id=file_id)

elif Config.FORWARD_AS_COPY is False:
return await bot.forward_messages(chat_id=user_id, from_chat_id=Config.DB_CHANNEL,
message_ids=file_id)
Expand All @@ -31,14 +33,31 @@ async def media_forward(bot: Client, user_id: int, file_id: int):
return media_forward(bot, user_id, file_id)


async def delete_file(file_id: int):
await asyncio.sleep(50) # wait for 50 seconds
# Delete the file using the file ID
# Code to delete the file goes here
# async def send_media_and_reply(bot: Client, user_id: int, file_id: int):
# sent_message = await media_forward(bot, user_id, file_id)
# await asyncio.sleep(1)
# return sent_message
# n = await reply_forward(message=sent_message, file_id=file_id)
# await asyncio.sleep(60)
# await sent_message.delete()
# await asyncio.sleep(0.5)
# await n.delete()


async def send_media(bot: Client, user_id: int, file_id: int):
new_message = await media_forward(bot, user_id, file_id)
await asyncio.sleep(1)
return new_message













async def send_media_and_reply(bot: Client, user_id: int, file_id: int):
sent_message = await media_forward(bot, user_id, file_id)
await reply_forward(message=sent_message, file_id=file_id)
asyncio.create_task(delete_file(file_id)) # schedule the file deletion task
await asyncio.sleep(2)