Skip to main content

NoneBot-Adapter-Kritor

✨ NoneBot2 Kritor Protocol适配器 / Kritor Protocol Adapter for NoneBot2 ✨

协议介绍

Kritor Protocol

协议端

目前提供了 kritor 协议实现的有:

配置

修改 NoneBot 配置文件 .env 或者 .env.*。

Driver

因本适配器基于 gRPC,Nonebot 没有现有的相关驱动器,所以驱动请直接写 none:

DRIVER=~none

KRITOR_CLIENTS

配置机器人帐号,如:

KRITOR_CLIENTS='
[
  {
    "host": "xxx",
    "port": xxx,
    "account": "xxx",
    "ticket": "xxx"
  }
]
'
KRITOR_SKIP_AUTH=false

其中,

  • host: 服务端的地址,默认为 localhost
  • port: 服务端的端口
  • account: bot 登录的账号
  • ticket: bot 登录用的凭证/密码
  • KRITOR_SKIP_AUTH: 若协议端未启用鉴权功能,则启用此配置项。此时 ticket 留空即可。

以对接 Lagrange.Kritor 为例

首先按照 Lagrange.Kritor 的 README 进行配置。进行下一步前你应当已经创建好了 appsettings.json:

// appsettings.json
{
    "Logging": {
        "LogLevel": {
            // Log level, please modify to `Trace` when providing feedback on issues
            "Default": "Information"
        }
    },
    "Core": {
        "Protocol": {
            // Protocol platform, please modify according to the Signer version
            // Type: String ("Windows", "MacOs", "Linux")
            // Default: "Linux"
            "Platform": "Linux",
            "Signer": {
                // Signer server url
                // Type: String (HTTP URL, HTTPS URL)
                "Url": "",
                // Signer server proxy
                // Type: String (HTTP URL)
                "Proxy": ""
            }
        },
        "Server": {
            // Whether to automatically reconnect to the TX server
            // Type: bool
            // Default: false
            "AutoReconnect": true,
            // Whether to get optimum server
            // Type: bool
            // Default: false
            "GetOptimumServer": true
        }
    },
    "Kritor": {
        "Network": {
            // Address of the Kritor service binding
            // Type: String (ip)
            "Address": "0.0.0.0",
            // Port of the Kritor service binding
            // Type: Number ([1-65535])
            "Port": 9000
        },
        "Authentication": {
            // Whether to enable authentication
            // Type: bool
            "Enabled": false,
            // Ticket with maximum privileges
            // Type: String
            "SuperTicket": "",
            // Ticket list
            // Type: String[]
            "Tickets": []
        },
        "Message": {
            // Whether to ignore your own messages
            // Type: bool
            "IgnoreSelf": false
        }
    }
}

对于配置项:

  • host 与 Kritor.Network.Address 一致
  • port 与 Kritor.Network.Port 一致
  • 若 Kritor.Authentication.Enabled 为 true, 则 ticket 应存在于 .SuperTicket 或 .Tickets 中
  • account 为你登录的账号

克隆

因为该仓库包含一个 submodule, 请使用以下命令克隆本仓库:

git clone --recursive https://github.com/nonebot/adapter-kritor.git

示例

from nonebot import on_command
from nonebot.adapters.kritor import Bot
from nonebot.adapters.kritor.message import MessageSegment
from nonebot.adapters.kritor.permission import PRIVATE


matcher = on_command("test", permission=PRIVATE)

@matcher.handle()
async def handle_receive(bot: Bot):
    await bot.send(event, MessageSegment.text("Hello, world!"))

Metadata

Release files for nonebot-adapter-kritor 0.3.2

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-adapter-kritor 0.3.2
File Size Uploaded
nonebot_adapter_kritor-0.3.2.tar.gz 44.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nonebot-adapter-kritor 0.3.2
File Interpreter ABI Platform
nonebot_adapter_kritor-0.3.2-py3-none-any.whl Python 3 none any Details

Total release size: 102.0 kB

Release files / nonebot_adapter_kritor-0.3.2.tar.gz

Download URL nonebot_adapter_kritor-0.3.2.tar.gz
Size 44.7 kB
Tags Source
SHA-256 checksum
How to use checksums
782247d7b8434bee9dab0d300786922ecb6f78e52bd2fe0c0681e01131fd25a9
BLAKE2b-256 checksum
How to use checksums
222f36edde5b07381190836fcf184625d0bc553465a98b8754fd4fd6f0d8ae35
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via pdm/2.19.1 CPython/3.10.12 Linux/6.8.0-1014-azure

Release files / nonebot_adapter_kritor-0.3.2-py3-none-any.whl

Download URL nonebot_adapter_kritor-0.3.2-py3-none-any.whl
Size 57.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f43a33317254e779eb27e2324900882a81bf9cb7eb6058e3d808ead716df8edc
BLAKE2b-256 checksum
How to use checksums
44e1713053d91468afd16d230fc24a25cfb62719a06ce20ff0ad85c7565d5a2b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via pdm/2.19.1 CPython/3.10.12 Linux/6.8.0-1014-azure

Release history Release notifications | RSS feed

This release

0.3.2 This release

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

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