From e109dc513dabb86d74a01d8cfc5973a4589ecc46 Mon Sep 17 00:00:00 2001 From: Emilia <85098155+Emilia-EMT@users.noreply.github.com> Date: Tue, 16 Apr 2024 20:02:58 +0800 Subject: [PATCH] =?UTF-8?q?qu=20=E4=BA=BA=E5=BD=A2=20@fish=5Fquote=5Freply?= =?UTF-8?q?=5Fbot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: omg-xtao <100690902+omg-xtao@users.noreply.github.com> --- qu/DES.md | 1 + qu/main.py | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 qu/DES.md create mode 100644 qu/main.py diff --git a/qu/DES.md b/qu/DES.md new file mode 100644 index 0000000..d5dd56d --- /dev/null +++ b/qu/DES.md @@ -0,0 +1 @@ +人形 @fish_quote_reply_bot \ No newline at end of file diff --git a/qu/main.py b/qu/main.py new file mode 100644 index 0000000..2b0bbf4 --- /dev/null +++ b/qu/main.py @@ -0,0 +1,61 @@ +from typing import Union, Tuple + +from pyrogram.types import User, Chat + +from pagermaid.enums import Client, Message +from pagermaid.listener import listener + + +def get_text(opt: str, opt1: str, user1: Union[User, Chat], user2: Union[User, Chat]) -> str: + first = user1.mention + second = user2.mention + return f"{first} {opt} {second} {opt1}!" + + +def get_second_chat(message: Message, me: User) -> Union[User, Chat]: + if not message.reply_to_message: + return me + reply = message.reply_to_message + if reply.from_user: + return reply.from_user + if reply.sender_chat: + return reply.sender_chat + return me + + +def get_opt(message: Message) -> Tuple[str, str]: + text = message.arguments + # 分割命令和参数 + opt, _, opt1 = text.partition(' ') + # opt1 为空的话给 opt 加个"了" + if opt and not opt1: + opt += "了" + return opt, opt1 + + +@listener(command="qu", description=r"使用“qu”代替“/”,以拙劣地模仿 @fish_quote_reply_bot") +async def qu(bot: Client, message: Message): + me = await bot.get_me() + # 分割命令和参数 + opt, opt1 = get_opt(message) + # opt 为空报错 + if not opt: + return await message.edit("E:未指定内容") + user1 = me + user2 = get_second_chat(message, me) + text = get_text(opt, opt1, user1, user2) + await message.edit(text, disable_web_page_preview=True) + + +@listener(command="uq", description=r"使用“uq”代替“\”,以拙劣地模仿 @fish_quote_reply_bot") +async def uq(bot: Client, message: Message): + me = await bot.get_me() + # 分割命令和参数 + opt, opt1 = get_opt(message) + # opt 为空报错 + if not opt: + return await message.edit("E:未指定内容") + user1 = me + user2 = get_second_chat(message, me) + text = get_text(opt, opt1, user2, user1) + await message.edit(text, disable_web_page_preview=True)