MCPcopy
hub / github.com/vasusen-code/SaveRestrictedContentBot / get_msg

Function get_msg

main/plugins/pyroplug.py:23–213  ·  view source on GitHub ↗

userbot: PyrogramUserBot client: PyrogramBotClient bot: TelethonBotClient

(userbot, client, bot, sender, edit_id, msg_link, i)

Source from the content-addressed store, hash-verified

21 return None
22
23async def get_msg(userbot, client, bot, sender, edit_id, msg_link, i):
24
25 """ userbot: PyrogramUserBot
26 client: PyrogramBotClient
27 bot: TelethonBotClient """
28
29 edit = ""
30 chat = ""
31 round_message = False
32 if "?single" in msg_link:
33 msg_link = msg_link.split("?single")[0]
34 msg_id = int(msg_link.split("/")[-1]) + int(i)
35 height, width, duration, thumb_path = 90, 90, 0, None
36 if 't.me/c/' or 't.me/b/' in msg_link:
37 if 't.me/b/' in msg_link:
38 chat = str(msg_link.split("/")[-2])
39 else:
40 chat = int('-100' + str(msg_link.split("/")[-2]))
41 file = ""
42 try:
43 msg = await userbot.get_messages(chat, msg_id)
44 if msg.media:
45 if msg.media==MessageMediaType.WEB_PAGE:
46 edit = await client.edit_message_text(sender, edit_id, "Cloning.")
47 await client.send_message(sender, msg.text.markdown)
48 await edit.delete()
49 return
50 if not msg.media:
51 if msg.text:
52 edit = await client.edit_message_text(sender, edit_id, "Cloning.")
53 await client.send_message(sender, msg.text.markdown)
54 await edit.delete()
55 return
56 edit = await client.edit_message_text(sender, edit_id, "Trying to Download.")
57 file = await userbot.download_media(
58 msg,
59 progress=progress_for_pyrogram,
60 progress_args=(
61 client,
62 "**DOWNLOADING:**\n",
63 edit,
64 time.time()
65 )
66 )
67 print(file)
68 await edit.edit('Preparing to Upload!')
69 caption = None
70 if msg.caption is not None:
71 caption = msg.caption
72 if msg.media==MessageMediaType.VIDEO_NOTE:
73 round_message = True
74 print("Trying to get metadata")
75 data = video_metadata(file)
76 height, width, duration = data["height"], data["width"], data["duration"]
77 print(f'd: {duration}, w: {width}, h:{height}')
78 try:
79 thumb_path = await screenshot(file, duration, sender)
80 except Exception:

Callers 2

cloneFunction · 0.90
get_bulk_msgFunction · 0.85

Calls 2

screenshotFunction · 0.90
thumbnailFunction · 0.85

Tested by

no test coverage detected