Skip to content

Feature: 添加一个上下文的api,能够实现禁用插件 启用插件的功能 #886

@HuanLinOTO

Description

@HuanLinOTO

Describe the problem related to the feature request

号不少 风控的也不少 我想要在一个号风控后通过命令的方式禁用掉当前的onebot插件 然后打开下一个onebot

Describe the solution you'd like

添加一个上下文的api,能够实现禁用插件 启用插件的功能(可在插件配置向用户申请该权

Describe alternatives you've considered

让koishi自动检测gocqhttp的stdout 来实现风控换号?

Additional context

来个伪代码实现

export function apply(ctx) {
    var onebots = ctx.getPluginsByType("adapter-onebot")
    // [
    //     {
    //         id:"114514",
    //         isActivate: false,
    //         activate:function(...)
    //     },
    //     {
    //         id:"1919810",
    //         isActivate: true,
    //         activate:function(...)
    //     }
    // ]
    for (const key in onebots) {
        if(onebots[key].isActivate) {
            if(key+1 == onebots.length) {
                onebots[0].activate()
            } else {
                onebots[key+1].activate()
            }
        }
    }   
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions