-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmute.py
More file actions
31 lines (26 loc) · 944 Bytes
/
mute.py
File metadata and controls
31 lines (26 loc) · 944 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from plugin import BotPlugin, DanmakuMessage, load_config
DEFAULT_CONTENT = {
'bad_danmaku': [
'主播是个大伞兵',
'主播你寄吧谁啊',
'主播NMSL'
]
}
class MuteUser(BotPlugin):
def __init__(self) -> None:
super().__init__()
data = load_config('mute.yml', DEFAULT_CONTENT)
self.bad_danmaku = data['bad_danmaku'] if 'bad_danmaku' in data else []
print(f'禁言弹幕: {self.bad_danmaku}')
async def on_command_received(self, cmd, data):
if cmd != 'DANMU_MSG':
return
danmu = DanmakuMessage.from_command(data['info'])
if danmu.msg not in self.bad_danmaku:
return
uid = danmu.uid
# 需要管理员权限进行禁言
if await self.mute_user(uid):
await self.send_message(f'{danmu.uname}, 你已被禁言!')
else:
print('禁言失败,可能没有权限')