|
1 | 1 | import os
|
2 | 2 | import shutil
|
| 3 | + |
3 | 4 | from pyrogram import Client, filters
|
4 | 5 | from pyrogram.types import Message
|
5 | 6 |
|
|
10 | 11 | async def in_f(client: Client, message: Message):
|
11 | 12 | if message.reply_to_message.document:
|
12 | 13 | module = await client.download_media(message.reply_to_message)
|
| 14 | + module_name = os.path.basename(module) |
13 | 15 | if os.path.exists(module):
|
14 |
| - shutil.copyfile(module, f"modules/custom_modules/{module}") |
15 |
| - await message.edit(f"<b>Module {module} downloaded succesfully restartin UB!</b>") |
16 |
| - restart() |
17 |
| - else: |
18 |
| - await message.edit( |
19 |
| - f"<b>Usage: </b><code>{prefix}dlf [reply to a file]</code>" |
20 |
| - ) |
| 16 | + shutil.move(module, f"modules/custom_modules/{module_name}") |
| 17 | + await message.edit(f"<b>Module {module_name} downloaded successfully, restarting UB!</b>") |
| 18 | + restart() |
| 19 | + else: |
| 20 | + await message.edit(f"<b>Usage: </b><code>{prefix}dlf [reply to a file]</code>") |
21 | 21 |
|
22 | 22 | @Client.on_message(filters.command("un", prefix) & filters.me)
|
23 | 23 | async def un_f(client: Client, message: Message):
|
24 | 24 | if message.reply_to_message.document:
|
25 | 25 | module = message.reply_to_message.document.file_name
|
26 | 26 | if os.path.exists(f"modules/custom_modules/{module}"):
|
27 | 27 | os.remove(f"modules/custom_modules/{module}")
|
28 |
| - await message.edit(f"<b>Module {module} removed succesfully restarting UB!</b>") |
| 28 | + await message.edit(f"<b>Module {module} removed successfully, restarting UB!</b>") |
29 | 29 | restart()
|
30 | 30 | else:
|
31 | 31 | await message.edit(f"<b>Module {module} not found!</b>")
|
32 | 32 | else:
|
33 |
| - await message.edit( |
34 |
| - f"<b>Usage: </b><code>{prefix}ulf [reply to a module name]</code>" |
35 |
| - ) |
| 33 | + await message.edit(f"<b>Usage: </b><code>{prefix}un [reply to a module name]</code>") |
36 | 34 |
|
37 |
| -modules_help = { |
| 35 | +modules_help["in"] = { |
38 | 36 | "in [reply*]": "Download a module from telegram",
|
39 | 37 | "un [reply*]": "Remove a module from telegram"
|
40 | 38 | }
|
0 commit comments