A LanXin open-platform adapter for AstrBot, supporting private and group messaging for LanXin bots.
Connect a LanXin bot to AstrBot. The adapter receives LanXin callbacks over Webhook, performs automatic AES-256-CBC decryption and signature verification, converts them into AstrBot message events, and replies with text, images, files, and other message types via the LanXin REST API.
- Message receiving — Receives LanXin callbacks via Webhook; supports private chat (
bot_private_message/account_message) and group chat (bot_group_message). - Message sending — Replies to private/group messages with text, images, video, files, voice, etc.; auto-detects
@botmentions in group chat. - Security verification — Built-in AES-256-CBC decryption (PKCS7 padding) with optional SHA1 signature verification.
- Media upload — Uploads files through the LanXin media interface, then sends with the returned
mediaId. - Token management — Automatically obtains and refreshes
app_token, renewing 60 seconds early to avoid expiry. - Event deduplication — Idempotent dedup based on event ID to prevent duplicate processing.
- Proactive push — Implements
send_by_sessionso plugins can proactively push messages to a session. - Unified Webhook mode — Compatible with AstrBot's unified callback entry (
unified_webhook_mode).
- Deploy and run AstrBot.
- Create an application on the LanXin open platform and obtain the following credentials:
- App ID and App Secret
- AES Key (Base64-encoded 43-character key, used for callback decryption)
- Sign Token (used when signature verification is enabled)
- Ensure the LanXin server can reach the machine running AstrBot from the public network (IP/domain + port).
Clone this repository into AstrBot's plugin directory:
# Enter the AstrBot plugin directory
cd data/plugins
git clone https://github.com/chenglinLiang/astrbot_plugin_lanxin_platform.gitDependencies are installed automatically when AstrBot starts (see requirements.txt): quart, aiohttp, pycryptodome, and typing_extensions on Python < 3.12.
Add a new "LanXin" platform adapter in the AstrBot WebUI and fill in the following options:
| Option | Type | Description |
|---|---|---|
app_id |
string | LanXin open-platform application ID |
app_secret |
string | LanXin open-platform application secret |
aes_key |
string | Base64-encoded 43-character AES key, for callback message decryption |
sign_token |
string | Signature verification token, used when signature verification is enabled |
enable_signature_verify |
bool | Whether to verify the signature of LanXin callback requests |
message_base_url |
string | LanXin API base URL, e.g. http://host:port/open/apigw/v1 |
port |
int | Webhook listen port (default 32653), must match the callback URL in the LanXin console |
callback_server_host |
string | Publicly reachable IP/domain of this machine (used to build the callback URL) |
webhook_path |
string | Callback URL path, default /lanxin/callback |
Note
The process always binds to 0.0.0.0 to accept requests on all network interfaces. callback_server_host is only used to build the full callback URL shown in the logs — fill in the IP/domain that the LanXin server can actually reach.
On startup the logs will print the full callback URL; copy it into the LanXin open-platform console's callback configuration:
========== LanXin Callback URL ==========
Please paste the following into the callback configuration in the LanXin console:
http://<callback_server_host>:<port>/lanxin/callback
==========================================
| Type | Receive | Send |
|---|---|---|
| Text | ✅ | ✅ |
| File | — | ✅ |
| Image | — | — |
| Card | — | — |
LanXin Server ──Webhook──▶ LanXinPlatformAdapter
│ 1. (optional) signature verification
│ 2. AES-256-CBC decryption
│ 3. event parsing + dedup
▼
LanXinPlatformEvent ──▶ AstrBot event bus
▲
│ reply / proactive push
LanXinClient (REST API)
│ auto token refresh / media upload
▼
LanXin Open Platform
Core modules:
main.py— Plugin entry point; registers the adapter.lanxin_adapter.py— Main adapter body: Webhook server, message parsing/conversion, config metadata.lanxin_client.py— LanXin API client: token management, message sending, media upload.lanxin_crypto.py— AES-256-CBC decryption and SHA1 signature verification.lanxin_event.py— Message event implementation; dispatches to the corresponding LanXin API by component type.
This project is licensed under the terms declared in LICENSE.
