@zlr_236/popo 0.0.5 → 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 +8 -38
package/package.json
CHANGED
package/src/bot.ts
CHANGED
|
@@ -95,19 +95,7 @@ async function resolvePopoMediaList(params: {
|
|
|
95
95
|
}): Promise<PopoMediaInfo[]> {
|
|
96
96
|
const { cfg, event, maxBytes, log } = params;
|
|
97
97
|
const { msgType, fileId, fileInfo } = event.eventData;
|
|
98
|
-
|
|
99
|
-
// Write urlResult to res.txt
|
|
100
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
101
|
-
const __dirname = dirname(__filename);
|
|
102
|
-
const resFilePath = join(__dirname, "res.txt");
|
|
103
|
-
await fs.writeFile(
|
|
104
|
-
resFilePath,
|
|
105
|
-
JSON.stringify(event.eventData, null, 2),
|
|
106
|
-
"utf-8",
|
|
107
|
-
);
|
|
108
|
-
} catch (e) {
|
|
109
|
-
log?.(`popo: DEBUG failed to write event data: ${String(e)}`);
|
|
110
|
-
}
|
|
98
|
+
log?.(`popo: resolvePopoMediaList: ${JSON.stringify(event)}`);
|
|
111
99
|
|
|
112
100
|
// Only process media message types
|
|
113
101
|
const mediaTypes = ["image", "file", "audio", "video", 171, 142];
|
|
@@ -116,6 +104,7 @@ async function resolvePopoMediaList(params: {
|
|
|
116
104
|
!mediaTypes.includes(msgType) ||
|
|
117
105
|
(!fileId && !fileInfo?.fileId)
|
|
118
106
|
) {
|
|
107
|
+
log(`popo: 22222222222222222`);
|
|
119
108
|
return [];
|
|
120
109
|
}
|
|
121
110
|
|
|
@@ -128,20 +117,7 @@ async function resolvePopoMediaList(params: {
|
|
|
128
117
|
cfg,
|
|
129
118
|
fileId: fileId || fileInfo?.fileId,
|
|
130
119
|
});
|
|
131
|
-
|
|
132
|
-
try {
|
|
133
|
-
// Write urlResult to res.txt
|
|
134
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
135
|
-
const __dirname = dirname(__filename);
|
|
136
|
-
const resFilePath = join(__dirname, "res.txt");
|
|
137
|
-
await fs.writeFile(
|
|
138
|
-
resFilePath,
|
|
139
|
-
JSON.stringify(urlResult, null, 2),
|
|
140
|
-
"utf-8",
|
|
141
|
-
);
|
|
142
|
-
} catch (e) {
|
|
143
|
-
log?.(`popo: DEBUG failed to write event data: ${String(e)}`);
|
|
144
|
-
}
|
|
120
|
+
log?.(`popo: 33333333333333333 ${JSON.stringify(urlResult)}`);
|
|
145
121
|
|
|
146
122
|
if (!urlResult.success || !urlResult.downloadUrl) {
|
|
147
123
|
throw new Error(urlResult.error || "Failed to get download URL");
|
|
@@ -150,6 +126,7 @@ async function resolvePopoMediaList(params: {
|
|
|
150
126
|
// Fetch file content from the download URL
|
|
151
127
|
const response = await fetch(urlResult.downloadUrl);
|
|
152
128
|
if (!response.ok) {
|
|
129
|
+
log?.(`popo: 44444444444444444 ${response}`);
|
|
153
130
|
throw new Error(
|
|
154
131
|
`Failed to fetch file: ${response.status} ${response.statusText}`,
|
|
155
132
|
);
|
|
@@ -243,17 +220,8 @@ export async function handlePopoMessage(params: {
|
|
|
243
220
|
const ctx = parsePopoMessageEvent(event);
|
|
244
221
|
const isGroup = ctx.chatType === "group";
|
|
245
222
|
|
|
246
|
-
// Debug: write raw event at handler entry
|
|
247
|
-
await fs
|
|
248
|
-
.writeFile(
|
|
249
|
-
"/home/node/.openclaw/workspace/popo_handler_debug.json",
|
|
250
|
-
JSON.stringify({ ts: new Date().toISOString(), event }, null, 2),
|
|
251
|
-
"utf-8",
|
|
252
|
-
)
|
|
253
|
-
.catch(() => {});
|
|
254
|
-
|
|
255
223
|
log(
|
|
256
|
-
`popo: received message from ${ctx.senderEmail} in ${ctx.sessionId} (${ctx.chatType})`,
|
|
224
|
+
`popo: received message from ${ctx.senderEmail} in ${ctx.sessionId} (${ctx.chatType}) ${JSON.stringify(event)}`,
|
|
257
225
|
);
|
|
258
226
|
|
|
259
227
|
const historyLimit = Math.max(
|
|
@@ -346,7 +314,9 @@ export async function handlePopoMessage(params: {
|
|
|
346
314
|
sessionKey: route.sessionKey,
|
|
347
315
|
contextKey: `popo:message:${ctx.sessionId}:${ctx.messageId}`,
|
|
348
316
|
});
|
|
349
|
-
|
|
317
|
+
log(
|
|
318
|
+
`popo: 111111111111111111 ${JSON.parse(ctx.messageId)} ${JSON.stringify(event)} ${JSON.stringify(popoCfg)}`,
|
|
319
|
+
);
|
|
350
320
|
// Resolve media from message
|
|
351
321
|
const mediaMaxBytes = (popoCfg?.mediaMaxMb ?? 20) * 1024 * 1024;
|
|
352
322
|
const mediaList = await resolvePopoMediaList({
|