miraicle
miraicle copied to clipboard
关于我的过滤器无法管理任务计划插件
我写了个任务计划插件,但是始终没有办法用我自己编写的 group_switch.py
去管理这个插件。详情如下:
bot.py:
# -*- coding: UTF-8 –*-
import miraicle
from plugins import *
qq = 123456789 # 我的QQ号
verify_key = '123'
port = 8080
bot = miraicle.Mirai(qq = qq, verify_key = verify_key, port = port)
bot.set_filter(miraicle.GroupSwitchFilter("config/group_switch.json"))
bot.run()
group_switch.py:
@miraicle.Mirai.filter('GroupSwitchFilter')
def group_switch(bot: miraicle.Mirai, msg: miraicle.GroupMessage, flt: miraicle.GroupSwitchFilter):
if msg.sender == my_qq:
if msg.plain == '启用所有组件':
flt.enable_all(group = msg.group)
bot.send_group_msg(group = msg.group, msg = '已在群内启用所有组件', quote = msg.id)
elif msg.plain == '禁用所有组件':
flt.disable_all(group=msg.group)
bot.send_group_msg(group = msg.group, msg = '已在群内禁用所有组件', quote = msg.id)
elif msg.plain[:6] == 'unload':
func = msg.plain[7:]
flt.disable(msg.group, func)
bot.send_group_msg(group = msg.group, msg = f"已在该群内禁用{func}", quote = msg.id)
elif msg.plain[:4] == 'load':
func = msg.plain[5:]
flt.enable(msg.group, func)
bot.send_group_msg(group = msg.group, msg = f"已在该群内启用{func}", quote = msg.id)
elif msg.plain == '查询权限':
fun = flt.funcs_info(msg.group)
data = ""
for i in fun:
data = data + f"{i['func']}: {i['enabled']}\n"
bot.send_group_msg(group = msg.group, msg = data, quote = msg.id)
文件结构:
测试情况:
group_switch.json:
{
"948973290": [
"hello_to_group",
"repeat",
"word_cloud"
]
}
个人猜测是我写的任务计划这个插件没有被正确识别,,,/捂脸
求解答。
目前试过的方法有:反复重启(bushi),手动往group_switch.json里加东西.....
init里面写了吗
写了的