moyu 禁止普通成员操作订阅/退订功能

This commit is contained in:
xtaodada 2022-05-27 23:47:36 +08:00
parent ea159b1aa1
commit 1b663ec5e1
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
2 changed files with 19 additions and 10 deletions

View File

@ -32,7 +32,7 @@
},
{
"name": "moyu",
"version": "1.0",
"version": "1.001",
"section": "chat",
"maintainer": "xtaodada",
"size": "3.0 kb",

View File

@ -3,10 +3,13 @@
from os import sep
from pyrogram import Client
from pyrogram.enums.parse_mode import ParseMode
from pagermaid import scheduler
from pagermaid import bot
from pagermaid.group_manager import enforce_permission
from pagermaid.listener import listener
from pagermaid.utils import client, Message
from pagermaid.modules.help import from_msg_get_sudo_uid
from pagermaid.utils import client, Message, from_self, edit_delete
from pagermaid.sub_utils import Sub
moyu_sub = Sub("moyu")
@ -55,12 +58,18 @@ async def moyu(_: Client, message: Message):
await message.safe_delete()
await push_moyu(message.chat.id)
elif message.arguments == "订阅":
if from_self(message) or enforce_permission(from_msg_get_sudo_uid(message), "modules.manage_subs"):
if moyu_sub.check_id(message.chat.id):
return await message.edit("你已经订阅了摸鱼日历")
return await edit_delete(message, "❌ 你已经订阅了摸鱼日历", parse_mode=ParseMode.HTML)
moyu_sub.add_id(message.chat.id)
await message.edit("你已经成功订阅了摸鱼日历")
else:
await edit_delete(message, "❌ 权限不足,无法订阅摸鱼日历", parse_mode=ParseMode.HTML)
elif message.arguments == "退订":
if from_self(message) or enforce_permission(from_msg_get_sudo_uid(message), "modules.manage_subs"):
if not moyu_sub.check_id(message.chat.id):
return await message.edit("你还没有订阅摸鱼日历")
return await edit_delete(message, "❌ 你还没有订阅摸鱼日历", parse_mode=ParseMode.HTML)
moyu_sub.del_id(message.chat.id)
await message.edit("你已经成功退订了摸鱼日历")
else:
await edit_delete(message, "❌ 权限不足,无法退订摸鱼日历", parse_mode=ParseMode.HTML)