@openclaw/line 2026.10.10-beta.5 → 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/{accounts-DOiM8-y3.mjs → accounts-Dm_NoU7R.mjs} +1 -2
- package/dist/.setup/{api-PmHlEZ7r.mjs → api-ByXjHPMe.mjs} +3 -4
- package/dist/.setup/api-DCMpIrda.mjs +3 -0
- package/dist/.setup/{card-command-BMLk4YKh.mjs → card-command-utjlRvb-.mjs} +27 -45
- package/dist/.setup/{channel-j3EnT95N.mjs → channel-D9i_xlsJ.mjs} +252 -359
- package/dist/.setup/channel.runtime-C-E2qsIu.mjs +4 -0
- package/dist/.setup/{monitor-DQ-v9pI6.mjs → monitor-BYGe2Y7S.mjs} +256 -358
- package/dist/.setup/{outbound.runtime-BJL2119X.mjs → outbound.runtime-AQvUJvJV.mjs} +2 -2
- package/dist/.setup/{runtime-V7yh9OeC.mjs → runtime-C9ldw-V4.mjs} +1 -2
- package/dist/.setup/{send-g4gFsc9W.mjs → send-H86JOXWw.mjs} +40 -109
- package/dist/.setup/{send-retry-Dzbkz5wG.mjs → send-retry-D6J7bThI.mjs} +187 -105
- package/dist/.setup/{setup-surface-CYd8oqzt.mjs → setup-surface-DvbBjHFi.mjs} +5 -9
- package/dist/.setup/{template-messages-COcdie6C.mjs → template-messages-KG1GwG0h.mjs} +36 -52
- package/dist/.setup/{webhook-spool-contract-msjTl60Q.mjs → webhook-spool-contract-COhQK5XQ.mjs} +1 -2
- 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/contract-api.js +1 -1
- package/dist/doctor-contract-api.js +3 -5
- package/dist/index.js +2 -3
- package/dist/runtime-api.js +1 -1
- package/dist/secret-contract-api.js +1 -2
- package/dist/setup-api.js +1 -1
- package/dist/setup-entry.js +2 -3
- 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-Bis3gHmg.mjs +0 -3
- package/dist/.setup/channel.runtime-in_KhKi8.mjs +0 -4
- package/dist/.setup/monitor.runtime-DtJPzQya.mjs +0 -1
- package/dist/.setup/probe.runtime-DaGwztSg.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,7 @@
|
|
|
1
1
|
import { createPluginRuntimeStore } from "openclaw/plugin-sdk/runtime-store";
|
|
2
|
-
|
|
2
|
+
// extensions/line/src/runtime.ts
|
|
3
3
|
const { setRuntime: setLineRuntime, getRuntime: getLineRuntime } = createPluginRuntimeStore({
|
|
4
4
|
pluginId: "line",
|
|
5
5
|
errorMessage: "LINE runtime not initialized - plugin not registered"
|
|
6
6
|
});
|
|
7
|
-
//#endregion
|
|
8
7
|
export { setLineRuntime as n, getLineRuntime as t };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
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";
|
|
2
|
+
import { r as resolveLineAccount } from "./accounts-Dm_NoU7R.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";
|
|
@@ -15,7 +15,7 @@ import { captureEffectAuthority } from "openclaw/plugin-sdk/fetch-runtime";
|
|
|
15
15
|
import { redactToolPayloadText } from "openclaw/plugin-sdk/logging-core";
|
|
16
16
|
import { requireRuntimeConfig } from "openclaw/plugin-sdk/plugin-config-runtime";
|
|
17
17
|
import { createDedupeCache } from "openclaw/plugin-sdk/dedupe-runtime";
|
|
18
|
-
|
|
18
|
+
// extensions/line/src/outbound-message-log.ts
|
|
19
19
|
const RECENT_SENT_LIMIT = 500;
|
|
20
20
|
const recentSentByAccount = /* @__PURE__ */ new Map();
|
|
21
21
|
function recentSentFor(accountId) {
|
|
@@ -36,66 +36,20 @@ function recordLineSentMessages(accountId, messageIds) {
|
|
|
36
36
|
function quotesLineBotMessage(accountId, quotedMessageId) {
|
|
37
37
|
return recentSentByAccount.get(accountId)?.peek(quotedMessageId) ?? false;
|
|
38
38
|
}
|
|
39
|
-
|
|
40
|
-
//#region extensions/line/src/send-receipt.ts
|
|
41
|
-
function createLineSendReceipt(params) {
|
|
42
|
-
const messageIds = (params.messageIds ?? [params.messageId]).map((messageId) => messageId.trim()).filter(Boolean);
|
|
43
|
-
const chatId = params.chatId.trim();
|
|
44
|
-
return createMessageReceiptFromOutboundResults({
|
|
45
|
-
results: messageIds.map((messageId) => ({
|
|
46
|
-
channel: "line",
|
|
47
|
-
messageId,
|
|
48
|
-
chatId,
|
|
49
|
-
conversationId: chatId,
|
|
50
|
-
meta: { messageCount: params.messageCount ?? 1 }
|
|
51
|
-
})),
|
|
52
|
-
...chatId ? { threadId: chatId } : {},
|
|
53
|
-
kind: params.kind ?? "unknown"
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
//#endregion
|
|
57
|
-
//#region extensions/line/src/send.ts
|
|
58
|
-
const profileCache = {
|
|
59
|
-
values: /* @__PURE__ */ new Map(),
|
|
60
|
-
pending: /* @__PURE__ */ new Map()
|
|
61
|
-
};
|
|
62
|
-
const groupNameCache = {
|
|
63
|
-
values: /* @__PURE__ */ new Map(),
|
|
64
|
-
pending: /* @__PURE__ */ new Map()
|
|
65
|
-
};
|
|
39
|
+
// extensions/line/src/send.ts
|
|
66
40
|
const PROFILE_CACHE_TTL_MS = 3e5;
|
|
67
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
|
+
});
|
|
68
50
|
const LINE_FLEX_ALT_TEXT_LIMIT = 1500;
|
|
69
51
|
const LINE_LOCATION_LABEL_LIMIT = 100;
|
|
70
52
|
const LINE_PROVIDER_RESPONSE_MAX_BYTES = 16384;
|
|
71
|
-
function rememberLineIdentity(cache, key, value) {
|
|
72
|
-
const entry = {
|
|
73
|
-
value,
|
|
74
|
-
fetchedAt: Date.now()
|
|
75
|
-
};
|
|
76
|
-
cache.values.delete(key);
|
|
77
|
-
cache.values.set(key, entry);
|
|
78
|
-
if (cache.values.size <= PROFILE_CACHE_MAX_ENTRIES) return;
|
|
79
|
-
for (const [cachedKey, cached] of cache.values) if (entry.fetchedAt - cached.fetchedAt >= PROFILE_CACHE_TTL_MS) cache.values.delete(cachedKey);
|
|
80
|
-
pruneMapToMaxSize(cache.values, PROFILE_CACHE_MAX_ENTRIES);
|
|
81
|
-
}
|
|
82
|
-
async function loadLineIdentity(cache, key, load) {
|
|
83
|
-
const cached = cache.values.get(key);
|
|
84
|
-
if (cached && Date.now() - cached.fetchedAt < PROFILE_CACHE_TTL_MS) return cached.value;
|
|
85
|
-
const pending = cache.pending.get(key);
|
|
86
|
-
if (pending) return await pending;
|
|
87
|
-
const lookup = load().then((value) => {
|
|
88
|
-
rememberLineIdentity(cache, key, value);
|
|
89
|
-
return value;
|
|
90
|
-
});
|
|
91
|
-
cache.pending.set(key, lookup);
|
|
92
|
-
pruneMapToMaxSize(cache.pending, PROFILE_CACHE_MAX_ENTRIES);
|
|
93
|
-
try {
|
|
94
|
-
return await lookup;
|
|
95
|
-
} finally {
|
|
96
|
-
if (cache.pending.get(key) === lookup) cache.pending.delete(key);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
53
|
function resolveLineProviderMessageIds(response, operation) {
|
|
100
54
|
const sentMessages = Array.isArray(response?.sentMessages) ? response.sentMessages : [];
|
|
101
55
|
const messageIds = sentMessages.flatMap((entry) => {
|
|
@@ -114,9 +68,7 @@ function resolveLineProviderMessageIds(response, operation) {
|
|
|
114
68
|
};
|
|
115
69
|
}
|
|
116
70
|
function normalizeTarget(to) {
|
|
117
|
-
const
|
|
118
|
-
if (!trimmed) throw new Error("Recipient is required for LINE sends");
|
|
119
|
-
const normalized = trimmed.replace(/^line:group:/i, "").replace(/^line:room:/i, "").replace(/^line:user:/i, "").replace(/^line:/i, "");
|
|
71
|
+
const normalized = normalizeLineMessagingTarget(to);
|
|
120
72
|
if (!normalized) throw new Error("Recipient is required for LINE sends");
|
|
121
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)}…`);
|
|
122
74
|
return normalized;
|
|
@@ -197,14 +149,6 @@ function createLocationMessage(location) {
|
|
|
197
149
|
longitude: location.longitude
|
|
198
150
|
};
|
|
199
151
|
}
|
|
200
|
-
function logLineHttpError(err, context) {
|
|
201
|
-
if (!err || typeof err !== "object") return;
|
|
202
|
-
const { status, statusText, body } = err;
|
|
203
|
-
if (typeof body === "string") {
|
|
204
|
-
const summary = status ? `${status} ${statusText ?? ""}`.trim() : "unknown status";
|
|
205
|
-
logVerbose(`line: ${context} failed (${summary}): ${body}`);
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
152
|
function recordLineOutboundActivity(accountId, delivery) {
|
|
209
153
|
recordLineSentMessages(accountId, delivery.messageIds);
|
|
210
154
|
try {
|
|
@@ -229,42 +173,35 @@ function resolveLineReceiptKind(messages) {
|
|
|
229
173
|
if (types.has("text")) return "text";
|
|
230
174
|
return "unknown";
|
|
231
175
|
}
|
|
232
|
-
async function pushLineMessages(to, messages, opts
|
|
176
|
+
async function pushLineMessages(to, messages, opts) {
|
|
233
177
|
if (messages.length === 0) throw new Error("Message must be non-empty for LINE sends");
|
|
234
178
|
const { account, token } = resolveLineMessagingAccount(opts);
|
|
235
179
|
const chatId = normalizeTarget(to);
|
|
236
180
|
const normalizedMessages = applyLineQuoteToken(messages, opts.quoteToken).map(normalizeLineMessage);
|
|
237
181
|
const retryKey = randomUUID();
|
|
238
|
-
const { messageId, messageIds } = resolveLineProviderMessageIds(await runLinePushWithRetries(
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
messages: normalizedMessages
|
|
243
|
-
}, retryKey, opts.authorize, opts.assertDirectAdapterHandoff);
|
|
244
|
-
} catch (err) {
|
|
245
|
-
if (behavior.errorContext) logLineHttpError(err, behavior.errorContext);
|
|
246
|
-
throw err;
|
|
247
|
-
}
|
|
248
|
-
}, "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");
|
|
249
186
|
const result = {
|
|
250
187
|
messageId,
|
|
251
188
|
chatId,
|
|
252
|
-
receipt:
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
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)
|
|
258
199
|
})
|
|
259
200
|
};
|
|
260
201
|
recordLineOutboundActivity(account.accountId, {
|
|
261
202
|
messageIds,
|
|
262
203
|
receipt: result.receipt
|
|
263
204
|
});
|
|
264
|
-
if (opts.verbose) {
|
|
265
|
-
const logMessage = behavior.verboseMessage?.(chatId, messages.length) ?? `line: pushed ${messages.length} messages to ${chatId}`;
|
|
266
|
-
logVerbose(logMessage);
|
|
267
|
-
}
|
|
268
205
|
return result;
|
|
269
206
|
}
|
|
270
207
|
async function pushMessageLine(to, text, opts) {
|
|
@@ -281,7 +218,7 @@ async function pushMessageLine(to, text, opts) {
|
|
|
281
218
|
type: "text",
|
|
282
219
|
text: text.trim()
|
|
283
220
|
});
|
|
284
|
-
return pushLineMessages(chatId, messages, opts
|
|
221
|
+
return pushLineMessages(chatId, messages, opts);
|
|
285
222
|
}
|
|
286
223
|
async function replyMessageLine(replyToken, messages, opts) {
|
|
287
224
|
const { account, token } = resolveLineMessagingAccount(opts);
|
|
@@ -290,10 +227,9 @@ async function replyMessageLine(replyToken, messages, opts) {
|
|
|
290
227
|
messages: applyLineQuoteToken(messages, opts.quoteToken).map(normalizeLineMessage)
|
|
291
228
|
}, void 0, opts.authorize, opts.assertDirectAdapterHandoff), "reply");
|
|
292
229
|
recordLineOutboundActivity(account.accountId, { messageIds });
|
|
293
|
-
if (opts.verbose) logVerbose(`line: replied with ${messages.length} messages`);
|
|
294
230
|
}
|
|
295
231
|
async function pushMessagesLine(to, messages, opts) {
|
|
296
|
-
return pushLineMessages(to, messages, opts
|
|
232
|
+
return pushLineMessages(to, messages, opts);
|
|
297
233
|
}
|
|
298
234
|
function createFlexMessage(altText, contents) {
|
|
299
235
|
return {
|
|
@@ -303,26 +239,23 @@ function createFlexMessage(altText, contents) {
|
|
|
303
239
|
};
|
|
304
240
|
}
|
|
305
241
|
async function pushLocationMessage(to, location, opts) {
|
|
306
|
-
return pushLineMessages(to, [createLocationMessage(location)], opts
|
|
242
|
+
return pushLineMessages(to, [createLocationMessage(location)], opts);
|
|
307
243
|
}
|
|
308
244
|
async function pushFlexMessage(to, altText, contents, opts) {
|
|
309
|
-
return pushLineMessages(to, [createFlexMessage(altText, contents)], opts
|
|
310
|
-
errorContext: "push flex message",
|
|
311
|
-
verboseMessage: (chatId) => `line: pushed flex message to ${chatId}`
|
|
312
|
-
});
|
|
245
|
+
return pushLineMessages(to, [createFlexMessage(altText, contents)], opts);
|
|
313
246
|
}
|
|
314
247
|
async function pushTemplateMessage(to, template, opts) {
|
|
315
|
-
return pushLineMessages(to, [template], opts
|
|
248
|
+
return pushLineMessages(to, [template], opts);
|
|
316
249
|
}
|
|
317
250
|
async function pushTextMessageWithQuickReplies(to, text, quickReplyLabels, opts) {
|
|
318
251
|
return pushLineMessages(to, [{
|
|
319
252
|
type: "text",
|
|
320
253
|
text,
|
|
321
254
|
quickReply: createQuickReplyItems(quickReplyLabels)
|
|
322
|
-
}], opts
|
|
255
|
+
}], opts);
|
|
323
256
|
}
|
|
324
257
|
function createQuickReplyItems(labels) {
|
|
325
|
-
return { items: labels.slice(0, 13).map((label) => ({
|
|
258
|
+
return { items: labels.map((label) => label.trim()).filter(Boolean).slice(0, 13).map((label) => ({
|
|
326
259
|
type: "action",
|
|
327
260
|
action: messageAction(label, label)
|
|
328
261
|
})) };
|
|
@@ -333,9 +266,8 @@ async function showLoadingAnimation(chatId, opts) {
|
|
|
333
266
|
try {
|
|
334
267
|
await client.showLoadingAnimation({
|
|
335
268
|
chatId: normalizeTarget(chatId),
|
|
336
|
-
loadingSeconds:
|
|
269
|
+
loadingSeconds: 20
|
|
337
270
|
});
|
|
338
|
-
logVerbose(`line: showing loading animation to ${chatId}`);
|
|
339
271
|
} catch (err) {
|
|
340
272
|
logVerbose(`line: loading animation failed (non-fatal): ${String(err)}`);
|
|
341
273
|
}
|
|
@@ -370,7 +302,7 @@ async function getUserProfile(userId, opts) {
|
|
|
370
302
|
return null;
|
|
371
303
|
}
|
|
372
304
|
};
|
|
373
|
-
return await
|
|
305
|
+
return (await profileCache.read(cacheKey, load, { allowStale: false })).value;
|
|
374
306
|
} catch (err) {
|
|
375
307
|
logVerbose(`line: failed to fetch profile for ${userId}: ${String(err)}`);
|
|
376
308
|
return null;
|
|
@@ -387,18 +319,17 @@ async function getLineGroupName(groupId, opts) {
|
|
|
387
319
|
"group",
|
|
388
320
|
groupId
|
|
389
321
|
]);
|
|
390
|
-
return await
|
|
322
|
+
return (await groupNameCache.read(cacheKey, async () => {
|
|
391
323
|
try {
|
|
392
324
|
return (await new messagingApi.MessagingApiClient({ channelAccessToken: token }).getGroupSummary(groupId)).groupName.trim() || void 0;
|
|
393
325
|
} catch (err) {
|
|
394
326
|
logVerbose(`line: failed to fetch group summary for ${groupId}: ${String(err)}`);
|
|
395
327
|
return;
|
|
396
328
|
}
|
|
397
|
-
});
|
|
329
|
+
}, { allowStale: false })).value;
|
|
398
330
|
} catch (err) {
|
|
399
331
|
logVerbose(`line: failed to fetch group summary for ${groupId}: ${String(err)}`);
|
|
400
332
|
return;
|
|
401
333
|
}
|
|
402
334
|
}
|
|
403
|
-
//#endregion
|
|
404
335
|
export { getUserDisplayName as a, pushLocationMessage as c, pushTemplateMessage as d, pushTextMessageWithQuickReplies as f, quotesLineBotMessage as h, getLineGroupName as i, pushMessageLine as l, showLoadingAnimation as m, createLocationMessage as n, getUserProfile as o, replyMessageLine as p, createQuickReplyItems as r, pushFlexMessage as s, createFlexMessage as t, pushMessagesLine as u };
|