foliko 1.0.17 → 1.0.18
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/plugins/weixin-plugin.js +12 -8
package/package.json
CHANGED
package/plugins/weixin-plugin.js
CHANGED
|
@@ -48,6 +48,12 @@ module.exports = function(Plugin) {
|
|
|
48
48
|
// 获取 SessionPlugin 引用
|
|
49
49
|
this._sessionPlugin = framework.pluginManager.get('session')
|
|
50
50
|
|
|
51
|
+
// 监听定时提醒事件(放在这里,即使登录失败也要能接收事件)
|
|
52
|
+
framework.on('scheduler:reminder', async (data) => {
|
|
53
|
+
console.log('[WeChat] Received scheduler reminder:', data)
|
|
54
|
+
await this._handleScheduledReminder(data)
|
|
55
|
+
})
|
|
56
|
+
|
|
51
57
|
// 异步初始化 Bot
|
|
52
58
|
this._initBotAsync().catch(err => {
|
|
53
59
|
console.error('[WeChat] Failed to initialize bot:', err.message)
|
|
@@ -96,14 +102,6 @@ module.exports = function(Plugin) {
|
|
|
96
102
|
await this._handleMessage(msg)
|
|
97
103
|
})
|
|
98
104
|
|
|
99
|
-
// 监听定时提醒事件
|
|
100
|
-
if (this._framework) {
|
|
101
|
-
this._framework.on('scheduler:reminder', async (data) => {
|
|
102
|
-
console.log('[WeChat] Received scheduler reminder:', data)
|
|
103
|
-
await this._handleScheduledReminder(data)
|
|
104
|
-
})
|
|
105
|
-
}
|
|
106
|
-
|
|
107
105
|
// 启动Bot
|
|
108
106
|
await this._bot.run()
|
|
109
107
|
console.log('[WeChat] 开始接收微信消息')
|
|
@@ -113,6 +111,12 @@ module.exports = function(Plugin) {
|
|
|
113
111
|
* 处理定时提醒
|
|
114
112
|
*/
|
|
115
113
|
async _handleScheduledReminder(data) {
|
|
114
|
+
// 检查 bot 是否可用
|
|
115
|
+
if (!this._bot) {
|
|
116
|
+
console.log('[WeChat] Bot not connected, cannot send reminder')
|
|
117
|
+
return
|
|
118
|
+
}
|
|
119
|
+
|
|
116
120
|
const { taskName, message, sessionId } = data
|
|
117
121
|
|
|
118
122
|
// 构建提醒消息
|