alemonjs 2.1.0-alpha.29 → 2.1.0-alpha.30
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/lib/app/hook-use-api.js +15 -14
- package/package.json +1 -1
package/lib/app/hook-use-api.js
CHANGED
|
@@ -20,7 +20,7 @@ const useMention = (event) => {
|
|
|
20
20
|
}
|
|
21
21
|
let res = null;
|
|
22
22
|
const mention = {
|
|
23
|
-
find: async (options) => {
|
|
23
|
+
find: async (options = {}) => {
|
|
24
24
|
try {
|
|
25
25
|
if (!res) {
|
|
26
26
|
const results = await sendAction({
|
|
@@ -43,28 +43,26 @@ const useMention = (event) => {
|
|
|
43
43
|
}
|
|
44
44
|
// 过滤出符合条件的数据
|
|
45
45
|
const data = res.filter(item => {
|
|
46
|
-
if (options.UserId && item.UserId !== options.UserId) {
|
|
46
|
+
if (options.UserId !== undefined && item.UserId !== options.UserId) {
|
|
47
47
|
return false;
|
|
48
48
|
}
|
|
49
|
-
if (options.UserKey && item.UserKey !== options.UserKey) {
|
|
49
|
+
if (options.UserKey !== undefined && item.UserKey !== options.UserKey) {
|
|
50
50
|
return false;
|
|
51
51
|
}
|
|
52
|
-
if (options.UserName && item.UserName !== options.UserName) {
|
|
52
|
+
if (options.UserName !== undefined && item.UserName !== options.UserName) {
|
|
53
53
|
return false;
|
|
54
54
|
}
|
|
55
|
-
if (options.IsMaster && item.IsMaster !== options.IsMaster) {
|
|
55
|
+
if (options.IsMaster !== undefined && item.IsMaster !== options.IsMaster) {
|
|
56
56
|
return false;
|
|
57
57
|
}
|
|
58
|
-
if (options.IsBot && item.IsBot !== options.IsBot) {
|
|
58
|
+
if (options.IsBot !== undefined && item.IsBot !== options.IsBot) {
|
|
59
59
|
return false;
|
|
60
60
|
}
|
|
61
61
|
return true;
|
|
62
62
|
});
|
|
63
63
|
return createResult(ResultCode.Ok, 'Successfully retrieved mention data', data);
|
|
64
64
|
},
|
|
65
|
-
findOne: async (options = {
|
|
66
|
-
IsBot: false
|
|
67
|
-
}) => {
|
|
65
|
+
findOne: async (options = {}) => {
|
|
68
66
|
try {
|
|
69
67
|
if (!res) {
|
|
70
68
|
const results = await sendAction({
|
|
@@ -87,21 +85,24 @@ const useMention = (event) => {
|
|
|
87
85
|
}
|
|
88
86
|
// 根据条件查找
|
|
89
87
|
const data = res.find(item => {
|
|
90
|
-
if (options.UserId && item.UserId !== options.UserId) {
|
|
88
|
+
if (options.UserId !== undefined && item.UserId !== options.UserId) {
|
|
91
89
|
return false;
|
|
92
90
|
}
|
|
93
|
-
if (options.UserKey && item.UserKey !== options.UserKey) {
|
|
91
|
+
if (options.UserKey !== undefined && item.UserKey !== options.UserKey) {
|
|
94
92
|
return false;
|
|
95
93
|
}
|
|
96
|
-
if (options.UserName && item.UserName !== options.UserName) {
|
|
94
|
+
if (options.UserName !== undefined && item.UserName !== options.UserName) {
|
|
97
95
|
return false;
|
|
98
96
|
}
|
|
99
|
-
if (options.IsMaster && item.IsMaster !== options.IsMaster) {
|
|
97
|
+
if (options.IsMaster !== undefined && item.IsMaster !== options.IsMaster) {
|
|
100
98
|
return false;
|
|
101
99
|
}
|
|
102
|
-
if (options.IsBot && item.IsBot !== options.IsBot) {
|
|
100
|
+
if (options.IsBot !== undefined && item.IsBot !== options.IsBot) {
|
|
103
101
|
return false;
|
|
104
102
|
}
|
|
103
|
+
if (item.IsBot) {
|
|
104
|
+
return false; // 如果是 bot,则不返回
|
|
105
|
+
}
|
|
105
106
|
return true;
|
|
106
107
|
});
|
|
107
108
|
if (!data) {
|