@pacoyang/wechaty-puppet-wechat 0.28.6 → 0.28.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/dist/examples/demo.js.map +1 -1
- package/dist/scripts/retry-unit-tests.js +2 -2
- package/dist/scripts/retry-unit-tests.js.map +1 -1
- package/dist/src/bridge.d.ts +41 -3
- package/dist/src/bridge.d.ts.map +1 -1
- package/dist/src/bridge.js +147 -8
- package/dist/src/bridge.js.map +1 -1
- package/dist/src/bridge.spec.js +8 -8
- package/dist/src/bridge.spec.js.map +1 -1
- package/dist/src/event.d.ts.map +1 -1
- package/dist/src/event.js +10 -2
- package/dist/src/event.js.map +1 -1
- package/dist/src/event.spec.js +1 -1
- package/dist/src/event.spec.js.map +1 -1
- package/dist/src/firer.d.ts.map +1 -1
- package/dist/src/firer.js +12 -3
- package/dist/src/firer.js.map +1 -1
- package/dist/src/firer.spec.js +4 -4
- package/dist/src/firer.spec.js.map +1 -1
- package/dist/src/mod.js +1 -1
- package/dist/src/puppet-wechat.d.ts +79 -3
- package/dist/src/puppet-wechat.d.ts.map +1 -1
- package/dist/src/puppet-wechat.js +343 -53
- package/dist/src/puppet-wechat.js.map +1 -1
- package/dist/src/puppet-wechat.spec.js +2 -2
- package/dist/src/puppet-wechat.spec.js.map +1 -1
- package/dist/src/pure-function-helpers/message-extname.js.map +1 -1
- package/dist/src/pure-function-helpers/message-filename.js +1 -1
- package/dist/src/pure-function-helpers/message-filename.js.map +1 -1
- package/dist/src/pure-function-helpers/message-raw-payload-parser.js +5 -5
- package/dist/src/pure-function-helpers/message-raw-payload-parser.js.map +1 -1
- package/dist/src/pure-function-helpers/mod.js +6 -2
- package/dist/src/pure-function-helpers/mod.js.map +1 -1
- package/dist/src/pure-function-helpers/normalize-scan-status.js.map +1 -1
- package/dist/src/pure-function-helpers/normalize-scan-status.spec.js +2 -2
- package/dist/src/pure-function-helpers/normalize-scan-status.spec.js.map +1 -1
- package/dist/src/pure-function-helpers/web-message-type.js.map +1 -1
- package/dist/src/pure-function-helpers/xml.js.map +1 -1
- package/dist/src/session-monitor.d.ts +74 -0
- package/dist/src/session-monitor.d.ts.map +1 -0
- package/dist/src/session-monitor.js +122 -0
- package/dist/src/session-monitor.js.map +1 -0
- package/dist/src/version.spec.js +1 -1
- package/dist/src/version.spec.js.map +1 -1
- package/dist/src/web-schemas.js +2 -2
- package/dist/src/web-schemas.js.map +1 -1
- package/dist/src/wechaty-bro.js +58 -3
- package/dist/tests/puppeteer-contact.spec.js +1 -1
- package/dist/tests/puppeteer-contact.spec.js.map +1 -1
- package/dist/tests/puppeteer-friendship.spec.js +4 -4
- package/dist/tests/puppeteer-friendship.spec.js.map +1 -1
- package/dist/tests/puppeteer-message.spec.js +2 -2
- package/dist/tests/puppeteer-message.spec.js.map +1 -1
- package/dist/tests/puppeteer-room.spec.js +1 -1
- package/dist/tests/puppeteer-room.spec.js.map +1 -1
- package/dist/tests/puppeteer.spec.js +12 -12
- package/dist/tests/puppeteer.spec.js.map +1 -1
- package/package.json +1 -1
- package/src/bridge.ts +173 -4
- package/src/event.ts +9 -1
- package/src/firer.ts +12 -3
- package/src/puppet-wechat.ts +344 -12
- package/src/session-monitor.ts +165 -0
- package/src/wechaty-bro.js +58 -3
package/src/wechaty-bro.js
CHANGED
|
@@ -268,6 +268,57 @@
|
|
|
268
268
|
setTimeout(() => checkScan(), 1000)
|
|
269
269
|
}
|
|
270
270
|
|
|
271
|
+
/**
|
|
272
|
+
* chatFactory.sendMessage() posts in the background and later sets the
|
|
273
|
+
* message's MMStatus to success or failure. Wait for that, so a message
|
|
274
|
+
* WeChat refused is reported as failed instead of sent.
|
|
275
|
+
*/
|
|
276
|
+
// the web app retries a send 3 times, 15s each, before it marks it failed
|
|
277
|
+
const SEND_CONFIRM_TIMEOUT = 75 * 1000
|
|
278
|
+
|
|
279
|
+
function sentResult (m) {
|
|
280
|
+
const confFactory = WechatyBro.glue.confFactory
|
|
281
|
+
const started = Date.now()
|
|
282
|
+
return new Promise(function (resolve) {
|
|
283
|
+
(function check () {
|
|
284
|
+
if (m.MMStatus === confFactory.MSG_SEND_STATUS_SUCC) {
|
|
285
|
+
return resolve(true)
|
|
286
|
+
}
|
|
287
|
+
if (m.MMStatus === confFactory.MSG_SEND_STATUS_FAIL) {
|
|
288
|
+
return resolve('WeChat refused the message')
|
|
289
|
+
}
|
|
290
|
+
if (Date.now() - started > SEND_CONFIRM_TIMEOUT) {
|
|
291
|
+
return resolve('no answer from WeChat in ' + (SEND_CONFIRM_TIMEOUT / 1000) + 's')
|
|
292
|
+
}
|
|
293
|
+
setTimeout(check, 200)
|
|
294
|
+
})()
|
|
295
|
+
})
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
function health () {
|
|
299
|
+
const loginScope = WechatyBro.glue.loginScope
|
|
300
|
+
let roomCount = null
|
|
301
|
+
try {
|
|
302
|
+
roomCount = WechatyBro.glue.contactFactory.getAllChatroomContact().length
|
|
303
|
+
} catch (e) {}
|
|
304
|
+
return {
|
|
305
|
+
loginState : loginState(),
|
|
306
|
+
loginCode : loginScope ? loginScope.code : null,
|
|
307
|
+
now : Date.now(),
|
|
308
|
+
roomCount,
|
|
309
|
+
userName : getUserName(),
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
function roomTopicList () {
|
|
314
|
+
return WechatyBro.glue.contactFactory.getAllChatroomContact()
|
|
315
|
+
.map(r => ({
|
|
316
|
+
id : r.UserName,
|
|
317
|
+
memberCount : (r.MemberList || []).length,
|
|
318
|
+
topic : r.NickName || '',
|
|
319
|
+
}))
|
|
320
|
+
}
|
|
321
|
+
|
|
271
322
|
function ding (data) {
|
|
272
323
|
log('recv ding')
|
|
273
324
|
return data || 'dong'
|
|
@@ -431,11 +482,11 @@
|
|
|
431
482
|
|
|
432
483
|
chatFactory.appendMessage(m)
|
|
433
484
|
chatFactory.sendMessage(m)
|
|
485
|
+
return sentResult(m)
|
|
434
486
|
} catch (e) {
|
|
435
487
|
log('sendMedia() exception: ' + e.message)
|
|
436
488
|
return false
|
|
437
489
|
}
|
|
438
|
-
return true
|
|
439
490
|
}
|
|
440
491
|
|
|
441
492
|
function forward (baseData, patchData) {
|
|
@@ -455,11 +506,11 @@
|
|
|
455
506
|
|
|
456
507
|
chatFactory.appendMessage(m)
|
|
457
508
|
chatFactory.sendMessage(m)
|
|
509
|
+
return sentResult(m)
|
|
458
510
|
} catch (e) {
|
|
459
511
|
log('forward() exception: ' + e.message)
|
|
460
512
|
return false
|
|
461
513
|
}
|
|
462
|
-
return true
|
|
463
514
|
}
|
|
464
515
|
|
|
465
516
|
function send (ToUserName, Content) {
|
|
@@ -478,11 +529,11 @@
|
|
|
478
529
|
})
|
|
479
530
|
chatFactory.appendMessage(m)
|
|
480
531
|
chatFactory.sendMessage(m)
|
|
532
|
+
return sentResult(m)
|
|
481
533
|
} catch (e) {
|
|
482
534
|
log('send() exception: ' + e.message)
|
|
483
535
|
return false
|
|
484
536
|
}
|
|
485
|
-
return true
|
|
486
537
|
}
|
|
487
538
|
|
|
488
539
|
function getMessage (id) {
|
|
@@ -811,6 +862,7 @@
|
|
|
811
862
|
|
|
812
863
|
scanCode : null,
|
|
813
864
|
heartBeatTimmer : null,
|
|
865
|
+
|
|
814
866
|
},
|
|
815
867
|
|
|
816
868
|
// funcs
|
|
@@ -846,6 +898,9 @@
|
|
|
846
898
|
roomList,
|
|
847
899
|
roomDelMember,
|
|
848
900
|
roomModTopic,
|
|
901
|
+
roomTopicList,
|
|
902
|
+
|
|
903
|
+
health,
|
|
849
904
|
|
|
850
905
|
// for Friend Request
|
|
851
906
|
verifyUserRequest,
|