|
| 1 | +# Moon-Userbot - telegram userbot |
| 2 | +# Copyright (C) 2020-present Moon Userbot Organization |
| 3 | +# |
| 4 | +# This program is free software: you can redistribute it and/or modify |
| 5 | +# it under the terms of the GNU General Public License as published by |
| 6 | +# the Free Software Foundation, either version 3 of the License, or |
| 7 | +# (at your option) any later version. |
| 8 | + |
| 9 | +# This program is distributed in the hope that it will be useful, |
| 10 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | +# GNU General Public License for more details. |
| 13 | + |
| 14 | +# You should have received a copy of the GNU General Public License |
| 15 | +# along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 16 | + |
| 17 | +from pyrogram import Client, filters |
| 18 | +from pyrogram.types import Message |
| 19 | +from pyrogram.types.user_and_chats.user import Link |
| 20 | + |
| 21 | +from utils.misc import modules_help, prefix |
| 22 | + |
| 23 | + |
| 24 | +def custom_mention(user, custom_text): |
| 25 | + return Link( |
| 26 | + f"tg://user?id={user.id}", |
| 27 | + custom_text, |
| 28 | + user._client.parse_mode, |
| 29 | + ) |
| 30 | + |
| 31 | + |
| 32 | +@Client.on_message(filters.command("mention", prefix) & filters.me) |
| 33 | +async def example_edit(_: Client, message: Message): |
| 34 | + if message.reply_to_message: |
| 35 | + user = message.reply_to_message.from_user |
| 36 | + custom_text = ( |
| 37 | + message.text.split(maxsplit=1)[1] if len(message.text.split()) > 1 else None |
| 38 | + ) |
| 39 | + if custom_text: |
| 40 | + await message.edit(custom_mention(user, custom_text)) |
| 41 | + else: |
| 42 | + await message.edit(user.mention) |
| 43 | + else: |
| 44 | + await message.edit("Please reply to a message to mention the user.") |
| 45 | + await message.delete() |
| 46 | + |
| 47 | + |
| 48 | +modules_help["mention"] = { |
| 49 | + "mention [custom_text]": "Mention the user you replied to with custom text.", |
| 50 | + "mention": "Mention the user you replied to with their username.", |
| 51 | +} |
0 commit comments