@rlynicrisis/link 0.0.6 → 0.0.8

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 CHANGED
@@ -88,6 +88,21 @@ openclaw channels add
88
88
 
89
89
  配置完成后,OpenClaw 将自动连接并开始监听消息。
90
90
 
91
+ ### 3. 获取 Token 示例
92
+
93
+ 您可以使用以下命令通过账号密码获取初始的 Access Token 和 Refresh Token:
94
+
95
+ ```bash
96
+ curl --location --request POST 'https://www.bingolink.biz/sso/oauth2/token' \
97
+ --header 'Authorization: Basic Y2xpZW50SWQ6Y2xpZW50U2VjcmV0' \
98
+ --header 'Content-Type: application/x-www-form-urlencoded' \
99
+ --data-urlencode 'grant_type=password' \
100
+ --data-urlencode 'username=个人账号' \
101
+ --data-urlencode 'password=个人密码'
102
+ ```
103
+
104
+ > **提示**: 请将 `username` 和 `password` 替换为您的实际账号信息。响应结果将包含 `access_token` 和 `refresh_token`。
105
+
91
106
  ## 开发调试
92
107
 
93
108
  ### 单元测试
@@ -9,9 +9,9 @@
9
9
  "additionalProperties": false,
10
10
  "properties": {
11
11
  "host": { "type": "string", "description": "Link Server Host (e.g. embtcpbeta.bingolink.biz:20081)" },
12
+ "ssoUrl": { "type": "string", "description": "SSO URL for refreshing token (e.g. https://sso.example.com)" },
12
13
  "accessToken": { "type": "string", "description": "User Access Token" },
13
14
  "refreshToken": { "type": "string", "description": "User Refresh Token (Optional)" },
14
- "ssoUrl": { "type": "string", "description": "SSO URL for refreshing token (e.g. https://sso.example.com)" },
15
15
  "heartbeatIntervalMs": { "type": "number", "default": 30000 }
16
16
  }
17
17
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rlynicrisis/link",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "type": "module",
5
5
  "description": "OpenClaw Link channel plugin",
6
6
  "files": [
package/src/bot.ts CHANGED
@@ -86,6 +86,19 @@ async function handleLinkMessage(params: {
86
86
  return;
87
87
  }
88
88
 
89
+ // Convert content to string if it's a buffer
90
+ let bodyStr = "";
91
+ if (Buffer.isBuffer(msg.content)) {
92
+ bodyStr = msg.content.toString('utf-8');
93
+ } else if (typeof msg.content === 'string') {
94
+ bodyStr = msg.content;
95
+ } else {
96
+ bodyStr = JSON.stringify(msg.content);
97
+ }
98
+
99
+ console.log(`[LinkBot] Message Body: ${bodyStr}`);
100
+
101
+
89
102
  // Determine chat ID (for reply)
90
103
  // If group message, reply to group (toId). If DM, reply to sender (fromId).
91
104
  // Assuming if toType is GROUP, then it's a group chat.
@@ -96,9 +109,9 @@ async function handleLinkMessage(params: {
96
109
  const sessionKey = `link:${chatId}`;
97
110
 
98
111
  const ctx = core.channel.reply.finalizeInboundContext({
99
- Body: msg.content,
100
- RawBody: msg.content,
101
- CommandBody: msg.content,
112
+ Body: bodyStr,
113
+ RawBody: bodyStr,
114
+ CommandBody: bodyStr,
102
115
  From: senderId,
103
116
  To: "bot",
104
117
  SessionKey: sessionKey,
@@ -33,7 +33,9 @@ export function encryptContent(raw: string | Buffer): string {
33
33
  export function decryptContentBuffer(encoded: string): Buffer {
34
34
  if (!encoded) return Buffer.alloc(0);
35
35
  const buffer = Buffer.from(encoded, 'base64');
36
-
36
+
37
+ // Restore bitwise NOT (~) for decryption
38
+ // This is required for standard text messages (Type 1) which are encrypted.
37
39
  for (let i = 0; i < buffer.length; i++) {
38
40
  buffer[i] = ~buffer[i];
39
41
  }