@juzi/wechaty 1.0.15 → 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/dist/cjs/src/mods/impls.d.ts +3 -3
- package/dist/cjs/src/mods/impls.d.ts.map +1 -1
- package/dist/cjs/src/mods/impls.js +2 -1
- package/dist/cjs/src/mods/impls.js.map +1 -1
- package/dist/cjs/src/mods/users.d.ts +1 -1
- package/dist/cjs/src/mods/users.d.ts.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/user-modules/contact.d.ts +8 -0
- package/dist/cjs/src/user-modules/contact.d.ts.map +1 -1
- package/dist/cjs/src/user-modules/contact.js +19 -5
- package/dist/cjs/src/user-modules/contact.js.map +1 -1
- package/dist/cjs/src/user-modules/mod.d.ts +4 -3
- package/dist/cjs/src/user-modules/mod.d.ts.map +1 -1
- package/dist/cjs/src/user-modules/mod.js +3 -1
- package/dist/cjs/src/user-modules/mod.js.map +1 -1
- package/dist/cjs/src/user-modules/post.js +1 -1
- package/dist/cjs/src/user-modules/room.d.ts +0 -4
- package/dist/cjs/src/user-modules/room.d.ts.map +1 -1
- package/dist/cjs/src/user-modules/room.js +3 -15
- package/dist/cjs/src/user-modules/room.js.map +1 -1
- package/dist/cjs/src/user-modules/tag-group.d.ts +60 -0
- package/dist/cjs/src/user-modules/tag-group.d.ts.map +1 -0
- package/dist/cjs/src/user-modules/tag-group.js +71 -0
- package/dist/cjs/src/user-modules/tag-group.js.map +1 -0
- package/dist/cjs/src/user-modules/tag.d.ts +37 -64
- package/dist/cjs/src/user-modules/tag.d.ts.map +1 -1
- package/dist/cjs/src/user-modules/tag.js +52 -127
- package/dist/cjs/src/user-modules/tag.js.map +1 -1
- package/dist/cjs/src/wechaty/wechaty-base.d.ts +15 -5
- package/dist/cjs/src/wechaty/wechaty-base.d.ts.map +1 -1
- package/dist/cjs/src/wechaty/wechaty-impl.spec.js +5 -3
- package/dist/cjs/src/wechaty/wechaty-impl.spec.js.map +1 -1
- package/dist/cjs/src/wechaty-mixins/login-mixin.d.ts +6 -0
- package/dist/cjs/src/wechaty-mixins/login-mixin.d.ts.map +1 -1
- package/dist/cjs/src/wechaty-mixins/misc-mixin.d.ts +9 -9
- package/dist/cjs/src/wechaty-mixins/misc-mixin.d.ts.map +1 -1
- package/dist/cjs/src/wechaty-mixins/plugin-mixin.d.ts +8 -0
- package/dist/cjs/src/wechaty-mixins/plugin-mixin.d.ts.map +1 -1
- package/dist/cjs/src/wechaty-mixins/puppet-mixin.d.ts +14 -20
- package/dist/cjs/src/wechaty-mixins/puppet-mixin.d.ts.map +1 -1
- package/dist/cjs/src/wechaty-mixins/puppet-mixin.js +6 -2
- package/dist/cjs/src/wechaty-mixins/puppet-mixin.js.map +1 -1
- package/dist/cjs/src/wechaty-mixins/wechatify-user-module-mixin.d.ts +4 -2
- package/dist/cjs/src/wechaty-mixins/wechatify-user-module-mixin.d.ts.map +1 -1
- package/dist/cjs/src/wechaty-mixins/wechatify-user-module-mixin.js +3 -0
- package/dist/cjs/src/wechaty-mixins/wechatify-user-module-mixin.js.map +1 -1
- package/dist/esm/src/mods/impls.d.ts +3 -3
- package/dist/esm/src/mods/impls.d.ts.map +1 -1
- package/dist/esm/src/mods/impls.js +1 -1
- package/dist/esm/src/mods/impls.js.map +1 -1
- package/dist/esm/src/mods/users.d.ts +1 -1
- package/dist/esm/src/mods/users.d.ts.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/user-modules/contact.d.ts +8 -0
- package/dist/esm/src/user-modules/contact.d.ts.map +1 -1
- package/dist/esm/src/user-modules/contact.js +19 -5
- package/dist/esm/src/user-modules/contact.js.map +1 -1
- package/dist/esm/src/user-modules/mod.d.ts +4 -3
- package/dist/esm/src/user-modules/mod.d.ts.map +1 -1
- package/dist/esm/src/user-modules/mod.js +2 -1
- package/dist/esm/src/user-modules/mod.js.map +1 -1
- package/dist/esm/src/user-modules/post.js +1 -1
- package/dist/esm/src/user-modules/room.d.ts +0 -4
- package/dist/esm/src/user-modules/room.d.ts.map +1 -1
- package/dist/esm/src/user-modules/room.js +3 -15
- package/dist/esm/src/user-modules/room.js.map +1 -1
- package/dist/esm/src/user-modules/tag-group.d.ts +60 -0
- package/dist/esm/src/user-modules/tag-group.d.ts.map +1 -0
- package/dist/esm/src/user-modules/tag-group.js +68 -0
- package/dist/esm/src/user-modules/tag-group.js.map +1 -0
- package/dist/esm/src/user-modules/tag.d.ts +37 -64
- package/dist/esm/src/user-modules/tag.d.ts.map +1 -1
- package/dist/esm/src/user-modules/tag.js +52 -127
- package/dist/esm/src/user-modules/tag.js.map +1 -1
- package/dist/esm/src/wechaty/wechaty-base.d.ts +15 -5
- package/dist/esm/src/wechaty/wechaty-base.d.ts.map +1 -1
- package/dist/esm/src/wechaty/wechaty-impl.spec.js +5 -3
- package/dist/esm/src/wechaty/wechaty-impl.spec.js.map +1 -1
- package/dist/esm/src/wechaty-mixins/login-mixin.d.ts +6 -0
- package/dist/esm/src/wechaty-mixins/login-mixin.d.ts.map +1 -1
- package/dist/esm/src/wechaty-mixins/misc-mixin.d.ts +9 -9
- package/dist/esm/src/wechaty-mixins/misc-mixin.d.ts.map +1 -1
- package/dist/esm/src/wechaty-mixins/plugin-mixin.d.ts +8 -0
- package/dist/esm/src/wechaty-mixins/plugin-mixin.d.ts.map +1 -1
- package/dist/esm/src/wechaty-mixins/puppet-mixin.d.ts +14 -20
- package/dist/esm/src/wechaty-mixins/puppet-mixin.d.ts.map +1 -1
- package/dist/esm/src/wechaty-mixins/puppet-mixin.js +6 -2
- package/dist/esm/src/wechaty-mixins/puppet-mixin.js.map +1 -1
- package/dist/esm/src/wechaty-mixins/wechatify-user-module-mixin.d.ts +4 -2
- package/dist/esm/src/wechaty-mixins/wechatify-user-module-mixin.d.ts.map +1 -1
- package/dist/esm/src/wechaty-mixins/wechatify-user-module-mixin.js +4 -1
- package/dist/esm/src/wechaty-mixins/wechatify-user-module-mixin.js.map +1 -1
- package/package.json +3 -3
- package/src/mods/impls.ts +3 -0
- package/src/mods/users.ts +1 -0
- package/src/package-json.ts +4 -4
- package/src/user-modules/contact.ts +27 -5
- package/src/user-modules/mod.ts +8 -0
- package/src/user-modules/post.ts +1 -1
- package/src/user-modules/room.ts +3 -17
- package/src/user-modules/tag-group.ts +115 -0
- package/src/user-modules/tag.ts +61 -124
- package/src/wechaty/wechaty-impl.spec.ts +3 -0
- package/src/wechaty-mixins/puppet-mixin.ts +6 -2
- package/src/wechaty-mixins/wechatify-user-module-mixin.ts +6 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wechaty Chatbot SDK - https://github.com/wechaty/wechaty
|
|
3
|
+
*
|
|
4
|
+
* @copyright 2016 Huan LI (李卓桓) <https://github.com/huan>, and
|
|
5
|
+
* Wechaty Contributors <https://github.com/wechaty>.
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agGroupreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific languagGroupe governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
import type * as PUPPET from '@juzi/wechaty-puppet'
|
|
21
|
+
|
|
22
|
+
import type { Constructor } from 'clone-class'
|
|
23
|
+
import { log } from '../config.js'
|
|
24
|
+
|
|
25
|
+
import { validationMixin } from '../user-mixins/validation.js'
|
|
26
|
+
import {
|
|
27
|
+
wechatifyMixinBase,
|
|
28
|
+
} from '../user-mixins/wechatify.js'
|
|
29
|
+
|
|
30
|
+
class TagGroupMixin extends wechatifyMixinBase() {
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
*
|
|
34
|
+
* Create
|
|
35
|
+
*
|
|
36
|
+
*/
|
|
37
|
+
static create (payload: PUPPET.payloads.TagGroup): TagGroupInterface {
|
|
38
|
+
log.verbose('TagGroup', 'create()')
|
|
39
|
+
|
|
40
|
+
return new this(payload)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @hideconstructor
|
|
45
|
+
*/
|
|
46
|
+
constructor (
|
|
47
|
+
public readonly payload: PUPPET.payloads.TagGroup,
|
|
48
|
+
) {
|
|
49
|
+
super()
|
|
50
|
+
log.silly('TagGroup', 'constructor()')
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
id (): string {
|
|
54
|
+
return this.payload.id
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
name (): string {
|
|
58
|
+
return this.payload.name
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
static async createTagGroup (name: string): Promise<TagGroupInterface | void> {
|
|
62
|
+
log.verbose('TagGroup', 'createTagGroup(%s, %s)', name)
|
|
63
|
+
|
|
64
|
+
try {
|
|
65
|
+
const payload = await this.wechaty.puppet.tagGroupAdd(name)
|
|
66
|
+
if (payload) {
|
|
67
|
+
return new this(payload)
|
|
68
|
+
}
|
|
69
|
+
} catch (e) {
|
|
70
|
+
this.wechaty.emitError(e)
|
|
71
|
+
log.error('Contact', 'createTag() exception: %s', (e as Error).message)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
static async deleteTagGroup (tagGroup: TagGroupInterface): Promise<TagGroupInterface | void> {
|
|
76
|
+
log.verbose('TagGroup', 'deleteTagGroup(%s)', tagGroup)
|
|
77
|
+
|
|
78
|
+
try {
|
|
79
|
+
await this.wechaty.puppet.tagGroupDelete(tagGroup.id())
|
|
80
|
+
} catch (e) {
|
|
81
|
+
this.wechaty.emitError(e)
|
|
82
|
+
log.error('Contact', 'createTag() exception: %s', (e as Error).message)
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
static async list (): Promise<TagGroupInterface[]> {
|
|
87
|
+
log.verbose('TagGroup', 'list()')
|
|
88
|
+
|
|
89
|
+
try {
|
|
90
|
+
const payloads = await this.wechaty.puppet.tagGroupList()
|
|
91
|
+
return payloads.map(payload => new this(payload))
|
|
92
|
+
} catch (e) {
|
|
93
|
+
this.wechaty.emitError(e)
|
|
94
|
+
log.error('TagGroup', 'list() exception: %s', (e as Error).message)
|
|
95
|
+
return []
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
class TagGroupImpl extends validationMixin(TagGroupMixin)<TagGroupInterface>() { }
|
|
102
|
+
interface TagGroupInterface extends TagGroupImpl { }
|
|
103
|
+
|
|
104
|
+
type TagGroupConstructor = Constructor<
|
|
105
|
+
TagGroupInterface,
|
|
106
|
+
typeof TagGroupImpl
|
|
107
|
+
>
|
|
108
|
+
|
|
109
|
+
export type {
|
|
110
|
+
TagGroupConstructor,
|
|
111
|
+
TagGroupInterface,
|
|
112
|
+
}
|
|
113
|
+
export {
|
|
114
|
+
TagGroupImpl,
|
|
115
|
+
}
|
package/src/user-modules/tag.ts
CHANGED
|
@@ -17,169 +17,106 @@
|
|
|
17
17
|
* limitations under the License.
|
|
18
18
|
*
|
|
19
19
|
*/
|
|
20
|
-
import
|
|
21
|
-
log,
|
|
22
|
-
} from '@juzi/wechaty-puppet'
|
|
23
|
-
|
|
24
|
-
import type { Constructor } from 'clone-class'
|
|
20
|
+
import type * as PUPPET from '@juzi/wechaty-puppet'
|
|
25
21
|
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
22
|
+
import type { Constructor } from 'clone-class'
|
|
23
|
+
import { log } from '../config.js'
|
|
28
24
|
|
|
29
|
-
import {
|
|
30
|
-
poolifyMixin,
|
|
31
|
-
} from '../user-mixins/poolify.js'
|
|
32
25
|
import { validationMixin } from '../user-mixins/validation.js'
|
|
33
26
|
import {
|
|
34
27
|
wechatifyMixinBase,
|
|
35
28
|
} from '../user-mixins/wechatify.js'
|
|
29
|
+
import type { ContactInterface } from './contact.js'
|
|
36
30
|
|
|
37
|
-
|
|
38
|
-
wechatifyMixinBase(),
|
|
39
|
-
)<TagInterface>()
|
|
31
|
+
class TagMixin extends wechatifyMixinBase() {
|
|
40
32
|
|
|
41
|
-
|
|
33
|
+
/**
|
|
34
|
+
*
|
|
35
|
+
* Create
|
|
36
|
+
*
|
|
37
|
+
*/
|
|
38
|
+
static create (payload: PUPPET.payloads.Tag): TagInterface {
|
|
39
|
+
log.verbose('Tag', 'create()')
|
|
40
|
+
|
|
41
|
+
return new this(payload)
|
|
42
|
+
}
|
|
42
43
|
|
|
43
44
|
/**
|
|
44
45
|
* @hideconstructor
|
|
45
46
|
*/
|
|
46
47
|
constructor (
|
|
47
|
-
public readonly
|
|
48
|
+
public readonly payload: PUPPET.payloads.Tag,
|
|
48
49
|
) {
|
|
49
50
|
super()
|
|
50
|
-
log.silly('Tag',
|
|
51
|
+
log.silly('Tag', 'constructor()')
|
|
51
52
|
}
|
|
52
53
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
*
|
|
56
|
-
* > Tips:
|
|
57
|
-
* This function is depending on the Puppet Implementation, see [puppet-compatible-table](https://github.com/Chatie/wechaty/wiki/Puppet#3-puppet-compatible-table)
|
|
58
|
-
*
|
|
59
|
-
* @static
|
|
60
|
-
* @param {string} [tag] the tag name which want to create
|
|
61
|
-
* @returns {Promise<TagImpl>}
|
|
62
|
-
* @example
|
|
63
|
-
* const bot = new Wechaty()
|
|
64
|
-
* await bot.Tag.get('TagName')
|
|
65
|
-
*/
|
|
66
|
-
static async get (
|
|
67
|
-
tag: string,
|
|
68
|
-
): Promise<TagInterface> {
|
|
69
|
-
log.verbose('Tag', 'get(%s)', tag)
|
|
70
|
-
return this.load(tag)
|
|
54
|
+
id (): string {
|
|
55
|
+
return this.payload.id
|
|
71
56
|
}
|
|
72
57
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
* If you want to delete a tag, please make sure there's no more Contact/Favorite(s) are using this tag.
|
|
77
|
-
* If this tag is be used by any Contact/Favorite, then it can not be deleted.
|
|
78
|
-
* (This is for protecting the tag being deleted by mistake)
|
|
79
|
-
*
|
|
80
|
-
* @static
|
|
81
|
-
* @returns {Promise<TagInterface[]>}
|
|
82
|
-
* @example
|
|
83
|
-
* const tag = wechaty.Tag.get('tag')
|
|
84
|
-
* await wechaty.Tag.delete(tag)
|
|
85
|
-
*/
|
|
58
|
+
type (): PUPPET.types.Tag {
|
|
59
|
+
return this.payload.type
|
|
60
|
+
}
|
|
86
61
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
static async delete (
|
|
91
|
-
tag: TagInterface,
|
|
92
|
-
target?: typeof ContactImpl | typeof FavoriteImpl,
|
|
93
|
-
): Promise<void> {
|
|
94
|
-
log.verbose('Tag', 'static delete(%s)', tag)
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Huan(202110) TODO: refactory this design:
|
|
98
|
-
* 1. we should not pass `typeof ContactImpl` as argument
|
|
99
|
-
* 2. find a better way to manage tag.
|
|
100
|
-
*/
|
|
62
|
+
groupId (): string {
|
|
63
|
+
return this.payload.groupId || ''
|
|
64
|
+
}
|
|
101
65
|
|
|
102
|
-
|
|
66
|
+
name (): string {
|
|
67
|
+
return this.payload.name
|
|
68
|
+
}
|
|
103
69
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
*/
|
|
70
|
+
static async list (): Promise<TagInterface[]> {
|
|
71
|
+
log.verbose('Tag', 'list()')
|
|
107
72
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
// } else if (!target || target === Favorite || target === this.wechaty.Favorite) {
|
|
112
|
-
// await this.wechaty.puppet.tagFavoriteDelete(tag.id)
|
|
113
|
-
}
|
|
73
|
+
try {
|
|
74
|
+
const payloads = await this.wechaty.puppet.tagTagList()
|
|
75
|
+
return payloads.map(payload => new this(payload))
|
|
114
76
|
} catch (e) {
|
|
115
77
|
this.wechaty.emitError(e)
|
|
116
|
-
log.error('Tag', '
|
|
78
|
+
log.error('Tag', 'list() exception: %s', (e as Error).message)
|
|
79
|
+
return []
|
|
117
80
|
}
|
|
118
81
|
}
|
|
119
82
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
* 1. we should not pass `typeof ContactImpl` as argument
|
|
139
|
-
* 2. use instanceof to check the type of `to`
|
|
140
|
-
*/
|
|
83
|
+
async contactList (): Promise<ContactInterface[]> {
|
|
84
|
+
log.verbose('Tag', 'contactList() for tag id: %s', this.id())
|
|
85
|
+
|
|
86
|
+
const contactIds = await this.wechaty.puppet.tagTagContactList(this.groupId(), this.id())
|
|
87
|
+
const contactPromises = contactIds.map(id => this.wechaty.Contact.find({ id })) as Promise<ContactInterface>[]
|
|
88
|
+
return Promise.all(contactPromises)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
async tag (contact: ContactInterface): Promise<void> {
|
|
92
|
+
log.verbose('Tag', 'tag(%s) for tag id: %s', contact, this.id())
|
|
93
|
+
|
|
94
|
+
const contactId = contact.id
|
|
95
|
+
await this.wechaty.puppet.tagContactTagAdd(this.groupId(), this.id(), contactId)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
static async createTag (tagGroupId: string | undefined, name: string): Promise<TagInterface | void> {
|
|
99
|
+
log.verbose('Tag', 'createTag(%s, %s)', tagGroupId, name)
|
|
100
|
+
|
|
141
101
|
try {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
// TODO: await this.wechaty.puppet.tagAddFavorite(this.tag, to.id)
|
|
102
|
+
const payload = await this.wechaty.puppet.tagTagAdd(tagGroupId, name)
|
|
103
|
+
if (payload) {
|
|
104
|
+
return new this(payload)
|
|
146
105
|
}
|
|
147
106
|
} catch (e) {
|
|
148
107
|
this.wechaty.emitError(e)
|
|
149
|
-
log.error('
|
|
150
|
-
throw new Error(`add error : ${(e as Error)}`)
|
|
108
|
+
log.error('Contact', 'createTag() exception: %s', (e as Error).message)
|
|
151
109
|
}
|
|
152
110
|
}
|
|
153
111
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
*
|
|
157
|
-
* > Tips:
|
|
158
|
-
* This function is depending on the Puppet Implementation, see [puppet-compatible-table](https://github.com/Chatie/wechaty/wiki/Puppet#3-puppet-compatible-table)
|
|
159
|
-
*
|
|
160
|
-
* @returns {Promise<void>}
|
|
161
|
-
* @example
|
|
162
|
-
* await tag.remove(contact)
|
|
163
|
-
*/
|
|
164
|
-
async remove (from: ContactInterface | FavoriteInterface): Promise<void> {
|
|
165
|
-
log.verbose('Tag', 'remove(%s) for %s', from, this.id)
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* Huan(202110): TODO: refactory this design:
|
|
169
|
-
* 1. we should not pass `typeof ContactImpl` as argument
|
|
170
|
-
* 2. use instanceof to check the type of `to`
|
|
171
|
-
*/
|
|
112
|
+
static async deleteTag (tag: TagInterface): Promise<void> {
|
|
113
|
+
log.verbose('Tag', 'deleteTag(%s, %s)', tag)
|
|
172
114
|
|
|
173
115
|
try {
|
|
174
|
-
|
|
175
|
-
await this.wechaty.puppet.tagContactRemove(this.id, from.id)
|
|
176
|
-
} else if (from instanceof FavoriteImpl) {
|
|
177
|
-
// TODO await this.wechaty.puppet.tagRemoveFavorite(this.tag, from.id)
|
|
178
|
-
}
|
|
116
|
+
await this.wechaty.puppet.tagTagDelete(tag.groupId(), tag.id())
|
|
179
117
|
} catch (e) {
|
|
180
118
|
this.wechaty.emitError(e)
|
|
181
|
-
log.error('
|
|
182
|
-
throw new Error(`remove error : ${e}`)
|
|
119
|
+
log.error('Contact', 'deleteTag() exception: %s', (e as Error).message)
|
|
183
120
|
}
|
|
184
121
|
}
|
|
185
122
|
|
|
@@ -17,6 +17,7 @@ import type {
|
|
|
17
17
|
RoomConstructor,
|
|
18
18
|
DelayConstructor,
|
|
19
19
|
TagConstructor,
|
|
20
|
+
TagGroupConstructor,
|
|
20
21
|
UrlLinkConstructor,
|
|
21
22
|
MessageInterface,
|
|
22
23
|
ChannelConstructor,
|
|
@@ -45,6 +46,7 @@ test('Wechaty interface', async t => {
|
|
|
45
46
|
Room : RoomConstructor
|
|
46
47
|
RoomInvitation : RoomInvitationConstructor
|
|
47
48
|
Tag : TagConstructor
|
|
49
|
+
TagGroup : TagGroupConstructor
|
|
48
50
|
UrlLink : UrlLinkConstructor
|
|
49
51
|
Channel : ChannelConstructor
|
|
50
52
|
|
|
@@ -63,6 +65,7 @@ test('Wechaty interface', async t => {
|
|
|
63
65
|
= this.Room
|
|
64
66
|
= this.RoomInvitation
|
|
65
67
|
= this.Tag
|
|
68
|
+
= this.TagGroup
|
|
66
69
|
= this.UrlLink
|
|
67
70
|
= this.Channel
|
|
68
71
|
= {} as any
|
|
@@ -387,7 +387,7 @@ const puppetMixin = <MixinBase extends WechatifyUserModuleMixin & GErrorMixin &
|
|
|
387
387
|
// issue #254
|
|
388
388
|
if (payload.removeeIdList.includes(puppet.currentUserId)) {
|
|
389
389
|
await puppet.roomPayloadDirty(payload.roomId)
|
|
390
|
-
|
|
390
|
+
await puppet.roomMemberPayloadDirty(payload.roomId)
|
|
391
391
|
}
|
|
392
392
|
} catch (e) {
|
|
393
393
|
this.emit('error', GError.from(e))
|
|
@@ -436,7 +436,6 @@ const puppetMixin = <MixinBase extends WechatifyUserModuleMixin & GErrorMixin &
|
|
|
436
436
|
puppet.on('dirty', async ({ payloadType, payloadId }) => {
|
|
437
437
|
try {
|
|
438
438
|
switch (payloadType) {
|
|
439
|
-
case PUPPET.types.Payload.RoomMember:
|
|
440
439
|
case PUPPET.types.Payload.Contact: {
|
|
441
440
|
const contact = await this.Contact.find({ id: payloadId }) as unknown as undefined | ContactImpl
|
|
442
441
|
await contact?.ready(true)
|
|
@@ -447,6 +446,11 @@ const puppetMixin = <MixinBase extends WechatifyUserModuleMixin & GErrorMixin &
|
|
|
447
446
|
await room?.ready(true)
|
|
448
447
|
break
|
|
449
448
|
}
|
|
449
|
+
case PUPPET.types.Payload.RoomMember: {
|
|
450
|
+
const room = await this.Room.find({ id: payloadId }) as unknown as undefined | RoomImpl
|
|
451
|
+
await room?.ready()
|
|
452
|
+
break
|
|
453
|
+
}
|
|
450
454
|
|
|
451
455
|
/**
|
|
452
456
|
* Huan(202008): noop for the following
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
RoomImpl,
|
|
14
14
|
RoomInvitationImpl,
|
|
15
15
|
TagImpl,
|
|
16
|
+
TagGroupImpl,
|
|
16
17
|
UrlLinkImpl,
|
|
17
18
|
ChannelImpl,
|
|
18
19
|
|
|
@@ -28,6 +29,7 @@ import {
|
|
|
28
29
|
RoomConstructor,
|
|
29
30
|
RoomInvitationConstructor,
|
|
30
31
|
TagConstructor,
|
|
32
|
+
TagGroupConstructor,
|
|
31
33
|
UrlLinkConstructor,
|
|
32
34
|
ChannelConstructor,
|
|
33
35
|
|
|
@@ -60,6 +62,7 @@ const wechatifyUserModuleMixin = <MixinBase extends typeof WechatySkeleton> (mix
|
|
|
60
62
|
__wechatifiedRoom? : RoomConstructor
|
|
61
63
|
__wechatifiedRoomInvitation? : RoomInvitationConstructor
|
|
62
64
|
__wechatifiedTag? : TagConstructor
|
|
65
|
+
__wechatifiedTagGroup? : TagGroupConstructor
|
|
63
66
|
__wechatifiedUrlLink? : UrlLinkConstructor
|
|
64
67
|
__wechatifiedChannel? : ChannelConstructor
|
|
65
68
|
|
|
@@ -75,6 +78,7 @@ const wechatifyUserModuleMixin = <MixinBase extends typeof WechatySkeleton> (mix
|
|
|
75
78
|
get Room () : RoomConstructor { return guardWechatify(this.__wechatifiedRoom) }
|
|
76
79
|
get RoomInvitation () : RoomInvitationConstructor { return guardWechatify(this.__wechatifiedRoomInvitation) }
|
|
77
80
|
get Tag () : TagConstructor { return guardWechatify(this.__wechatifiedTag) }
|
|
81
|
+
get TagGroup () : TagGroupConstructor { return guardWechatify(this.__wechatifiedTagGroup) }
|
|
78
82
|
get UrlLink () : UrlLinkConstructor { return guardWechatify(this.__wechatifiedUrlLink) }
|
|
79
83
|
get Channel () : ChannelConstructor { return guardWechatify(this.__wechatifiedChannel) }
|
|
80
84
|
|
|
@@ -110,6 +114,7 @@ const wechatifyUserModuleMixin = <MixinBase extends typeof WechatySkeleton> (mix
|
|
|
110
114
|
this.__wechatifiedRoom = wechatifyUserModule(RoomImpl)(this as any)
|
|
111
115
|
this.__wechatifiedRoomInvitation = wechatifyUserModule(RoomInvitationImpl)(this as any)
|
|
112
116
|
this.__wechatifiedTag = wechatifyUserModule(TagImpl)(this as any)
|
|
117
|
+
this.__wechatifiedTagGroup = wechatifyUserModule(TagGroupImpl)(this as any)
|
|
113
118
|
this.__wechatifiedUrlLink = wechatifyUserModule(UrlLinkImpl)(this as any)
|
|
114
119
|
this.__wechatifiedChannel = wechatifyUserModule(ChannelImpl)(this as any)
|
|
115
120
|
|
|
@@ -145,6 +150,7 @@ type ProtectedPropertyWechatifyUserModuleMixin =
|
|
|
145
150
|
| '__wechatifiedRoom'
|
|
146
151
|
| '__wechatifiedRoomInvitation'
|
|
147
152
|
| '__wechatifiedTag'
|
|
153
|
+
| '__wechatifiedTagGroup'
|
|
148
154
|
| '__wechatifiedUrlLink'
|
|
149
155
|
| '__wechatifiedChannel'
|
|
150
156
|
|