miraicle icon indicating copy to clipboard operation
miraicle copied to clipboard

关于我的过滤器无法管理任务计划插件

Open LittFlower opened this issue 3 years ago • 2 comments

我写了个任务计划插件,但是始终没有办法用我自己编写的 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)

文件结构: Snipaste_2022-01-15_17-33-12

测试情况: 2

group_switch.json:

{
    "948973290": [
        "hello_to_group",
        "repeat",
        "word_cloud"
    ]
}

个人猜测是我写的任务计划这个插件没有被正确识别,,,/捂脸

求解答。

目前试过的方法有:反复重启(bushi),手动往group_switch.json里加东西.....

LittFlower avatar Jan 15 '22 09:01 LittFlower

init里面写了吗

Elflare avatar Jan 18 '22 12:01 Elflare

写了的

LittFlower avatar Jan 19 '22 13:01 LittFlower