Git Product home page Git Product logo

Comments (10)

arily avatar arily commented on July 23, 2024 1

看到v2已经要实现了不知道是不是来晚了.
https://github.com/arily/sb-qq-bot-framework/blob/master/lib/Wrapper.js
这边有个hack的实现, 通过构造一个假的app拿到middleware和prependMiddleware function 然后代理这两个函数.
https://github.com/arily/sb-qq-bot-framework/blob/2aa5bda9b62ec1fe8cb09c11db0587ea04e210fc/config/contextPlugins.js#L19
这里是定义filter和prependFilter的地方

整个工程无敌乱 非常仓促的搭出来可用的版本之后酷q直接没了,失去了继续制造的动力

from koishi.

shigma avatar shigma commented on July 23, 2024

谢谢你的提问。目前做不到,下面的版本可能也不会考虑实现。

上下文这个概念相当于你使用 QQ 时打开的聊天窗口,会话这个概念则相当于你和我在同一个窗口中持续进行的对话。因此我觉得上下文模型无法表达你所说的这个需求。

另一方面,我暂时也没有想到必须引入新语法才能实现的需求。不妨说说你具体想要做什么,或许我可以给你提一些建议。

from koishi.

kgysf avatar kgysf commented on July 23, 2024

我的目的是给自己写个每个插件集中一个配置文件,通过读取配置直接过滤这个插件只处理哪些消息,类似于过滤器,这样不用在每个插件中去单独判断发送者之类的。

如果上下文的概念不适合,我建议可以加一个过滤器的概念,不仅仅是过滤发送者QQ和群号,还包括比如群内身份(群主,管理,成员)、事件类型(群聊,私聊,请求)、是否包含哪些关键字,其实就是和CQHTTP有提供的事件过滤器一样。

不过目前不支持的话也可以自己另外实现就是了。

from koishi.

shigma avatar shigma commented on July 23, 2024

我大概明白你的意思了。我应该不会提供插件级别的过滤器功能(原因类似,插件直接对接上下文,抽象级别太高,一旦复杂化会产生许多问题),但未来可能会针对你的情况上线其他功能。

同时,CQHTTP 的事件过滤器是底层的,它把不要的事件的所有出口都堵死了。如果你想要这种效果的话倒是很好实现:

// 这里的代码只要写一遍,不需要每个插件中单独判断
app.prependMiddleware((meta, next) => {
  // 自己写一个过滤器判断是否不是群管理员,如果不是则不进入之后的中间件流程
  if (!checkFilter(meta)) return next()
})

from koishi.

kgysf avatar kgysf commented on July 23, 2024

谢谢,我倒是确实没注意到prependMiddleware这个api,那么我自己实现就方便多了

from koishi.

kgysf avatar kgysf commented on July 23, 2024

我有一个新的疑问,我每个插件的过滤规则都是不同的,而这个api是将所有中间件直接全部中断了吧

from koishi.

shigma avatar shigma commented on July 23, 2024

是的(

但是你说 CQHTTP 的过滤器也是这样的吧🤣

from koishi.

kgysf avatar kgysf commented on July 23, 2024

那看来我只能自己另外实现了

(我举例CQHTTP只是举例和他那个过滤规则一样

from koishi.

undefined-moe avatar undefined-moe commented on July 23, 2024

选择器支持多条件选择,但没有计划实现正则匹配,仅能根据群号,用户等简单筛选。
推荐使用 mrs4s/go-cqhttp 替代 cqp。

from koishi.

arily avatar arily commented on July 23, 2024

选择器支持多条件选择,但没有计划实现正则匹配,仅能根据群号,用户等简单筛选。
推荐使用 mrs4s/go-cqhttp 替代 cqp。

嗯,现在就是在用这个替代。就是不知道整个qqbot会不会一起出事

from koishi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.