-
Notifications
You must be signed in to change notification settings - Fork 3k
Expand file tree
/
Copy pathstart.py
More file actions
64 lines (56 loc) · 2.36 KB
/
start.py
File metadata and controls
64 lines (56 loc) · 2.36 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
#Github.com/Vasusen-code
import os
from .. import bot
from telethon import events, Button, TelegramClient
from pyrogram import idle
from main.plugins.main import Bot, userbot
st = "Send me Link of any message to clone it here, For private channel message, send invite link first.\n\n**SUPPORT:** @mehulsupport\n**DEV:** @Patil_Mehul"
@bot.on(events.NewMessage(incoming=True, pattern="/start"))
async def start(event):
await event.reply(f'{st}',
buttons=[
[Button.inline("SET THUMB.", data="sett"),
Button.inline("REM THUMB.", data="remt")]
])
try:
await Bot.start()
await userbot.start()
await idle()
except Exception as e:
if 'Client is already connected' in str(e):
pass
else:
await event.client.send_message(event.chat_id, "Error while starting Client, check if your API and SESSION is right.")
return
@bot.on(events.callbackquery.CallbackQuery(data="sett"))
async def sett(event):
Drone = event.client
button = await event.get_message()
msg = await button.get_reply_message()
await event.delete()
async with Drone.conversation(event.chat_id) as conv:
xx = await conv.send_message("Send me any image for thumbnail as a `reply` to this message.")
x = await conv.get_reply()
if not x.media:
xx.edit("No media found.")
mime = x.file.mime_type
if not 'png' in mime:
if not 'jpg' in mime:
if not 'jpeg' in mime:
return await xx.edit("No image found.")
await xx.delete()
t = await event.client.send_message(event.chat_id, 'Trying.')
path = await event.client.download_media(x.media)
if os.path.exists(f'{event.sender_id}.jpg'):
os.remove(f'{event.sender_id}.jpg')
os.rename(path, f'./{event.sender_id}.jpg')
await t.edit("Temporary thumbnail saved!")
@bot.on(events.callbackquery.CallbackQuery(data="remt"))
async def remt(event):
Drone = event.client
await event.edit('Trying.')
try:
os.remove(f'{event.sender_id}.jpg')
await event.edit('Removed!')
except Exception:
await event.edit("No thumbnail saved.")