Skip to main content
NoneBotPluginLogo

NoneBotPluginText

nonebot-plugin-cs2bridge

✨ CS2 服务器与 QQ 群桥接插件(事件推送、玩家查询、状态轮询) ✨

license pypi python

CS2-Bridge

基于 NoneBot 的与 CS2 Server 互通消息插件

  • 支持 QQ 群(OneBot V11适配器)
  • 支持服务器与多个群聊的互通

🔧 服务端对接

CS2服务器端插件/Mod:CS2-Bridge

快速开始
  1. 安装插件并在 NoneBot2 中加载。
  2. 在 .env 中配置 CS2_QQ_GROUP_IDS、CS2_SERVER_HOST、CS2_WEBHOOK_SECRET 等配置项。
  3. 通过 CS2 服务端向 webhook 地址发送事件,或在群里发送 !players 查询玩家列表。

📖 介绍

nonebot-plugin-cs2bridge 提供以下能力:

  • 接收 CS2 事件 Webhook(玩家加入/离开、地图切换等)并推送至多个 QQ 群。
  • 支持基于密钥的 webhook 校验(X-Webhook-Secret)。
  • 支持短时间重复事件抑制,避免刷屏。
  • 支持群内指令 !players 查询在线玩家(通过 A2S 查询)。
  • 后台轮询服务器状态,仅在在线/离线状态变化时通知群聊。

💿 安装

使用 nb-cli 安装 在 nonebot2 项目的根目录下打开命令行, 输入以下指令即可安装
nb plugin install nonebot-plugin-cs2bridge
使用包管理器安装 在 nonebot2 项目的插件目录下, 打开命令行, 输入相应的安装命令
pip install nonebot-plugin-cs2bridge

打开 nonebot2 项目根目录下的 pyproject.toml 文件, 在 [tool.nonebot.plugins] 部分追加写入

nonebot-plugin-cs2bridge = ["nonebot_plugin_cs2bridge"]

⚙️ 配置

在 nonebot2 项目的 .env 文件中添加下表配置:

配置项 必填 默认值 说明
CS2_QQ_GROUP_IDS 是 [] 接收推送的群号列表,例如 [123456789,987654321]
CS2_WEBHOOK_SECRET 是 空 Webhook 密钥,需与请求头 X-Webhook-Secret 一致
CS2_WEBHOOK_PATH 否 /cs2/event Webhook 路径
CS2_SERVER_HOST 否 空 CS2 服务器地址,用于在线玩家查询与状态轮询
CS2_QUERY_PORT 否 27015 A2S 查询端口
CS2_STATUS_INTERVAL 否 45 状态轮询间隔,范围 30-60 秒
CS2_RCON_HOST 否 空 RCON 主机地址
CS2_RCON_PORT 否 27015 RCON 端口
CS2_RCON_PASSWORD 否 空 RCON 密码

🎉 使用

指令表

指令 权限 需要@ 范围 说明
!players 群员 否 指定群聊 查询 CS2 服务器在线玩家并按队伍展示

Webhook 事件

  • 请求方式:POST
  • Header:X-Webhook-Secret: <密钥>
  • 默认路径:/cs2/event

请求体示例:

{
    "event": "player_connect",
    "data": {
        "player_name": "Akiyy",
        "steamid": "76561198000000000",
        "player_count": 8,
        "max_players": 20
    }
}

支持事件包括:test、player_connect、player_disconnect、player_kick、map_changed。

Metadata

Release files for nonebot-plugin-cs2bridge 1.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nonebot-plugin-cs2bridge 1.1.3
File Size Uploaded Provenance Actions
nonebot_plugin_cs2bridge-1.1.3.tar.gz 10.8 kB Without provenance Details for nonebot_plugin_cs2bridge-1.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nonebot-plugin-cs2bridge 1.1.3
File Interpreter ABI Platform Actions
nonebot_plugin_cs2bridge-1.1.3-py3-none-any.whl Python 3 none any Details for nonebot_plugin_cs2bridge-1.1.3-py3-none-any.whl

Total release size: 22.8 kB

Release files / nonebot_plugin_cs2bridge-1.1.3.tar.gz

Download URL nonebot_plugin_cs2bridge-1.1.3.tar.gz
Size 10.8 kB
Tags Source
SHA-256 checksum
How to use checksums
0083417f416b7a11a7065afb826610ab5f2b2fd1864d8ba4f1b290caab8a064b
BLAKE2b-256 checksum
How to use checksums
24cb919653f22f26556b7bc2960bdb6e6a16f5a3ddbf9e7fbe1cd7612020babf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via pdm/2.26.7 CPython/3.12.3 Linux/6.17.0-1008-azure

Release files / nonebot_plugin_cs2bridge-1.1.3-py3-none-any.whl

Download URL nonebot_plugin_cs2bridge-1.1.3-py3-none-any.whl
Size 12.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
45c729141370f1eaf19fd3e553d0c314d59dff20f650bcb4fd6099662b54b61b
BLAKE2b-256 checksum
How to use checksums
25842eb71f7da2be275661e01f34727acdda5b934a8e2e31d19a722bf3d5ea2a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via pdm/2.26.7 CPython/3.12.3 Linux/6.17.0-1008-azure

Security for nonebot-plugin-cs2bridge 1.1.3

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page