A adapter event bridge for nonebot2 makes plugins run on different adapters without any modify
Project description
nonebridge
A adapter event bridge for nonebot2 makes plugins running on different adapters without any modify
一个让你能够在不修改插件的情况下使其运行在不同adapter中的魔法bridge,开发目的是为了给Yuki Clanbattle提供Telegram支持
还在开发中请勿生产环境使用
女生自用插件,目前仅支持让为onebotv11编写的插件运行在自己写的nonebot-adapter-telegram上,仅会支持有限的消息类型和API模拟
目前不支持主动发送消息和向非事件触发的聊天发送消息,支持主动向群聊使用send_group_msg发送群组消息了(必须在tg端收到任意消息后虚假的obv11 bot连接才会被注册)
支持的接收类型
- 纯文字(MessageSegment.text)
- 图片(MessageSegment.image) (需要nonebot-adapter-antelegram 0.2.0.dev10+)
支持的发送类型
- 文字(MessageSegment.text)
- 图片(MessageSegment.image)
- AT(MessageSegment.at) (需要nonebot-adapter-antelegram 0.2.0.dev9+)
支持的额外API
Onebot v11 API | 对应的Telegarm API |
---|---|
get_group_info | getChat和getChatMemberCount |
get_group_member_list | getChatAdministrators(由于tg并没有提供相关API,仅能够直接获取管理员信息) |
get_group_member_info | getChatMember |
send_group_msg | --- |
配置
nonebridge所需的配置直接写入到nonebot2的.env文件内即可
nonebridge_ob11_caption_ahead_photo: 将从telegram收到的带文字描述的图片消息中文字部分作为文字消息在ob11的消息段中前置以配合ob11中大部分插件的习惯写法,默认为True
使用方法
同时安装并两个adapter,在bot.py紧随nonebot之后导入nonebridge,必须在任何adapter导入之前导入nonebridge,需要同时注册两个Adapter才能正常运行
Example bot.py
import nonebot
import nonebridge
from nonebot.adapters.onebot.v11 import Adapter as OneBot_V11_Adapter
from nonebot.adapters.telegram.adapter import Adapter as Telegram_Adapter
nonebot.init()
driver = nonebot.get_driver()
driver.register_adapter(OneBot_V11_Adapter)
driver.register_adapter(Telegram_Adapter)
nonebot.load_plugin("your_onebotv11_plugin")
if __name__ == "__main__":
nonebot.run()
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
nonebridge-0.1.2.tar.gz
(6.5 kB
view hashes)
Built Distribution
Close
Hashes for nonebridge-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4ad0fd96e0c9dff47d7e037fe00f05e81f11ef11fd9efe3dff69bfaab51b0f06 |
|
MD5 | e000f7d0b47a5e17bc86e42494567348 |
|
BLAKE2b-256 | f09126234e0a2b2a0816ed55fc50ed17cbd21e281cb91862db6ee59685985675 |