dsh-line-bot 0.9.3 → 0.9.4
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/CHANGELOG.md +5 -0
- package/lib/host.mjs +5 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/lib/host.mjs
CHANGED
|
@@ -47,7 +47,7 @@ const { createStickerImages } = stickerImageMod
|
|
|
47
47
|
const { createVision } = visionMod
|
|
48
48
|
const { chunkText, clip, inQuietWindow, jsonFail, jsonOk, maskSecret, readJsonBody, safeArray, sleep, readJsonSafe } = utilMod
|
|
49
49
|
|
|
50
|
-
export const VERSION = '0.9.
|
|
50
|
+
export const VERSION = '0.9.4'
|
|
51
51
|
|
|
52
52
|
// 環境變數提供的 Cloudflare API Token(方便用 shell 注入、不用把 token 寫進設定檔)。
|
|
53
53
|
// 設定檔裡的 token 優先;兩者都沒有時才用環境變數。
|
|
@@ -1858,9 +1858,11 @@ export async function create({ ctx, config: pluginConfig, logger: upstream }) {
|
|
|
1858
1858
|
|
|
1859
1859
|
async function sendPush(userId, text) {
|
|
1860
1860
|
const { messages } = await buildOutgoingMessages(text)
|
|
1861
|
-
if (messages.length === 0) return
|
|
1861
|
+
if (messages.length === 0) return { sent: false, reason: 'empty' }
|
|
1862
1862
|
const imageCount = messages.filter((item) => typeof item !== 'string' && item.type === 'image').length
|
|
1863
1863
|
if (imageCount > 0) logger.info(`主動訊息含 ${imageCount} 張圖片`)
|
|
1864
|
+
const response = await withToken((token) => lineApi.pushMessage(token, userId, messages))
|
|
1865
|
+
logger.info(`主動訊息已送出(${messages.length} 則,LINE 回報 ${Array.isArray(response?.sentMessages) ? response.sentMessages.length : '未知'} 則)`)
|
|
1864
1866
|
store.updateState((state) => ({
|
|
1865
1867
|
...state,
|
|
1866
1868
|
users: {
|
|
@@ -1868,6 +1870,7 @@ export async function create({ ctx, config: pluginConfig, logger: upstream }) {
|
|
|
1868
1870
|
[userId]: { ...(state.users[userId] || {}), lastAt: Date.now(), lastPushAt: Date.now() },
|
|
1869
1871
|
},
|
|
1870
1872
|
}))
|
|
1873
|
+
return { sent: true, count: messages.length, requestId: response?.requestId || '' }
|
|
1871
1874
|
}
|
|
1872
1875
|
|
|
1873
1876
|
const nudge = createNudgeScheduler({
|