forked from Createbots23/TGVid-Comp
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstart.py
More file actions
98 lines (74 loc) · 4.79 KB
/
start.py
File metadata and controls
98 lines (74 loc) · 4.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import asyncio
import shutil
import humanize
from time import sleep
from config import Config
from script import Txt
from helper.database import db
from pyrogram.errors import FloodWait
from pyrogram import Client, filters, enums
from .check_user_status import handle_user_status
from pyrogram.types import Message, InlineKeyboardButton, InlineKeyboardMarkup
@Client.on_message((filters.private | filters.group))
async def _(bot: Client, cmd: Message):
await handle_user_status(bot, cmd)
@Client.on_message((filters.private | filters.group) & filters.command('start'))
async def Handle_StartMsg(bot:Client, msg:Message):
Snowdev = await msg.reply_text(text= '**Please Wait...**', reply_to_message_id=msg.id)
if msg.chat.type == enums.ChatType.SUPERGROUP and not await db.is_user_exist(msg.from_user.id):
botusername = await bot.get_me()
btn = [
[InlineKeyboardButton(text='⚡ BOT PM', url=f'https://t.me/{botusername.username}')],
[InlineKeyboardButton(text='💻 Dᴇᴠᴇʟᴏᴘᴇʀ', url='https://t.me/Snowball_Official')]
]
await Snowdev.edit(text=Txt.GROUP_START_MSG.format(msg.from_user.mention), reply_markup=InlineKeyboardMarkup(btn))
else:
btn = [
[InlineKeyboardButton(text='❗ Hᴇʟᴘ', callback_data='help'), InlineKeyboardButton(text='🌨️ Aʙᴏᴜᴛ', callback_data='about')],
[InlineKeyboardButton(text='📢 Uᴘᴅᴀᴛᴇs', url='https://t.me/AIORFT'), InlineKeyboardButton(text='💻 Dᴇᴠᴇʟᴏᴘᴇʀ', url='https://t.me/Snowball_Official')]
]
if Config.START_PIC:
await Snowdev.delete()
await msg.reply_photo(photo=Config.START_PIC, caption=Txt.PRIVATE_START_MSG.format(msg.from_user.mention), reply_markup=InlineKeyboardMarkup(btn), reply_to_message_id=msg.id)
else:
await Snowdev.delete()
await msg.reply_text(text=Txt.PRIVATE_START_MSG.format(msg.from_user.mention), reply_markup=InlineKeyboardMarkup(btn), reply_to_message_id=msg.id)
@Client.on_message((filters.private | filters.group) & (filters.document | filters.audio | filters.video) & filters.user(Config.ADMIN))
async def Files_Option(bot:Client, message:Message):
SnowDev = await message.reply_text(text='**Please Wait**', reply_to_message_id=message.id)
if message.chat.type == enums.ChatType.SUPERGROUP and not await db.is_user_exist(message.from_user.id):
botusername = await bot.get_me()
btn = [
[InlineKeyboardButton(text='⚡ BOT PM', url=f'https://t.me/{botusername.username}')],
[InlineKeyboardButton(text='💻 Dᴇᴠᴇʟᴏᴘᴇʀ', url='https://t.me/Snowball_Official')]
]
return await SnowDev.edit(text=Txt.GROUP_START_MSG.format(message.from_user.mention), reply_markup=InlineKeyboardMarkup(btn))
file = getattr(message, message.media.value)
filename = file.file_name
filesize = humanize.naturalsize(file.file_size)
try:
text = f"""**__What do you want me to do with this file.?__**\n\n**File Name** :- `{filename}`\n\n**File Size** :- `{filesize}`"""
buttons = [[InlineKeyboardButton("Rᴇɴᴀᴍᴇ 📝", callback_data=f"rename-{message.from_user.id}")],
[InlineKeyboardButton("Cᴏᴍᴘʀᴇss 🗜️", callback_data=f"compress-{message.from_user.id}")]]
await SnowDev.edit(text=text, reply_markup=InlineKeyboardMarkup(buttons))
except FloodWait as e:
floodmsg = await message.reply_text(f"**😥 Pʟᴇᴀsᴇ Wᴀɪᴛ ᴅᴏɴ'ᴛ ᴅᴏ ғʟᴏᴏᴅɪɴɢ ᴡᴀɪᴛ ғᴏʀ {e.value} Sᴇᴄᴄᴏɴᴅs**", reply_to_message_id=message.id)
await sleep(e.value)
await floodmsg.delete()
text = f"""**__What do you want me to do with this file.?__**\n\n**File Name** :- `{filename}`\n\n**File Size** :- `{filesize}`"""
buttons = [[InlineKeyboardButton("Rᴇɴᴀᴍᴇ 📝", callback_data=f"rename-{message.from_user.id}")],
[InlineKeyboardButton("Cᴏᴍᴘʀᴇss 🗜️", callback_data=f"compress-{message.from_user.id}")]]
await SnowDev.edit(text=text, reply_markup=InlineKeyboardMarkup(buttons))
except Exception as e:
print(e)
@Client.on_message((filters.private | filters.group) & filters.command('cancel'))
async def cancel_process(bot:Client, message:Message):
try:
shutil.rmtree(f"encode/{message.from_user.id}")
shutil.rmtree(f"ffmpeg/{message.from_user.id}")
shutil.rmtree(f"Renames/{message.from_user.id}")
shutil.rmtree(f"Metadata/{message.from_user.id}")
shutil.rmtree(f"Screenshot_Generation/{message.from_user.id}")
return await message.reply_text(text="**Canceled All On Going Processes ✅**")
except BaseException:
pass