QQ群-Discord 互通
前言
OneBot 实现众多,表现各有不同,我的测试环境为 Lagrange.Onebot,遇到 bug 请提 issues,务必附上日志
本人 python 水平有限,遇到你认为可以改进的方法和函数,或有任何不妥之处,或需要注释支持,也请提出
功能
可以在指定的QQ群和 Discord 频道之间同步消息,只支持普通的文字频道,不支持帖子频道
消息支持情况
| 类型 | QQ to Discord | Discord to QQ | 备注 |
|---|---|---|---|
| 文字 | 🟢 | 🟢 | 🟢支持 |
| 图片 | 🟢 | 🟢 | 🟡压缩为文字 |
| At | 🟡 | 🟡 | ⚠️不良好 |
| 回复 | 🟢 | 🟢 | |
| 撤回 | 🟢 | ⚠️ | |
| 表情 | 🟡 | 🟡 | |
| 贴纸 | 🟡 | ||
| 文件 | 🟢 | 🟢 | |
| 视频 | 🟢 | 🟢 | |
| 语音 | 🟢 | 🟢 | |
| Embed | 🟢 | ||
| xml | ⚠️ | ||
| json | ⚠️ |
安装
使用 nb-cli 安装
在 nonebot2 项目的根目录下打开命令行, 输入以下指令即可安装
nb plugin install nonebot-plugin-dcqq-relay
使用包管理器安装
建议使用 poetry
- 通过 poetry 添加到 NoneBot2 项目的 pyproject.toml
poetry add nonebot-plugin-dcqq-relay
- 也可以通过 pip 安装
pip install nonebot-plugin-dcqq-relay
安装开发中版本
pip install git+https://github.com/Autuamn/nonebot-plugin-dcqq-relay.git@main
配置
数据库
本插件使用 nonebot-plugin-orm 存储消息 ID
仅简单测试过 SQLite、MySQL、PostgreSQL
相关配置请看 NoneBot-最佳实践-数据库
机器人权限
推荐权限:管理员
最低权限:
- QQ:
- 管理员(不给撤回功能将不正常)
- Discord:
- Manage Messages(不给无法撤回)
- Mention Everyone(不给无法转发@全体成员)
- Manage Webhooks(不给要提供 Webhook)
dcqq_relay_channel_links
- 类型:
json - 默认值:
[] - 说明:链接对应的QQ群与 Discord 频道,目前只支持一对一链接
配置文件示例
dcqq_relay_channel_links='[
{
"qq_group_id": 123132,
"dc_guild_id": 456456,
"dc_channel_id": 789789,
"webhook_id": 4444444,
"webhook_token": "asdxxx"
},
{
"qq_group_id": int # QQ群号
"dc_guild_id": int # Discord 服务器 id
"dc_channel_id": int # Discord 频道 id
"webhook_id": Optional[int] # (可选的)Discord 对应频道的 Webhook ID
"webhook_token": Optional[str] # (可选的)Discord 对应频道的 Webhook Token
# 不要把注释放在此处!!
}
]'
关于 Webhook 是什么请看:使用網絡鉤手(Webhooks)
得到 Webhook URL 后,可从 URL 中获取 webhook_id 和 webhook_token
Webhook URL 形如:
https://discord.com/api/webhooks/{webhook_id}/{webhook_token}
例如:
| webhook_id | webhook_token |
https://discord.com/api/webhooks/1243529342621978694/kq1Vc3NsN4d3SB0MAusB-xbY_e8xMChQmxypIFna0c1lwQS-uL85fqupK2jFfkYtUR1h
|-------------------|--------------------------------------------------------------------|
当 Webhook URL 为 https://discord.com/api/webhooks/1243529342621978694/kq1Vc3NsN4d3SB0MAusB-xbY_e8xMChQmxypIFna0c1lwQS-uL85fqupK2jFfkYtUR1h 时
1243529342621978694 就是 webhook_id
kq1Vc3NsN4d3SB0MAusB-xbY_e8xMChQmxypIFna0c1lwQS-uL85fqupK2jFfkYtUR1h 就是 webhook_token
dcqq_relay_unmatch_beginning
- 类型:
list[str] - 默认值:
["/"] - 说明:指明不转发的消息开头
dcqq_relay_only_to_me
- 类型:
bool - 默认值:
False - 说明:指明是否只转发 @机器人 的消息
特别感谢
Metadata
Release files for nonebot-plugin-dcqq-relay 1.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nonebot_plugin_dcqq_relay-1.3.1.tar.gz | 18.8 kB | Without provenance | Details for nonebot_plugin_dcqq_relay-1.3.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nonebot_plugin_dcqq_relay-1.3.1-py3-none-any.whl | Python 3 | none | any | Details for nonebot_plugin_dcqq_relay-1.3.1-py3-none-any.whl |
Total release size: 40.9 kB
Release files / nonebot_plugin_dcqq_relay-1.3.1.tar.gz
| Download URL | nonebot_plugin_dcqq_relay-1.3.1.tar.gz |
|---|---|
| Size | 18.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d4a1a14421034d96faab5eed7d3424cb6db766b0c0612a241a83a7d69f69f55e
|
|
BLAKE2b-256 checksum How to use checksums |
1b3ab88148b66c5348312667d6e32b9d497039b3a89d71b6ad1083a4fe5db13b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.24 {"installer":{"name":"uv","version":"0.11.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / nonebot_plugin_dcqq_relay-1.3.1-py3-none-any.whl
| Download URL | nonebot_plugin_dcqq_relay-1.3.1-py3-none-any.whl |
|---|---|
| Size | 22.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
94bcb5027d3f6aa7528d3d096d4432e9374b08538d61506ef41718db391f6339
|
|
BLAKE2b-256 checksum How to use checksums |
c6453a7a4977bae64e49dbab2227b06450ddf5856f90b8786e2d577cf2ad3bd6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.24 {"installer":{"name":"uv","version":"0.11.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for nonebot-plugin-dcqq-relay 1.3.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.