@juzi/wechaty 1.0.57 → 1.0.59
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/package-json.js +2 -2
- package/dist/cjs/src/user-modules/contact.d.ts.map +1 -1
- package/dist/cjs/src/user-modules/contact.js +31 -18
- package/dist/cjs/src/user-modules/contact.js.map +1 -1
- package/dist/cjs/src/user-modules/message.d.ts.map +1 -1
- package/dist/cjs/src/user-modules/message.js +42 -4
- package/dist/cjs/src/user-modules/message.js.map +1 -1
- package/dist/cjs/src/user-modules/room.d.ts.map +1 -1
- package/dist/cjs/src/user-modules/room.js +31 -19
- package/dist/cjs/src/user-modules/room.js.map +1 -1
- package/dist/cjs/src/user-modules/room.spec.js +25 -0
- package/dist/cjs/src/user-modules/room.spec.js.map +1 -1
- package/dist/cjs/src/user-modules/tag-group.d.ts.map +1 -1
- package/dist/cjs/src/user-modules/tag-group.js +21 -1
- package/dist/cjs/src/user-modules/tag-group.js.map +1 -1
- package/dist/cjs/src/user-modules/tag.d.ts.map +1 -1
- package/dist/cjs/src/user-modules/tag.js +28 -15
- package/dist/cjs/src/user-modules/tag.js.map +1 -1
- package/dist/esm/src/package-json.js +2 -2
- package/dist/esm/src/user-modules/contact.d.ts.map +1 -1
- package/dist/esm/src/user-modules/contact.js +31 -18
- package/dist/esm/src/user-modules/contact.js.map +1 -1
- package/dist/esm/src/user-modules/message.d.ts.map +1 -1
- package/dist/esm/src/user-modules/message.js +42 -4
- package/dist/esm/src/user-modules/message.js.map +1 -1
- package/dist/esm/src/user-modules/room.d.ts.map +1 -1
- package/dist/esm/src/user-modules/room.js +31 -19
- package/dist/esm/src/user-modules/room.js.map +1 -1
- package/dist/esm/src/user-modules/room.spec.js +25 -0
- package/dist/esm/src/user-modules/room.spec.js.map +1 -1
- package/dist/esm/src/user-modules/tag-group.d.ts.map +1 -1
- package/dist/esm/src/user-modules/tag-group.js +21 -1
- package/dist/esm/src/user-modules/tag-group.js.map +1 -1
- package/dist/esm/src/user-modules/tag.d.ts.map +1 -1
- package/dist/esm/src/user-modules/tag.js +28 -15
- package/dist/esm/src/user-modules/tag.js.map +1 -1
- package/package.json +1 -1
- package/src/package-json.ts +2 -2
- package/src/user-modules/contact.ts +34 -20
- package/src/user-modules/message.ts +43 -6
- package/src/user-modules/room.spec.ts +33 -0
- package/src/user-modules/room.ts +34 -23
- package/src/user-modules/tag-group.ts +21 -1
- package/src/user-modules/tag.ts +31 -18
package/src/user-modules/tag.ts
CHANGED
|
@@ -77,28 +77,41 @@ class TagMixin extends MixinBase {
|
|
|
77
77
|
static async list (): Promise<TagInterface[]> {
|
|
78
78
|
log.verbose('Tag', 'list()')
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
const tagList: TagInterface[] = []
|
|
89
|
-
for await (const tag of tagIterator) {
|
|
90
|
-
if (tag) {
|
|
91
|
-
tagList.push(tag)
|
|
92
|
-
}
|
|
80
|
+
const tagIdList = await this.wechaty.puppet.tagTagList()
|
|
81
|
+
|
|
82
|
+
let continuousErrorCount = 0
|
|
83
|
+
let totalErrorCount = 0
|
|
84
|
+
const totalErrorThreshold = Math.round(tagIdList.length / 5)
|
|
85
|
+
const idToTag = async (id: string) => {
|
|
86
|
+
if (!this.wechaty.isLoggedIn) {
|
|
87
|
+
throw new Error('wechaty not logged in')
|
|
93
88
|
}
|
|
89
|
+
const result = this.find({ id }).catch(e => {
|
|
90
|
+
this.wechaty.emitError(e)
|
|
91
|
+
continuousErrorCount++
|
|
92
|
+
totalErrorCount++
|
|
93
|
+
if (continuousErrorCount > 5) {
|
|
94
|
+
throw new Error('5 continuous errors!')
|
|
95
|
+
}
|
|
96
|
+
if (totalErrorCount > totalErrorThreshold) {
|
|
97
|
+
throw new Error(`${totalErrorThreshold} total errors!`)
|
|
98
|
+
}
|
|
99
|
+
})
|
|
100
|
+
continuousErrorCount = 0
|
|
101
|
+
return result
|
|
102
|
+
}
|
|
94
103
|
|
|
95
|
-
|
|
104
|
+
const CONCURRENCY = 17
|
|
105
|
+
const tagIterator = concurrencyExecuter(CONCURRENCY)(idToTag)(tagIdList)
|
|
96
106
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
107
|
+
const tagList: TagInterface[] = []
|
|
108
|
+
for await (const tag of tagIterator) {
|
|
109
|
+
if (tag) {
|
|
110
|
+
tagList.push(tag)
|
|
111
|
+
}
|
|
101
112
|
}
|
|
113
|
+
|
|
114
|
+
return tagList
|
|
102
115
|
}
|
|
103
116
|
|
|
104
117
|
static async find (filter: TagQueryFilter): Promise<TagInterface | undefined> {
|