@lanyingim/lanying 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +105 -0
- package/index.ts +17 -0
- package/openclaw.plugin.json +9 -0
- package/package.json +15 -0
- package/src/channel.ts +1028 -0
- package/src/lanying-im-sdk/floo-3.0.0.js +2 -0
- package/src/runtime.ts +14 -0
- package/src/types.ts +44 -0
- package/tsconfig.json +15 -0
package/README.md
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# OpenClaw Channel Plugin: Lanying
|
|
2
|
+
|
|
3
|
+
Lanying IM Channel for OpenClaw.
|
|
4
|
+
|
|
5
|
+
## 功能说明
|
|
6
|
+
|
|
7
|
+
- 使用蓝莺 IM Web SDK 接入 OpenClaw
|
|
8
|
+
- 支持登录、收发文本消息
|
|
9
|
+
- 支持断线后的自动重连
|
|
10
|
+
- 当前版本仅处理单聊消息(群聊事件会忽略)
|
|
11
|
+
|
|
12
|
+
## 安装
|
|
13
|
+
|
|
14
|
+
推荐使用 OpenClaw CLI 安装扩展。
|
|
15
|
+
|
|
16
|
+
从 npm 安装:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
openclaw plugins install @lanyingim/lanying
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
从 GitHub 安装:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
git clone https://github.com/maxim-top/openclaw-channel-lanying
|
|
26
|
+
openclaw plugins install ./openclaw-channel-lanying
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## 配置
|
|
30
|
+
|
|
31
|
+
在 OpenClaw 配置中添加 `channels.lanying`:
|
|
32
|
+
|
|
33
|
+
```json
|
|
34
|
+
{
|
|
35
|
+
"channels": {
|
|
36
|
+
"lanying": {
|
|
37
|
+
"enabled": true,
|
|
38
|
+
"app_id": "xxxxx",
|
|
39
|
+
"username": "xxxx",
|
|
40
|
+
"password": "xxxx",
|
|
41
|
+
"dmPolicy": "open",
|
|
42
|
+
"allowFrom": ["*"]
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### 参数说明
|
|
49
|
+
|
|
50
|
+
- `enabled`: 是否启用插件(默认 `true`)
|
|
51
|
+
- `app_id`: 蓝莺应用 App ID
|
|
52
|
+
- `username`: 登录名
|
|
53
|
+
- `password`: 登录密码
|
|
54
|
+
- `dmPolicy`: 私聊策略,常用 `open` 或 `pairing`
|
|
55
|
+
- `allowFrom`: 允许发起对话的来源列表
|
|
56
|
+
- `defaultTo`: 可选,默认发送目标
|
|
57
|
+
|
|
58
|
+
## 使用
|
|
59
|
+
|
|
60
|
+
配置生效并重启网关后:
|
|
61
|
+
|
|
62
|
+
1. 用蓝莺账号向机器人账号发送私聊消息
|
|
63
|
+
2. 插件收到消息后会转发给 OpenClaw
|
|
64
|
+
3. OpenClaw 生成回复后由插件回发到蓝莺
|
|
65
|
+
|
|
66
|
+
## 日志与排查
|
|
67
|
+
|
|
68
|
+
插件日志前缀为 `[lanying]`,常见关键日志:
|
|
69
|
+
|
|
70
|
+
- `attempting login`
|
|
71
|
+
- `login success`
|
|
72
|
+
- `sdk ready`
|
|
73
|
+
- `inbound event: onRosterMessage`
|
|
74
|
+
- `inbound message`
|
|
75
|
+
- `reply dispatcher result`
|
|
76
|
+
- `schedule reconnect`
|
|
77
|
+
- `reconnect attempt start`
|
|
78
|
+
- `reconnect attempt success`
|
|
79
|
+
|
|
80
|
+
### 常见问题
|
|
81
|
+
|
|
82
|
+
1. 登录成功但很快退出
|
|
83
|
+
|
|
84
|
+
- 请确认 `app_id/username/password` 正确
|
|
85
|
+
- 观察是否出现 `loginFail event` 或 `flooError event`
|
|
86
|
+
|
|
87
|
+
2. 收到消息但 OpenClaw 不回复
|
|
88
|
+
|
|
89
|
+
- 当前只处理单聊;群聊不会触发回复
|
|
90
|
+
- 历史消息、回环消息(`from === to`)和自发同步消息会被跳过
|
|
91
|
+
- 检查是否出现 `reply dispatcher skipped payload` 或 `reply dispatcher send failed`
|
|
92
|
+
|
|
93
|
+
3. 断线后未恢复
|
|
94
|
+
|
|
95
|
+
- 检查是否有 `disconnected` / `schedule reconnect` / `reconnect attempt` 日志
|
|
96
|
+
- 插件已内置指数退避重连(2s 起步,最大 30s)
|
|
97
|
+
|
|
98
|
+
## 目标格式(主动发送时)
|
|
99
|
+
|
|
100
|
+
插件支持以下目标写法:
|
|
101
|
+
|
|
102
|
+
- `user:<uid>`
|
|
103
|
+
- `group:<gid>`
|
|
104
|
+
- 直接写 `<uid>`(按单聊处理)
|
|
105
|
+
- 可带前缀 `lanying:`,例如 `lanying:user:123456`
|
package/index.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { OpenClawPluginApi } from "openclaw/plugin-sdk";
|
|
2
|
+
import { emptyPluginConfigSchema } from "openclaw/plugin-sdk";
|
|
3
|
+
import { lanyingPlugin } from "./src/channel.js";
|
|
4
|
+
import { setLanyingRuntime } from "./src/runtime.js";
|
|
5
|
+
|
|
6
|
+
const plugin = {
|
|
7
|
+
id: "lanying",
|
|
8
|
+
name: "Lanying",
|
|
9
|
+
description: "Lanying IM channel plugin for OpenClaw",
|
|
10
|
+
configSchema: emptyPluginConfigSchema(),
|
|
11
|
+
register(api: OpenClawPluginApi) {
|
|
12
|
+
setLanyingRuntime(api.runtime);
|
|
13
|
+
api.registerChannel({ plugin: lanyingPlugin });
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default plugin;
|
package/package.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lanyingim/lanying",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "OpenClaw Lanying IM channel plugin",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"devDependencies": {
|
|
8
|
+
"openclaw": "workspace:*"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
},
|
|
12
|
+
"openclaw": {
|
|
13
|
+
"extensions": ["./index.ts"]
|
|
14
|
+
}
|
|
15
|
+
}
|