Skip to main content

A plugin to run go-cqhttp directly in NoneBot2, without additional download and installation.

Project description

nonebot-plugin-gocqhttp

A plugin to run go-cqhttp directly in NoneBot2, without additional download and installation.

一款在 NoneBot2 中直接运行 go-cqhttp 的插件, 无需额外下载安装.

PyPI

GitHub issues GitHub forks GitHub stars GitHub license


优势

  • 对标koishijs/koishi-plugin-gocqhttp

  • 便于部署: 部署时只需启动一个 Bot 进程即可, 无需其他附加工具

  • 易于使用: 本插件提供一个简单的 WebUI, 可以直接在图形界面中添加账户

    • 这个地方应该有两张截图, 但是我没有找到合适的图片, 如果你们觉得这个插件很赞, 欢迎返图
  • 跨平台支持: 根据反馈, 本插件已可以在MacOS/Linux/Windows上运行, 且不受异步子进程调用带来的限制

使用

安装

推荐使用nb-cli进行安装

要求最低 Python 版本为3.8

配置

本项目提供以下可选配置项, 请在.env中自行进行配置

如果想要获取更多配置文件相关信息, 请阅读源代码

账号配置

GOCQ_ACCOUNTS: 要登录的 QQ 账号列表, 为一个 json 数组

  • 支持的字段:

    • uin: QQ 账号 (必填)
    • password: QQ 密码, 不填将使用扫码登录
    • protocol: 数字, 是登录使用的客户端协议
    • config_extra: 配置文件拓展, 用于覆盖默认配置
      • 由于在每次程序启动时go-cqhttp启动配置文件都会被覆盖, 所以请在该项目中设置你要添加的配置项
        • 当直接填写 json 对象时, 原样传入并更新配置文件
        • 当传入以ref:开头的字符串时, 它将尝试读取之后目录中的文件, 来更改配置文件
        • 当传入以override:开头的字符串时, 它将尝试尝试读取之后目录中的文件, 来覆盖配置文件
    • device_extra: 和config_extra类似, 但是是用来覆盖device.json中配置的
  • 示例:

    [
      {
        "uin": "QQ帐号",
        "password": "密码"
      }
    ]
    

下载地址配置

GOCQ_URL: 下载 URL, 默认为空, 设置该项目后以下几个与下载有关的配置项目将失效

GOCQ_DOWNLOAD_DOMAIN: 下载域名, 默认为download.fastgit.org

GOCQ_REPO: 要下载的仓库, 默认为Mrs4s/gocqhttp

GOCQ_VERSION: 要下载的版本, 默认为空, 即下载最新版本

GOCQ_FORCE_DOWNLOAD: 强制在启动时下载, 默认为false

其他配置

GOCQ_PROCESS_KWARGS: 创建进程时的可选参数, 请参照代码进行修改

GOCQ_WEBUI_USERNAME, GOCQ_WEBUI_PASSWORD: WebUI 的登录凭证, 不设置即不进行验证

开始使用

配置好了以后启动你的 Bot 即可

  • 需要注意以下几点:

    • 本插件会在 Bot 工作目录下创建accounts文件夹用于存储go-cqhttp的二进制和账户数据文件, 如果你使用版本管理工具(如git), 请自行将该文件夹加入忽略列表

    • 本插件通过子进程调用实现, 如果你在外部通过手段强行终止了 Bot 进程, 请检查开启的子进程是否也同样已终止

    • 如果你的 Bot 监听来自所有主机的连接(比如监听了0.0.0.0), 或者它向公网开放, 强烈建议设置 WebUI 登录凭证以防止被未授权访问

  • 本插件提供了一个SUPERUSERS能使用的命令: gocq, 可以用来查看当前运行的go-cqhttp进程状态

鸣谢

开源许可证

由于go-cqhttp使用了AGPL-3.0许可证, 本项目也同样使用该许可

注意! 如果在您的项目中依赖了该插件, 您的项目必须以该许可开源!

A plugin to run go-cqhttp directly in NoneBot2, without additional download and installation.
Copyright (C) 2022 Mix

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <https://www.gnu.org/licenses/>.

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

nonebot-plugin-gocqhttp-0.4.2.tar.gz (2.3 MB view hashes)

Uploaded Source

Built Distribution

nonebot_plugin_gocqhttp-0.4.2-py3-none-any.whl (2.4 MB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page