MCPcopy Index your code
hub / github.com/CodeXBotz/File-Sharing-Bot / start_command

Function start_command

plugins/start.py:22–108  ·  view source on GitHub ↗
(client: Client, message: Message)

Source from the content-addressed store, hash-verified

20
21@Bot.on_message(filters.command('start') & filters.private & subscribed)
22async def start_command(client: Client, message: Message):
23 id = message.from_user.id
24 if not await present_user(id):
25 try:
26 await add_user(id)
27 except:
28 pass
29 text = message.text
30 if len(text)>7:
31 try:
32 base64_string = text.split(" ", 1)[1]
33 except:
34 return
35 string = await decode(base64_string)
36 argument = string.split("-")
37 if len(argument) == 3:
38 try:
39 start = int(int(argument[1]) / abs(client.db_channel.id))
40 end = int(int(argument[2]) / abs(client.db_channel.id))
41 except:
42 return
43 if start <= end:
44 ids = range(start,end+1)
45 else:
46 ids = []
47 i = start
48 while True:
49 ids.append(i)
50 i -= 1
51 if i < end:
52 break
53 elif len(argument) == 2:
54 try:
55 ids = [int(int(argument[1]) / abs(client.db_channel.id))]
56 except:
57 return
58 temp_msg = await message.reply("Please wait...")
59 try:
60 messages = await get_messages(client, ids)
61 except:
62 await message.reply_text("Something went wrong..!")
63 return
64 await temp_msg.delete()
65
66 for msg in messages:
67
68 if bool(CUSTOM_CAPTION) & bool(msg.document):
69 caption = CUSTOM_CAPTION.format(previouscaption = "" if not msg.caption else msg.caption.html, filename = msg.document.file_name)
70 else:
71 caption = "" if not msg.caption else msg.caption.html
72
73 if DISABLE_CHANNEL_BUTTON:
74 reply_markup = msg.reply_markup
75 else:
76 reply_markup = None
77
78 try:
79 await msg.copy(chat_id=message.from_user.id, caption = caption, parse_mode = ParseMode.HTML, reply_markup = reply_markup, protect_content=PROTECT_CONTENT)

Callers

nothing calls this directly

Calls 4

present_userFunction · 0.90
add_userFunction · 0.90
decodeFunction · 0.90
get_messagesFunction · 0.90

Tested by

no test coverage detected