from pyrogram import Client, filters from pyrogram.types import Message from defs.source import from_keyword_to_module from defs.subs import gen_subs_msg, gen_back_button, add_to_subs, remove_from_subs from plugins.start import sub_msg, not_found_msg, already_sub_msg, unsub_msg, not_sub_msg sub_help_msg = """ 👩🏻‍💼 » /subscribe 包名|关键词|作用域|开源地址|模块地址 - 订阅更新 /subscribe nil.nadph.qnotified /subscribe QNotified /subscribe com.tencent.mobileqq /subscribe https://github.com/ferredoxin/QNotified /subscribe https://modules.lsposed.org/module/nil.nadph.qnotified """ unsub_help_msg = """ 👩🏻‍💼 » /unsubscribe 包名|关键词|作用域|开源地址|模块地址 - 取消订阅更新 /unsubscribe nil.nadph.qnotified /unsubscribe QNotified /unsubscribe com.tencent.mobileqq /unsubscribe https://github.com/ferredoxin/QNotified /unsubscribe https://modules.lsposed.org/module/nil.nadph.qnotified """ @Client.on_message(filters.incoming & filters.private & filters.command(["subscription"])) async def subscription_command(_: Client, message: Message): text = gen_subs_msg(message.from_user.id) await message.reply(text, reply_markup=gen_back_button(), quote=True, ) @Client.on_message(filters.incoming & filters.private & filters.command(["subscribe"])) async def sub_command(_: Client, message: Message): if len(message.command) == 1: await message.reply(sub_help_msg, reply_markup=gen_back_button(), quote=True) else: data = " ".join(message.command[1:]) module = from_keyword_to_module(data) if module: success = add_to_subs(message.from_user.id, module) if success: await message.reply(sub_msg.format(module.name), quote=True) else: await message.reply(already_sub_msg.format(module.name), quote=True) else: await message.reply(not_found_msg.format(data), quote=True) @Client.on_message(filters.incoming & filters.private & filters.command(["unsubscribe"])) async def un_sub_command(_: Client, message: Message): if len(message.command) == 1: await message.reply(unsub_help_msg, reply_markup=gen_back_button(), quote=True) else: data = " ".join(message.command[1:]) module = from_keyword_to_module(data) if module: success = remove_from_subs(message.from_user.id, module) if success: await message.reply(unsub_msg.format(module.name), quote=True) else: await message.reply(not_sub_msg.format(module.name), quote=True) else: await message.reply(not_found_msg.format(data), quote=True)