@rlynicrisis/link 0.0.6 → 0.0.7
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/package.json +1 -1
- package/src/bot.ts +16 -3
- package/src/link/protocol.ts +3 -1
package/package.json
CHANGED
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:
|
|
100
|
-
RawBody:
|
|
101
|
-
CommandBody:
|
|
112
|
+
Body: bodyStr,
|
|
113
|
+
RawBody: bodyStr,
|
|
114
|
+
CommandBody: bodyStr,
|
|
102
115
|
From: senderId,
|
|
103
116
|
To: "bot",
|
|
104
117
|
SessionKey: sessionKey,
|
package/src/link/protocol.ts
CHANGED
|
@@ -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
|
}
|