@juzi/wechaty 1.0.2 → 1.0.5
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/cjs/src/io-peer/io-peer.d.ts.map +1 -1
- package/dist/cjs/src/io-peer/io-peer.js +3 -6
- package/dist/cjs/src/io-peer/io-peer.js.map +1 -1
- package/dist/cjs/src/io-peer/io-peer.spec.js +4 -7
- package/dist/cjs/src/io-peer/io-peer.spec.js.map +1 -1
- package/dist/cjs/src/package-json.js +4 -4
- package/dist/cjs/src/package-json.js.map +1 -1
- package/dist/cjs/src/sayable/deliver-sayable.d.ts +2 -2
- package/dist/cjs/src/sayable/deliver-sayable.d.ts.map +1 -1
- package/dist/cjs/src/sayable/deliver-sayable.js +5 -2
- package/dist/cjs/src/sayable/deliver-sayable.js.map +1 -1
- package/dist/cjs/src/sayable/mod.d.ts +2 -2
- package/dist/cjs/src/sayable/mod.d.ts.map +1 -1
- package/dist/cjs/src/sayable/mod.js.map +1 -1
- package/dist/cjs/src/sayable/types.d.ts +9 -3
- package/dist/cjs/src/sayable/types.d.ts.map +1 -1
- package/dist/cjs/src/sayable/types.js +8 -0
- package/dist/cjs/src/sayable/types.js.map +1 -1
- package/dist/cjs/src/user-modules/contact.d.ts +2 -2
- package/dist/cjs/src/user-modules/contact.d.ts.map +1 -1
- package/dist/cjs/src/user-modules/contact.js +6 -2
- package/dist/cjs/src/user-modules/contact.js.map +1 -1
- package/dist/cjs/src/user-modules/message.d.ts +8 -1
- package/dist/cjs/src/user-modules/message.d.ts.map +1 -1
- package/dist/cjs/src/user-modules/message.js +32 -2
- package/dist/cjs/src/user-modules/message.js.map +1 -1
- package/dist/cjs/src/user-modules/room.d.ts +3 -1
- package/dist/cjs/src/user-modules/room.d.ts.map +1 -1
- package/dist/cjs/src/user-modules/room.js +21 -3
- package/dist/cjs/src/user-modules/room.js.map +1 -1
- package/dist/esm/src/io-peer/io-peer.d.ts.map +1 -1
- package/dist/esm/src/io-peer/io-peer.js +3 -3
- package/dist/esm/src/io-peer/io-peer.js.map +1 -1
- package/dist/esm/src/io-peer/io-peer.spec.js +4 -4
- package/dist/esm/src/io-peer/io-peer.spec.js.map +1 -1
- package/dist/esm/src/package-json.js +4 -4
- package/dist/esm/src/package-json.js.map +1 -1
- package/dist/esm/src/sayable/deliver-sayable.d.ts +2 -2
- package/dist/esm/src/sayable/deliver-sayable.d.ts.map +1 -1
- package/dist/esm/src/sayable/deliver-sayable.js +5 -2
- package/dist/esm/src/sayable/deliver-sayable.js.map +1 -1
- package/dist/esm/src/sayable/mod.d.ts +2 -2
- package/dist/esm/src/sayable/mod.d.ts.map +1 -1
- package/dist/esm/src/sayable/mod.js.map +1 -1
- package/dist/esm/src/sayable/types.d.ts +9 -3
- package/dist/esm/src/sayable/types.d.ts.map +1 -1
- package/dist/esm/src/sayable/types.js +6 -1
- package/dist/esm/src/sayable/types.js.map +1 -1
- package/dist/esm/src/user-modules/contact.d.ts +2 -2
- package/dist/esm/src/user-modules/contact.d.ts.map +1 -1
- package/dist/esm/src/user-modules/contact.js +6 -2
- package/dist/esm/src/user-modules/contact.js.map +1 -1
- package/dist/esm/src/user-modules/message.d.ts +8 -1
- package/dist/esm/src/user-modules/message.d.ts.map +1 -1
- package/dist/esm/src/user-modules/message.js +32 -2
- package/dist/esm/src/user-modules/message.js.map +1 -1
- package/dist/esm/src/user-modules/room.d.ts +3 -1
- package/dist/esm/src/user-modules/room.d.ts.map +1 -1
- package/dist/esm/src/user-modules/room.js +21 -3
- package/dist/esm/src/user-modules/room.js.map +1 -1
- package/package.json +3 -3
- package/src/io-peer/io-peer.spec.ts +4 -4
- package/src/io-peer/io-peer.ts +3 -3
- package/src/package-json.ts +4 -4
- package/src/sayable/deliver-sayable.ts +6 -2
- package/src/sayable/mod.ts +4 -0
- package/src/sayable/types.ts +21 -2
- package/src/user-modules/contact.ts +8 -1
- package/src/user-modules/message.ts +41 -3
- package/src/user-modules/room.ts +32 -10
package/src/user-modules/room.ts
CHANGED
|
@@ -46,7 +46,7 @@ import {
|
|
|
46
46
|
validationMixin,
|
|
47
47
|
} from '../user-mixins/mod.js'
|
|
48
48
|
import {
|
|
49
|
-
deliverSayableConversationPuppet,
|
|
49
|
+
deliverSayableConversationPuppet, SayOptions, SayOptionsObject,
|
|
50
50
|
} from '../sayable/mod.js'
|
|
51
51
|
import type {
|
|
52
52
|
SayableSayer,
|
|
@@ -61,6 +61,7 @@ import {
|
|
|
61
61
|
import type {
|
|
62
62
|
MessageInterface,
|
|
63
63
|
} from './message.js'
|
|
64
|
+
import { isSayOptionsObject } from '../sayable/types.js'
|
|
64
65
|
|
|
65
66
|
const MixinBase = wechatifyMixin(
|
|
66
67
|
poolifyMixin(
|
|
@@ -355,7 +356,8 @@ class RoomMixin extends MixinBase implements SayableSayer {
|
|
|
355
356
|
}
|
|
356
357
|
|
|
357
358
|
say (sayable: Sayable) : Promise<void | MessageInterface>
|
|
358
|
-
say (text:
|
|
359
|
+
say (text: string, options?: SayOptions): Promise<void | MessageInterface>
|
|
360
|
+
say (text: string, ...options: SayOptions[]): Promise<void | MessageInterface>
|
|
359
361
|
say (textList: TemplateStringsArray, ...varList: any[]) : Promise<void | MessageInterface>
|
|
360
362
|
|
|
361
363
|
// Huan(202006): allow fall down to the defination to get more flexibility.
|
|
@@ -464,15 +466,23 @@ class RoomMixin extends MixinBase implements SayableSayer {
|
|
|
464
466
|
* 1. string
|
|
465
467
|
*/
|
|
466
468
|
let mentionList: ContactInterface[] = []
|
|
469
|
+
let quoteMessage: MessageInterface | undefined
|
|
470
|
+
let options: SayOptionsObject
|
|
467
471
|
|
|
468
472
|
if (varList.length > 0) {
|
|
469
|
-
|
|
473
|
+
if (isSayOptionsObject(varList[0])) {
|
|
474
|
+
options = varList[0] as SayOptionsObject
|
|
475
|
+
mentionList = options.mentionList || []
|
|
476
|
+
quoteMessage = options.quoteMessage
|
|
477
|
+
} else {
|
|
478
|
+
mentionList = varList as ContactInterface[]
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
const allIsContact = mentionList.every(c => ContactImpl.valid(c))
|
|
470
482
|
if (!allIsContact) {
|
|
471
483
|
throw new Error('mentionList must be contact when not using TemplateStringsArray function call.')
|
|
472
484
|
}
|
|
473
485
|
|
|
474
|
-
mentionList = [...varList as any]
|
|
475
|
-
|
|
476
486
|
const AT_SEPARATOR = FOUR_PER_EM_SPACE
|
|
477
487
|
const mentionAlias = await Promise.all(mentionList.map(async contact =>
|
|
478
488
|
'@' + (await this.alias(contact) || contact.name()),
|
|
@@ -487,11 +497,23 @@ class RoomMixin extends MixinBase implements SayableSayer {
|
|
|
487
497
|
// contactId : (mentionList.length && mentionList[0].id) || undefined,
|
|
488
498
|
// roomId : this.id,
|
|
489
499
|
// }
|
|
490
|
-
|
|
491
|
-
this.
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
500
|
+
if (quoteMessage) {
|
|
501
|
+
msgId = await this.wechaty.puppet.messageSendText(
|
|
502
|
+
this.id,
|
|
503
|
+
text,
|
|
504
|
+
{
|
|
505
|
+
mentionIdList: mentionList.map(c => c.id),
|
|
506
|
+
quoteId: quoteMessage.id,
|
|
507
|
+
},
|
|
508
|
+
)
|
|
509
|
+
} else {
|
|
510
|
+
msgId = await this.wechaty.puppet.messageSendText(
|
|
511
|
+
this.id,
|
|
512
|
+
text,
|
|
513
|
+
mentionList.map(c => c.id),
|
|
514
|
+
)
|
|
515
|
+
}
|
|
516
|
+
|
|
495
517
|
} else {
|
|
496
518
|
msgId = await deliverSayableConversationPuppet(this.wechaty.puppet)(this.id)(sayable)
|
|
497
519
|
}
|