-
Notifications
You must be signed in to change notification settings - Fork 3k
Expand file tree
/
Copy pathfrontend.py
More file actions
50 lines (42 loc) · 1.55 KB
/
frontend.py
File metadata and controls
50 lines (42 loc) · 1.55 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
#Github.com/Vasusen-code
import time, os
from .. import bot as Drone
from .. import userbot, Bot
from .. import FORCESUB as fs
from main.plugins.pyroplug import get_msg
from main.plugins.helpers import get_link, join
from main.utils import logger
from telethon import events
from pyrogram.errors import FloodWait
from ethon.telefunc import force_sub
ft = f"To use this bot you've to join @{fs}."
message = "Send me the message link you want to start saving from, as a reply to this message."
@Drone.on(events.NewMessage(incoming=True, func=lambda e: e.is_private))
async def clone(event):
if event.is_reply:
reply = await event.get_reply_message()
if reply.text == message:
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, ft)
if s == True:
await event.reply(r)
return
edit = await event.reply("Processing!")
try:
if 't.me/+' in link:
q = await join(userbot, link)
await edit.edit(q)
return
if 't.me/' in link:
await get_msg(userbot, Bot, Drone, event.sender_id, edit.id, link, 0)
except FloodWait as fw:
return await Drone.send_message(event.sender_id, f'Try again after {fw.x} seconds due to floodwait from telegram.')
except Exception as e:
logger.error(e)
await Drone.send_message(event.sender_id, f"An error occurred during cloning of `{link}`\n\n**Error:** {str(e)}")