You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
众所周知,NoneBot2 是一个 跨平台 的机器人框架,然而绝大多数插件只支持 OneBot V11(CQHTTP)平台。我认为这与插件跨平台的困难有些许关系:
如果一个插件开发者想要使它的插件跨平台,最简单的方法就是从
nonebot.adapters
里 import 基类而非从nonebot.adapters.onebot.v11
import。但此方法仅适用于被动回复纯文本消息的插件,一旦插件需要接受和发送的消息里有任何非纯文本的东西,或者插件需要区分群聊和私聊消息时,这类方法就完全不管用了。第二种方法则是为每一平台单独做适配,并使用一系列的
try-except
以防止在插件加载时因为用户并未安装对应适配器而报错,或者在 NoneBot 启动后检测当前存在的适配器并加载对应的代码。这一方法显然并不优雅,但绝对有效。当开发者使用此方法开发复数插件时,他们就会意识到一件事:为何不写一个可以复用的工具插件?这也就是本文接下来要介绍的内容。以下插件按第一个 commit 的时间排序,欢迎补充。
https://github.com/iyume/nonebot-plugin-params
通过 Rule 和依赖注入实现的跨平台,支持 OneBot V11/Feishu/Telegram/QQ Guild。
https://github.com/ColdThunder11/nonebridge
通过一系列 hack 实现的跨平台,支持其作者开发的非官方 Telegram 适配器跨平台到 OneBot V11。
https://github.com/felinae98/nonebot-plugin-send-anything-anywhere
#322
为消息段实现跨平台,支持 OneBot V11/OneBot V12。
https://github.com/nonepkg/nonebot-plugin-all4one
通过将其他适配器的事件转换为 OneBot V12 的格式再连接到 NoneBot 自身从而实现跨平台,支持 OneBot V11/OneBot V12/Telegram/QQ Guild。
Beta Was this translation helpful? Give feedback.
All reactions