Comments (10)
看到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.
谢谢你的提问。目前做不到,下面的版本可能也不会考虑实现。
上下文这个概念相当于你使用 QQ 时打开的聊天窗口,会话这个概念则相当于你和我在同一个窗口中持续进行的对话。因此我觉得上下文模型无法表达你所说的这个需求。
另一方面,我暂时也没有想到必须引入新语法才能实现的需求。不妨说说你具体想要做什么,或许我可以给你提一些建议。
from koishi.
我的目的是给自己写个每个插件集中一个配置文件,通过读取配置直接过滤这个插件只处理哪些消息,类似于过滤器,这样不用在每个插件中去单独判断发送者之类的。
如果上下文的概念不适合,我建议可以加一个过滤器的概念,不仅仅是过滤发送者QQ和群号,还包括比如群内身份(群主,管理,成员)、事件类型(群聊,私聊,请求)、是否包含哪些关键字,其实就是和CQHTTP有提供的事件过滤器一样。
不过目前不支持的话也可以自己另外实现就是了。
from koishi.
我大概明白你的意思了。我应该不会提供插件级别的过滤器功能(原因类似,插件直接对接上下文,抽象级别太高,一旦复杂化会产生许多问题),但未来可能会针对你的情况上线其他功能。
同时,CQHTTP 的事件过滤器是底层的,它把不要的事件的所有出口都堵死了。如果你想要这种效果的话倒是很好实现:
// 这里的代码只要写一遍,不需要每个插件中单独判断
app.prependMiddleware((meta, next) => {
// 自己写一个过滤器判断是否不是群管理员,如果不是则不进入之后的中间件流程
if (!checkFilter(meta)) return next()
})
from koishi.
谢谢,我倒是确实没注意到prependMiddleware这个api,那么我自己实现就方便多了
from koishi.
我有一个新的疑问,我每个插件的过滤规则都是不同的,而这个api是将所有中间件直接全部中断了吧
from koishi.
是的(
但是你说 CQHTTP 的过滤器也是这样的吧🤣
from koishi.
那看来我只能自己另外实现了
(我举例CQHTTP只是举例和他那个过滤规则一样
from koishi.
选择器支持多条件选择,但没有计划实现正则匹配,仅能根据群号,用户等简单筛选。
推荐使用 mrs4s/go-cqhttp 替代 cqp。
from koishi.
选择器支持多条件选择,但没有计划实现正则匹配,仅能根据群号,用户等简单筛选。
推荐使用 mrs4s/go-cqhttp 替代 cqp。
嗯,现在就是在用这个替代。就是不知道整个qqbot会不会一起出事
from koishi.
Related Issues (20)
- Bug: yarn pub 无法正常上传包 HOT 2
- Bug: 多余请求头导致拿不到头像 HOT 2
- Bug: 使用 windows 安装的 podman-desktop 启动镜像时老是尝试启动 /mnt/c/.../powershell.exe 但报错 ENOENT HOT 1
- Feature: Schema.string() 添加代码编辑器的 role
- Bug: Schema.array() 的`添加项目`按钮行为不正常,在特定场景不可用等
- Bug(Schema): Computed with Union Not Showing Branches Correctly HOT 2
- Bug: help 指令在遇到 .platform 或其他情况下回复错误
- Bug: 在使用指令管理 改变一些层级后,指令管理选项消失 HOT 2
- feat(core): parser[number]: support delimiters in number
- Bug: 使用adapter-satori的机器人会出现i18n错误 HOT 1
- adapter-qq是否能增加支持markdown模板和原生markdown?
- 云服务器如何公网连接控制台 HOT 2
- Bug(schemastery-vue): Schema.dict添加项目的体验优化 HOT 1
- Bug: Cannot find module '@cordisjs/server'
- Bug: adapter-satori接入chronocat,引用消息的session中quote属性缺失。
- Bug: h.transform 不会处理命中元素的嵌套元素 HOT 1
- Bug: What happen HOT 1
- Feature: 指令参数类型增加非负整数 HOT 3
- Bug: 当指令参数的image是某个元素的子元素,会提示参数输入无效
- Bug: 重载 koishi-plugin-puppeteer出现报错
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from koishi.