voice_only_contact 仅联系人可以发送语音消息

This commit is contained in:
xtaodada 2022-07-15 20:32:28 +08:00
parent 45d4ad0df0
commit 2b281e3f53
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
2 changed files with 24 additions and 0 deletions

View File

@ -319,6 +319,16 @@
"supported": true, "supported": true,
"des-short": "关键词回复。", "des-short": "关键词回复。",
"des": "关键词回复。\n指令,keyword" "des": "关键词回复。\n指令,keyword"
},
{
"name": "voice_only_contact",
"version": "1.0",
"section": "chat",
"maintainer": "xtaodada",
"size": "0.4 kb",
"supported": true,
"des-short": "仅联系人可以发送语音消息给我。",
"des": "仅联系人可以发送语音消息给我。"
} }
] ]
} }

View File

@ -0,0 +1,14 @@
import contextlib
from pyrogram import filters
from pagermaid.listener import raw_listener
from pagermaid.single_utils import Message
@raw_listener(filters.private & filters.voice & filters.incoming)
async def voice_only_contact(message: Message):
with contextlib.suppress(Exception):
if message.from_user.is_contact:
return
await message.delete()