@openclaw/line 2026.10.10 → 2026.11.5-beta.1
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/dist/.setup/{api-Bz8QPCGD.mjs → api-ByXjHPMe.mjs} +1 -1
- package/dist/.setup/api-DCMpIrda.mjs +3 -0
- package/dist/.setup/{card-command-XYkg1XvG.mjs → card-command-utjlRvb-.mjs} +26 -43
- package/dist/.setup/{channel-ezTshIoC.mjs → channel-D9i_xlsJ.mjs} +237 -329
- package/dist/.setup/channel.runtime-C-E2qsIu.mjs +4 -0
- package/dist/.setup/{monitor-BBEBldZu.mjs → monitor-BYGe2Y7S.mjs} +240 -328
- package/dist/.setup/{outbound.runtime-BSuF2lax.mjs → outbound.runtime-AQvUJvJV.mjs} +2 -2
- package/dist/.setup/{send-B8TYfTO_.mjs → send-H86JOXWw.mjs} +37 -103
- package/dist/.setup/{send-retry-gHsCgBlf.mjs → send-retry-D6J7bThI.mjs} +174 -80
- package/dist/.setup/{template-messages-CdpQxqqb.mjs → template-messages-KG1GwG0h.mjs} +32 -44
- package/dist/.source-module-urls/2c97352967966b7ab9f67f528eb25c098b6fe10ea0e4616ffae3851ed839d81e.json +1 -1
- package/dist/api.js +2 -2
- package/dist/channel-plugin-api.js +1 -1
- package/dist/index.js +1 -1
- package/dist/setup-entry.js +1 -1
- package/node_modules/@line/bot-sdk/node_modules/@types/node/README.md +1 -1
- package/node_modules/@line/bot-sdk/node_modules/@types/node/package.json +2 -2
- package/node_modules/@line/bot-sdk/node_modules/@types/node/util.d.ts +7 -4
- package/node_modules/typebox/build/format/duration.d.mts +2 -2
- package/node_modules/typebox/build/format/duration.mjs +2 -2
- package/node_modules/typebox/build/format/idn_email.d.mts +1 -0
- package/node_modules/typebox/build/format/idn_email.mjs +1 -0
- package/node_modules/typebox/build/format/idn_hostname.d.mts +1 -1
- package/node_modules/typebox/build/format/idn_hostname.mjs +1 -1
- package/node_modules/typebox/build/format/ipv4.d.mts +2 -2
- package/node_modules/typebox/build/format/ipv4.mjs +2 -2
- package/node_modules/typebox/build/format/ipv6.d.mts +1 -1
- package/node_modules/typebox/build/format/ipv6.mjs +1 -1
- package/node_modules/typebox/build/format/relative_json_pointer.d.mts +2 -2
- package/node_modules/typebox/build/format/relative_json_pointer.mjs +2 -2
- package/node_modules/typebox/build/schema/build.mjs +1 -0
- package/node_modules/typebox/build/schema/engine/_unique.d.mts +4 -2
- package/node_modules/typebox/build/schema/engine/_unique.mjs +7 -3
- package/node_modules/typebox/build/schema/engine/additionalItems.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/additionalProperties.d.mts +0 -3
- package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +15 -17
- package/node_modules/typebox/build/schema/engine/contains.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/index.d.mts +1 -0
- package/node_modules/typebox/build/schema/engine/index.mjs +1 -0
- package/node_modules/typebox/build/schema/engine/items.mjs +7 -4
- package/node_modules/typebox/build/schema/engine/maxContains.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/minContains.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/oneOf.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/patternProperties.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/propertyNames.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/unevaluatedItems.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/unevaluatedProperties.mjs +2 -2
- package/node_modules/typebox/build/system/hashing/hash.mjs +63 -34
- package/node_modules/typebox/build/system/locale/en_US.mjs +2 -1
- package/node_modules/typebox/build/system/memory/assign.d.mts +2 -8
- package/node_modules/typebox/build/system/memory/assign.mjs +13 -6
- package/node_modules/typebox/build/system/memory/clone.d.mts +4 -5
- package/node_modules/typebox/build/system/memory/clone.mjs +8 -96
- package/node_modules/typebox/build/system/memory/create.d.mts +1 -5
- package/node_modules/typebox/build/system/memory/create.mjs +18 -13
- package/node_modules/typebox/build/system/memory/deep.d.mts +2 -0
- package/node_modules/typebox/build/system/memory/deep.mjs +108 -0
- package/node_modules/typebox/build/system/memory/discard.d.mts +1 -1
- package/node_modules/typebox/build/system/memory/discard.mjs +9 -8
- package/node_modules/typebox/build/system/memory/finalize.d.mts +4 -0
- package/node_modules/typebox/build/system/memory/finalize.mjs +30 -0
- package/node_modules/typebox/build/system/memory/keys.d.mts +2 -0
- package/node_modules/typebox/build/system/memory/keys.mjs +8 -0
- package/node_modules/typebox/build/system/memory/update.d.mts +1 -4
- package/node_modules/typebox/build/system/memory/update.mjs +43 -16
- package/node_modules/typebox/build/type/engine/call/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/call/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +2 -24
- package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +2 -29
- package/node_modules/typebox/build/type/engine/evaluate/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/evaluate/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/evaluate/narrow.d.mts +5 -1
- package/node_modules/typebox/build/type/engine/evaluate/narrow.mjs +6 -1
- package/node_modules/typebox/build/type/engine/evaluate/property.d.mts +30 -0
- package/node_modules/typebox/build/type/engine/evaluate/property.mjs +29 -0
- package/node_modules/typebox/build/type/engine/immutable/instantiate_add.d.mts +1 -3
- package/node_modules/typebox/build/type/engine/immutable/instantiate_add.mjs +1 -4
- package/node_modules/typebox/build/type/engine/object/from_intersect.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/object/from_intersect.mjs +2 -2
- package/node_modules/typebox/build/type/engine/object/from_union.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/object/from_union.mjs +2 -2
- package/node_modules/typebox/build/type/engine/optional/instantiate_add.d.mts +1 -3
- package/node_modules/typebox/build/type/engine/optional/instantiate_add.mjs +1 -4
- package/node_modules/typebox/build/type/engine/readonly/instantiate_add.d.mts +1 -3
- package/node_modules/typebox/build/type/engine/readonly/instantiate_add.mjs +1 -4
- package/node_modules/typebox/build/type/engine/this/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/this/index.mjs +1 -0
- package/node_modules/typebox/build/value/clone/clone.d.mts +4 -3
- package/node_modules/typebox/build/value/clone/clone.mjs +5 -7
- package/node_modules/typebox/build/value/repair/from_cyclic.d.mts +2 -0
- package/node_modules/typebox/build/value/repair/from_cyclic.mjs +6 -0
- package/node_modules/typebox/build/value/shared/union_priority_sort.mjs +25 -14
- package/node_modules/typebox/package.json +1 -1
- package/node_modules/typebox/readme.md +1 -1
- package/node_modules/zod/package.json +1 -1
- package/node_modules/zod/src/v4/classic/tests/array.test.ts +27 -0
- package/node_modules/zod/src/v4/classic/tests/map.test.ts +7 -0
- package/node_modules/zod/src/v4/classic/tests/set.test.ts +6 -0
- package/node_modules/zod/src/v4/core/compile.ts +9 -0
- package/node_modules/zod/src/v4/core/schemas.ts +35 -1
- package/node_modules/zod/src/v4/core/util.ts +13 -0
- package/node_modules/zod/src/v4/core/versions.ts +1 -1
- package/node_modules/zod/v4/core/compile.cjs +8 -0
- package/node_modules/zod/v4/core/compile.js +8 -0
- package/node_modules/zod/v4/core/schemas.cjs +30 -0
- package/node_modules/zod/v4/core/schemas.d.cts +3 -1
- package/node_modules/zod/v4/core/schemas.d.ts +3 -1
- package/node_modules/zod/v4/core/schemas.js +30 -0
- package/node_modules/zod/v4/core/util.cjs +15 -0
- package/node_modules/zod/v4/core/util.d.cts +2 -0
- package/node_modules/zod/v4/core/util.d.ts +2 -0
- package/node_modules/zod/v4/core/util.js +14 -0
- package/node_modules/zod/v4/core/versions.cjs +1 -1
- package/node_modules/zod/v4/core/versions.js +1 -1
- package/package.json +6 -6
- package/dist/.setup/api-EJnP_1cJ.mjs +0 -3
- package/dist/.setup/channel.runtime-4w8EffJb.mjs +0 -4
- package/dist/.setup/monitor.runtime-BWIgUqzC.mjs +0 -1
- package/dist/.setup/probe.runtime-a-fC57xd.mjs +0 -1
- package/node_modules/typebox/build/system/memory/freeze.d.mts +0 -4
- package/node_modules/typebox/build/system/memory/freeze.mjs +0 -6
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { c as pushLocationMessage, d as pushTemplateMessage, f as pushTextMessageWithQuickReplies, l as pushMessageLine, n as createLocationMessage, r as createQuickReplyItems, s as pushFlexMessage, t as createFlexMessage, u as pushMessagesLine } from "./send-
|
|
2
|
-
import { n as processLineMessage, t as buildTemplateMessageFromPayload } from "./template-messages-
|
|
1
|
+
import { c as pushLocationMessage, d as pushTemplateMessage, f as pushTextMessageWithQuickReplies, l as pushMessageLine, n as createLocationMessage, r as createQuickReplyItems, s as pushFlexMessage, t as createFlexMessage, u as pushMessagesLine } from "./send-H86JOXWw.mjs";
|
|
2
|
+
import { n as processLineMessage, t as buildTemplateMessageFromPayload } from "./template-messages-KG1GwG0h.mjs";
|
|
3
3
|
export { buildTemplateMessageFromPayload, createFlexMessage, createLocationMessage, createQuickReplyItems, processLineMessage, pushFlexMessage, pushLocationMessage, pushMessageLine, pushMessagesLine, pushTemplateMessage, pushTextMessageWithQuickReplies };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { E as applyLineQuoteToken, F as normalizeLineMessagingTarget, M as withoutLineQuoteTokens, N as buildLineMediaMessage, b as normalizeLineMessage, i as runLinePushWithRetries, n as findLineHttpError, s as resolveLineChannelAccessToken, y as messageAction } from "./send-retry-D6J7bThI.mjs";
|
|
1
2
|
import { r as resolveLineAccount } from "./accounts-Dm_NoU7R.mjs";
|
|
2
|
-
import { M as buildLineMediaMessage, T as applyLineQuoteToken, i as runLinePushWithRetries, j as withoutLineQuoteTokens, n as findLineHttpError, o as resolveLineChannelAccessToken, v as messageAction, y as normalizeLineMessage } from "./send-retry-gHsCgBlf.mjs";
|
|
3
3
|
import { createMessageReceiptFromOutboundResults } from "openclaw/plugin-sdk/channel-outbound";
|
|
4
4
|
import { createChannelPartialDeliveryError } from "openclaw/plugin-sdk/channel-inbound";
|
|
5
|
-
import {
|
|
5
|
+
import { createStaleWhileRevalidateCache } from "openclaw/plugin-sdk/collection-runtime";
|
|
6
6
|
import { logVerbose } from "openclaw/plugin-sdk/runtime-env";
|
|
7
7
|
import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
8
8
|
import { HTTPFetchError, messagingApi } from "@line/bot-sdk";
|
|
@@ -36,64 +36,20 @@ function recordLineSentMessages(accountId, messageIds) {
|
|
|
36
36
|
function quotesLineBotMessage(accountId, quotedMessageId) {
|
|
37
37
|
return recentSentByAccount.get(accountId)?.peek(quotedMessageId) ?? false;
|
|
38
38
|
}
|
|
39
|
-
// extensions/line/src/send-receipt.ts
|
|
40
|
-
function createLineSendReceipt(params) {
|
|
41
|
-
const messageIds = (params.messageIds ?? [params.messageId]).map((messageId) => messageId.trim()).filter(Boolean);
|
|
42
|
-
const chatId = params.chatId.trim();
|
|
43
|
-
return createMessageReceiptFromOutboundResults({
|
|
44
|
-
results: messageIds.map((messageId) => ({
|
|
45
|
-
channel: "line",
|
|
46
|
-
messageId,
|
|
47
|
-
chatId,
|
|
48
|
-
conversationId: chatId,
|
|
49
|
-
meta: { messageCount: params.messageCount ?? 1 }
|
|
50
|
-
})),
|
|
51
|
-
...chatId ? { threadId: chatId } : {},
|
|
52
|
-
kind: params.kind ?? "unknown"
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
39
|
// extensions/line/src/send.ts
|
|
56
|
-
const profileCache = {
|
|
57
|
-
values: /* @__PURE__ */ new Map(),
|
|
58
|
-
pending: /* @__PURE__ */ new Map()
|
|
59
|
-
};
|
|
60
|
-
const groupNameCache = {
|
|
61
|
-
values: /* @__PURE__ */ new Map(),
|
|
62
|
-
pending: /* @__PURE__ */ new Map()
|
|
63
|
-
};
|
|
64
40
|
const PROFILE_CACHE_TTL_MS = 3e5;
|
|
65
41
|
const PROFILE_CACHE_MAX_ENTRIES = 1e3;
|
|
42
|
+
const profileCache = createStaleWhileRevalidateCache({
|
|
43
|
+
maxEntries: PROFILE_CACHE_MAX_ENTRIES,
|
|
44
|
+
ttlMs: PROFILE_CACHE_TTL_MS
|
|
45
|
+
});
|
|
46
|
+
const groupNameCache = createStaleWhileRevalidateCache({
|
|
47
|
+
maxEntries: PROFILE_CACHE_MAX_ENTRIES,
|
|
48
|
+
ttlMs: PROFILE_CACHE_TTL_MS
|
|
49
|
+
});
|
|
66
50
|
const LINE_FLEX_ALT_TEXT_LIMIT = 1500;
|
|
67
51
|
const LINE_LOCATION_LABEL_LIMIT = 100;
|
|
68
52
|
const LINE_PROVIDER_RESPONSE_MAX_BYTES = 16384;
|
|
69
|
-
function rememberLineIdentity(cache, key, value) {
|
|
70
|
-
const entry = {
|
|
71
|
-
value,
|
|
72
|
-
fetchedAt: Date.now()
|
|
73
|
-
};
|
|
74
|
-
cache.values.delete(key);
|
|
75
|
-
cache.values.set(key, entry);
|
|
76
|
-
if (cache.values.size <= PROFILE_CACHE_MAX_ENTRIES) return;
|
|
77
|
-
for (const [cachedKey, cached] of cache.values) if (entry.fetchedAt - cached.fetchedAt >= PROFILE_CACHE_TTL_MS) cache.values.delete(cachedKey);
|
|
78
|
-
pruneMapToMaxSize(cache.values, PROFILE_CACHE_MAX_ENTRIES);
|
|
79
|
-
}
|
|
80
|
-
async function loadLineIdentity(cache, key, load) {
|
|
81
|
-
const cached = cache.values.get(key);
|
|
82
|
-
if (cached && Date.now() - cached.fetchedAt < PROFILE_CACHE_TTL_MS) return cached.value;
|
|
83
|
-
const pending = cache.pending.get(key);
|
|
84
|
-
if (pending) return await pending;
|
|
85
|
-
const lookup = load().then((value) => {
|
|
86
|
-
rememberLineIdentity(cache, key, value);
|
|
87
|
-
return value;
|
|
88
|
-
});
|
|
89
|
-
cache.pending.set(key, lookup);
|
|
90
|
-
pruneMapToMaxSize(cache.pending, PROFILE_CACHE_MAX_ENTRIES);
|
|
91
|
-
try {
|
|
92
|
-
return await lookup;
|
|
93
|
-
} finally {
|
|
94
|
-
if (cache.pending.get(key) === lookup) cache.pending.delete(key);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
53
|
function resolveLineProviderMessageIds(response, operation) {
|
|
98
54
|
const sentMessages = Array.isArray(response?.sentMessages) ? response.sentMessages : [];
|
|
99
55
|
const messageIds = sentMessages.flatMap((entry) => {
|
|
@@ -112,9 +68,7 @@ function resolveLineProviderMessageIds(response, operation) {
|
|
|
112
68
|
};
|
|
113
69
|
}
|
|
114
70
|
function normalizeTarget(to) {
|
|
115
|
-
const
|
|
116
|
-
if (!trimmed) throw new Error("Recipient is required for LINE sends");
|
|
117
|
-
const normalized = trimmed.replace(/^line:group:/i, "").replace(/^line:room:/i, "").replace(/^line:user:/i, "").replace(/^line:/i, "");
|
|
71
|
+
const normalized = normalizeLineMessagingTarget(to);
|
|
118
72
|
if (!normalized) throw new Error("Recipient is required for LINE sends");
|
|
119
73
|
if (normalized.length >= 33 && !/^[CUR]/.test(normalized)) throw new Error(`Recipient is not a valid LINE id (case-sensitive; expected leading capital C/U/R): ${truncateUtf16Safe(normalized, 4)}…`);
|
|
120
74
|
return normalized;
|
|
@@ -195,14 +149,6 @@ function createLocationMessage(location) {
|
|
|
195
149
|
longitude: location.longitude
|
|
196
150
|
};
|
|
197
151
|
}
|
|
198
|
-
function logLineHttpError(err, context) {
|
|
199
|
-
if (!err || typeof err !== "object") return;
|
|
200
|
-
const { status, statusText, body } = err;
|
|
201
|
-
if (typeof body === "string") {
|
|
202
|
-
const summary = status ? `${status} ${statusText ?? ""}`.trim() : "unknown status";
|
|
203
|
-
logVerbose(`line: ${context} failed (${summary}): ${body}`);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
152
|
function recordLineOutboundActivity(accountId, delivery) {
|
|
207
153
|
recordLineSentMessages(accountId, delivery.messageIds);
|
|
208
154
|
try {
|
|
@@ -227,42 +173,35 @@ function resolveLineReceiptKind(messages) {
|
|
|
227
173
|
if (types.has("text")) return "text";
|
|
228
174
|
return "unknown";
|
|
229
175
|
}
|
|
230
|
-
async function pushLineMessages(to, messages, opts
|
|
176
|
+
async function pushLineMessages(to, messages, opts) {
|
|
231
177
|
if (messages.length === 0) throw new Error("Message must be non-empty for LINE sends");
|
|
232
178
|
const { account, token } = resolveLineMessagingAccount(opts);
|
|
233
179
|
const chatId = normalizeTarget(to);
|
|
234
180
|
const normalizedMessages = applyLineQuoteToken(messages, opts.quoteToken).map(normalizeLineMessage);
|
|
235
181
|
const retryKey = randomUUID();
|
|
236
|
-
const { messageId, messageIds } = resolveLineProviderMessageIds(await runLinePushWithRetries(
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
messages: normalizedMessages
|
|
241
|
-
}, retryKey, opts.authorize, opts.assertDirectAdapterHandoff);
|
|
242
|
-
} catch (err) {
|
|
243
|
-
if (behavior.errorContext) logLineHttpError(err, behavior.errorContext);
|
|
244
|
-
throw err;
|
|
245
|
-
}
|
|
246
|
-
}, "line:push"), "push");
|
|
182
|
+
const { messageId, messageIds } = resolveLineProviderMessageIds(await runLinePushWithRetries(() => sendLineProviderMessages("push", token, {
|
|
183
|
+
to: chatId,
|
|
184
|
+
messages: normalizedMessages
|
|
185
|
+
}, retryKey, opts.authorize, opts.assertDirectAdapterHandoff), "line:push"), "push");
|
|
247
186
|
const result = {
|
|
248
187
|
messageId,
|
|
249
188
|
chatId,
|
|
250
|
-
receipt:
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
189
|
+
receipt: createMessageReceiptFromOutboundResults({
|
|
190
|
+
results: messageIds.map((providerMessageId) => ({
|
|
191
|
+
channel: "line",
|
|
192
|
+
messageId: providerMessageId,
|
|
193
|
+
chatId,
|
|
194
|
+
conversationId: chatId,
|
|
195
|
+
meta: { messageCount: messages.length }
|
|
196
|
+
})),
|
|
197
|
+
...chatId ? { threadId: chatId } : {},
|
|
198
|
+
kind: resolveLineReceiptKind(messages)
|
|
256
199
|
})
|
|
257
200
|
};
|
|
258
201
|
recordLineOutboundActivity(account.accountId, {
|
|
259
202
|
messageIds,
|
|
260
203
|
receipt: result.receipt
|
|
261
204
|
});
|
|
262
|
-
if (opts.verbose) {
|
|
263
|
-
const logMessage = behavior.verboseMessage?.(chatId, messages.length) ?? `line: pushed ${messages.length} messages to ${chatId}`;
|
|
264
|
-
logVerbose(logMessage);
|
|
265
|
-
}
|
|
266
205
|
return result;
|
|
267
206
|
}
|
|
268
207
|
async function pushMessageLine(to, text, opts) {
|
|
@@ -279,7 +218,7 @@ async function pushMessageLine(to, text, opts) {
|
|
|
279
218
|
type: "text",
|
|
280
219
|
text: text.trim()
|
|
281
220
|
});
|
|
282
|
-
return pushLineMessages(chatId, messages, opts
|
|
221
|
+
return pushLineMessages(chatId, messages, opts);
|
|
283
222
|
}
|
|
284
223
|
async function replyMessageLine(replyToken, messages, opts) {
|
|
285
224
|
const { account, token } = resolveLineMessagingAccount(opts);
|
|
@@ -288,10 +227,9 @@ async function replyMessageLine(replyToken, messages, opts) {
|
|
|
288
227
|
messages: applyLineQuoteToken(messages, opts.quoteToken).map(normalizeLineMessage)
|
|
289
228
|
}, void 0, opts.authorize, opts.assertDirectAdapterHandoff), "reply");
|
|
290
229
|
recordLineOutboundActivity(account.accountId, { messageIds });
|
|
291
|
-
if (opts.verbose) logVerbose(`line: replied with ${messages.length} messages`);
|
|
292
230
|
}
|
|
293
231
|
async function pushMessagesLine(to, messages, opts) {
|
|
294
|
-
return pushLineMessages(to, messages, opts
|
|
232
|
+
return pushLineMessages(to, messages, opts);
|
|
295
233
|
}
|
|
296
234
|
function createFlexMessage(altText, contents) {
|
|
297
235
|
return {
|
|
@@ -301,26 +239,23 @@ function createFlexMessage(altText, contents) {
|
|
|
301
239
|
};
|
|
302
240
|
}
|
|
303
241
|
async function pushLocationMessage(to, location, opts) {
|
|
304
|
-
return pushLineMessages(to, [createLocationMessage(location)], opts
|
|
242
|
+
return pushLineMessages(to, [createLocationMessage(location)], opts);
|
|
305
243
|
}
|
|
306
244
|
async function pushFlexMessage(to, altText, contents, opts) {
|
|
307
|
-
return pushLineMessages(to, [createFlexMessage(altText, contents)], opts
|
|
308
|
-
errorContext: "push flex message",
|
|
309
|
-
verboseMessage: (chatId) => `line: pushed flex message to ${chatId}`
|
|
310
|
-
});
|
|
245
|
+
return pushLineMessages(to, [createFlexMessage(altText, contents)], opts);
|
|
311
246
|
}
|
|
312
247
|
async function pushTemplateMessage(to, template, opts) {
|
|
313
|
-
return pushLineMessages(to, [template], opts
|
|
248
|
+
return pushLineMessages(to, [template], opts);
|
|
314
249
|
}
|
|
315
250
|
async function pushTextMessageWithQuickReplies(to, text, quickReplyLabels, opts) {
|
|
316
251
|
return pushLineMessages(to, [{
|
|
317
252
|
type: "text",
|
|
318
253
|
text,
|
|
319
254
|
quickReply: createQuickReplyItems(quickReplyLabels)
|
|
320
|
-
}], opts
|
|
255
|
+
}], opts);
|
|
321
256
|
}
|
|
322
257
|
function createQuickReplyItems(labels) {
|
|
323
|
-
return { items: labels.slice(0, 13).map((label) => ({
|
|
258
|
+
return { items: labels.map((label) => label.trim()).filter(Boolean).slice(0, 13).map((label) => ({
|
|
324
259
|
type: "action",
|
|
325
260
|
action: messageAction(label, label)
|
|
326
261
|
})) };
|
|
@@ -331,9 +266,8 @@ async function showLoadingAnimation(chatId, opts) {
|
|
|
331
266
|
try {
|
|
332
267
|
await client.showLoadingAnimation({
|
|
333
268
|
chatId: normalizeTarget(chatId),
|
|
334
|
-
loadingSeconds:
|
|
269
|
+
loadingSeconds: 20
|
|
335
270
|
});
|
|
336
|
-
logVerbose(`line: showing loading animation to ${chatId}`);
|
|
337
271
|
} catch (err) {
|
|
338
272
|
logVerbose(`line: loading animation failed (non-fatal): ${String(err)}`);
|
|
339
273
|
}
|
|
@@ -368,7 +302,7 @@ async function getUserProfile(userId, opts) {
|
|
|
368
302
|
return null;
|
|
369
303
|
}
|
|
370
304
|
};
|
|
371
|
-
return await
|
|
305
|
+
return (await profileCache.read(cacheKey, load, { allowStale: false })).value;
|
|
372
306
|
} catch (err) {
|
|
373
307
|
logVerbose(`line: failed to fetch profile for ${userId}: ${String(err)}`);
|
|
374
308
|
return null;
|
|
@@ -385,14 +319,14 @@ async function getLineGroupName(groupId, opts) {
|
|
|
385
319
|
"group",
|
|
386
320
|
groupId
|
|
387
321
|
]);
|
|
388
|
-
return await
|
|
322
|
+
return (await groupNameCache.read(cacheKey, async () => {
|
|
389
323
|
try {
|
|
390
324
|
return (await new messagingApi.MessagingApiClient({ channelAccessToken: token }).getGroupSummary(groupId)).groupName.trim() || void 0;
|
|
391
325
|
} catch (err) {
|
|
392
326
|
logVerbose(`line: failed to fetch group summary for ${groupId}: ${String(err)}`);
|
|
393
327
|
return;
|
|
394
328
|
}
|
|
395
|
-
});
|
|
329
|
+
}, { allowStale: false })).value;
|
|
396
330
|
} catch (err) {
|
|
397
331
|
logVerbose(`line: failed to fetch group summary for ${groupId}: ${String(err)}`);
|
|
398
332
|
return;
|