使用命令:开启/关闭全禁
这里我就不放效果图了,还请各位大佬自行摸索
废话不多说,上源码:
from cgitb import enable
from nonebot import on_keyword, on_regex
from nonebot.typing import T_State
from nonebot.adapters.onebot.v11 import Message, GroupMessageEvent, GroupIncreaseNoticeEvent, GroupDecreaseNoticeEvent,GroupUploadNoticeEvent, GroupAdminNoticeEvent, GroupRecallNoticeEvent, PokeNotifyEvent,Bot,Event
from nonebot import on_notice, on_command
import warnings,requests
from nonebot.permission import *
#from nonebot import
import re
warnings.filterwarnings("ignore")
# 撤回消息
che = on_keyword({'广告', '沙雕', '广告', 'md', '妈的', '卧槽', '嘛的', '操你妈', '操你', '加vx','操','草','傻逼','SB','sb','nt','脑瘫','骚'})
qtk = on_regex(pattern = r'^开启全禁$')
qtg = on_regex(pattern = r'^关闭全禁$')
zr = 1648576390
@che.handle()
async def c(bot: Bot, event: GroupMessageEvent, state: T_State):
mid = event.message_id
group = event.group_id
qq = event.user_id
sj = 300
print(mid)
print(group)
await bot.delete_msg(message_id=mid)
await bot.set_group_ban(group_id=group,user_id=qq,duration=sj)
await che.finish(message=f'@{qq} 你的发言可能包含敏感词汇,这里禁言5分钟警告一下')
@qtk.handle()
async def j(bot: Bot, event: GroupMessageEvent, state: T_State):
group = event.group_id
qq = event.user_id
if qq == zr:
await bot.set_group_whole_ban(group_id=group,enable=True)
await che.finish(message=f'好的大大,辞辞已经为您开启全体禁言了')
else:
await che.finish(message=f'你没有资格命令我!')
@qtg.handle()
async def g(bot: Bot, event: GroupMessageEvent, state: T_State):
group = event.group_id
qq = event.user_id
if qq == zr:
await bot.set_group_whole_ban(group_id=group,enable=False)
await che.finish(message=f'好的大大,辞辞已经为您关闭全体禁言了')
else:
await che.finish(message=f'你没有资格命令我!')
ps:违禁词可以根据自身需要进行修改,禁言时间也可以自行修改,单位是秒,我源码中是300秒,也就是5分钟