yz-yuki-plugin 2.0.7-12 → 2.0.7-13
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/CHANGELOG.md +1 -0
- package/lib/apps/bilibili.js +35 -7
- package/lib/apps/weibo.js +42 -14
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/lib/apps/bilibili.js
CHANGED
|
@@ -358,6 +358,17 @@ message.use(async (e) => {
|
|
|
358
358
|
}
|
|
359
359
|
else {
|
|
360
360
|
let subData = Config.getConfigData('config', 'bilibili', 'push') || { group: {}, private: {} };
|
|
361
|
+
// 如果聊天ID没有订阅数据,则删除该聊天ID
|
|
362
|
+
for (let chatType in subData) {
|
|
363
|
+
if (subData.hasOwnProperty(chatType)) {
|
|
364
|
+
subData[chatType] = Object.keys(subData[chatType]).reduce((nonEmptyData, chatId) => {
|
|
365
|
+
if (subData[chatType][chatId].length > 0) {
|
|
366
|
+
nonEmptyData[chatId] = subData[chatType][chatId];
|
|
367
|
+
}
|
|
368
|
+
return nonEmptyData;
|
|
369
|
+
}, {});
|
|
370
|
+
}
|
|
371
|
+
}
|
|
361
372
|
const messages = [];
|
|
362
373
|
const typeMap = {
|
|
363
374
|
DYNAMIC_TYPE_AV: '视频',
|
|
@@ -369,9 +380,9 @@ message.use(async (e) => {
|
|
|
369
380
|
};
|
|
370
381
|
// 处理群组订阅
|
|
371
382
|
if (subData.group && Object.keys(subData.group).length > 0) {
|
|
372
|
-
messages.push('
|
|
383
|
+
messages.push('\n>>>>>>群组B站订阅<<<<<<');
|
|
373
384
|
Object.keys(subData.group).forEach(groupId => {
|
|
374
|
-
messages.push(
|
|
385
|
+
messages.push(`\n<群组${groupId}>:`);
|
|
375
386
|
subData.group[groupId].forEach((item) => {
|
|
376
387
|
const types = new Set();
|
|
377
388
|
if (item.type && item.type.length) {
|
|
@@ -381,15 +392,18 @@ message.use(async (e) => {
|
|
|
381
392
|
}
|
|
382
393
|
});
|
|
383
394
|
}
|
|
384
|
-
messages.push(`${item.
|
|
395
|
+
messages.push(`${item.uid}:${item.name} ${types.size ? `[${Array.from(types).join('、')}]` : ' [全部动态]'}`);
|
|
385
396
|
});
|
|
386
397
|
});
|
|
387
398
|
}
|
|
399
|
+
else {
|
|
400
|
+
messages.push('\n>>>>>>群组B站订阅<<<<<<\n当前没有任何群组订阅数据~');
|
|
401
|
+
}
|
|
388
402
|
// 处理私聊订阅
|
|
389
403
|
if (subData.private && Object.keys(subData.private).length > 0) {
|
|
390
|
-
messages.push('\n
|
|
404
|
+
messages.push('\n>>>>>>私聊B站订阅<<<<<<');
|
|
391
405
|
Object.keys(subData.private).forEach(userId => {
|
|
392
|
-
messages.push(
|
|
406
|
+
messages.push(`\n<用户${userId}>:`);
|
|
393
407
|
subData.private[userId].forEach((item) => {
|
|
394
408
|
const types = new Set();
|
|
395
409
|
if (item.type && item.type.length) {
|
|
@@ -399,16 +413,30 @@ message.use(async (e) => {
|
|
|
399
413
|
}
|
|
400
414
|
});
|
|
401
415
|
}
|
|
402
|
-
messages.push(`${item.
|
|
416
|
+
messages.push(`${item.uid}:${item.name} ${types.size ? `[${Array.from(types).join('、')}]` : ' [全部动态]'}`);
|
|
403
417
|
});
|
|
404
418
|
});
|
|
405
419
|
}
|
|
420
|
+
else {
|
|
421
|
+
messages.push('\n>>>>>>私聊B站订阅<<<<<<\n当前没有任何私聊订阅数据~');
|
|
422
|
+
}
|
|
406
423
|
e.reply(`推送列表如下:\n${messages.join('\n')}`);
|
|
407
424
|
}
|
|
408
425
|
}, [/^(#|\/)(yuki|优纪)?(b站|B站|bili|bilibili|哔哩|哔哩哔哩)全部(推送|动态|订阅)列表$/]);
|
|
409
426
|
/** 单独群聊或私聊的订阅的b站推送列表 */
|
|
410
427
|
message.use(async (e) => {
|
|
411
428
|
let subData = Config.getConfigData('config', 'bilibili', 'push') || { group: {}, private: {} };
|
|
429
|
+
// 如果聊天ID没有订阅数据,则删除该聊天ID
|
|
430
|
+
for (let chatType in subData) {
|
|
431
|
+
if (subData.hasOwnProperty(chatType)) {
|
|
432
|
+
subData[chatType] = Object.keys(subData[chatType]).reduce((nonEmptyData, chatId) => {
|
|
433
|
+
if (subData[chatType][chatId].length > 0) {
|
|
434
|
+
nonEmptyData[chatId] = subData[chatType][chatId];
|
|
435
|
+
}
|
|
436
|
+
return nonEmptyData;
|
|
437
|
+
}, {});
|
|
438
|
+
}
|
|
439
|
+
}
|
|
412
440
|
const messages = [];
|
|
413
441
|
const typeMap = {
|
|
414
442
|
DYNAMIC_TYPE_AV: '视频',
|
|
@@ -433,7 +461,7 @@ message.use(async (e) => {
|
|
|
433
461
|
}
|
|
434
462
|
});
|
|
435
463
|
}
|
|
436
|
-
messages.push(`${item.
|
|
464
|
+
messages.push(`${item.uid}:${item.name} ${types.size ? `[${Array.from(types).join('、')}]` : ' [全部动态]'}`);
|
|
437
465
|
});
|
|
438
466
|
e.reply(`推送列表如下:\n${messages.join('\n')}`);
|
|
439
467
|
}, [/^(#|\/)(yuki|优纪)?(b站|B站|bili|bilibili|哔哩|哔哩哔哩)(推送|动态|订阅)列表$/]);
|
package/lib/apps/weibo.js
CHANGED
|
@@ -86,16 +86,16 @@ message.use(async (e) => {
|
|
|
86
86
|
return;
|
|
87
87
|
}
|
|
88
88
|
// 获取或初始化微博推送数据
|
|
89
|
-
let
|
|
89
|
+
let subData = weiboPushData || { group: {}, private: {} };
|
|
90
90
|
// 根据聊天类型初始化数据
|
|
91
91
|
let chatType = e.isGroup ? 'group' : 'private';
|
|
92
92
|
let chatId = e.isGroup ? e.group_id : e.user_id;
|
|
93
93
|
// 初始化群组或私聊数据
|
|
94
|
-
if (!
|
|
95
|
-
|
|
94
|
+
if (!subData[chatType][chatId]) {
|
|
95
|
+
subData[chatType][chatId] = [];
|
|
96
96
|
}
|
|
97
97
|
// 查找指定UID的订阅数据
|
|
98
|
-
const upData =
|
|
98
|
+
const upData = subData[chatType][chatId].find((item) => item.uid == uid);
|
|
99
99
|
if (!upData) {
|
|
100
100
|
e.reply(`订阅列表中没有找到该UID~\n${uid}可能是无效的`);
|
|
101
101
|
return;
|
|
@@ -105,7 +105,7 @@ message.use(async (e) => {
|
|
|
105
105
|
let isDel = false;
|
|
106
106
|
if (newType.length) {
|
|
107
107
|
// 更新订阅类型
|
|
108
|
-
|
|
108
|
+
subData[chatType][chatId] = subData[chatType][chatId].map(item => {
|
|
109
109
|
if (item.uid == uid) {
|
|
110
110
|
item.type = newType;
|
|
111
111
|
}
|
|
@@ -115,11 +115,11 @@ message.use(async (e) => {
|
|
|
115
115
|
else {
|
|
116
116
|
// 删除订阅
|
|
117
117
|
isDel = true;
|
|
118
|
-
|
|
118
|
+
subData[chatType][chatId] = subData[chatType][chatId].filter((item) => item.uid !== uid);
|
|
119
119
|
}
|
|
120
120
|
// 保存更新后的数据
|
|
121
121
|
//weiboPushData = data;
|
|
122
|
-
Config.saveConfig('config', 'weibo', 'push',
|
|
122
|
+
Config.saveConfig('config', 'weibo', 'push', subData);
|
|
123
123
|
// 回复用户操作结果
|
|
124
124
|
e.reply(`${isDel ? '删除' : '修改'}微博推送成功~\n${uid}`);
|
|
125
125
|
}
|
|
@@ -131,6 +131,17 @@ message.use(async (e) => {
|
|
|
131
131
|
}
|
|
132
132
|
else {
|
|
133
133
|
let subData = weiboPushData || { group: {}, private: {} };
|
|
134
|
+
// 如果聊天ID没有订阅数据,则删除该聊天ID
|
|
135
|
+
for (let chatType in subData) {
|
|
136
|
+
if (subData.hasOwnProperty(chatType)) {
|
|
137
|
+
subData[chatType] = Object.keys(subData[chatType]).reduce((nonEmptyData, chatId) => {
|
|
138
|
+
if (subData[chatType][chatId].length > 0) {
|
|
139
|
+
nonEmptyData[chatId] = subData[chatType][chatId];
|
|
140
|
+
}
|
|
141
|
+
return nonEmptyData;
|
|
142
|
+
}, {});
|
|
143
|
+
}
|
|
144
|
+
}
|
|
134
145
|
const messages = [];
|
|
135
146
|
const typeMap = {
|
|
136
147
|
DYNAMIC_TYPE_AV: '视频',
|
|
@@ -141,9 +152,9 @@ message.use(async (e) => {
|
|
|
141
152
|
};
|
|
142
153
|
// 处理群组订阅
|
|
143
154
|
if (subData.group && Object.keys(subData.group).length > 0) {
|
|
144
|
-
messages.push('
|
|
155
|
+
messages.push('\n>>>>>>群组微博订阅<<<<<<');
|
|
145
156
|
Object.keys(subData.group).forEach(groupId => {
|
|
146
|
-
messages.push(
|
|
157
|
+
messages.push(`\n<群组${groupId}>:`);
|
|
147
158
|
subData.group[groupId].forEach((item) => {
|
|
148
159
|
const types = new Set();
|
|
149
160
|
if (item.type && item.type.length) {
|
|
@@ -153,15 +164,18 @@ message.use(async (e) => {
|
|
|
153
164
|
}
|
|
154
165
|
});
|
|
155
166
|
}
|
|
156
|
-
messages.push(`${item.
|
|
167
|
+
messages.push(`${item.uid}:${item.name} ${types.size ? `[${Array.from(types).join('、')}]` : ' [全部动态]'}`);
|
|
157
168
|
});
|
|
158
169
|
});
|
|
159
170
|
}
|
|
171
|
+
else {
|
|
172
|
+
messages.push('\n>>>>>>群组微博订阅<<<<<<\n当前没有任何群组订阅数据~');
|
|
173
|
+
}
|
|
160
174
|
// 处理私聊订阅
|
|
161
175
|
if (subData.private && Object.keys(subData.private).length > 0) {
|
|
162
|
-
messages.push('
|
|
176
|
+
messages.push('\n>>>>>>私聊微博订阅<<<<<<');
|
|
163
177
|
Object.keys(subData.private).forEach(userId => {
|
|
164
|
-
messages.push(
|
|
178
|
+
messages.push(`\n<用户${userId}>:`);
|
|
165
179
|
subData.private[userId].forEach((item) => {
|
|
166
180
|
const types = new Set();
|
|
167
181
|
if (item.type && item.type.length) {
|
|
@@ -171,16 +185,30 @@ message.use(async (e) => {
|
|
|
171
185
|
}
|
|
172
186
|
});
|
|
173
187
|
}
|
|
174
|
-
messages.push(`${item.
|
|
188
|
+
messages.push(`${item.uid}:${item.name} ${types.size ? `[${Array.from(types).join('、')}]` : ' [全部动态]'}`);
|
|
175
189
|
});
|
|
176
190
|
});
|
|
177
191
|
}
|
|
192
|
+
else {
|
|
193
|
+
messages.push('\n>>>>>>私聊微博订阅<<<<<<\n当前没有任何私聊订阅数据~');
|
|
194
|
+
}
|
|
178
195
|
e.reply(`推送列表如下:\n${messages.join('\n')}`);
|
|
179
196
|
}
|
|
180
197
|
}, [/^(#|\/)(yuki|优纪)?(微博|weibo|WEIBO)全部(推送|动态|订阅)列表$/]);
|
|
181
198
|
/** 单独群聊或私聊的订阅的b站推送列表 */
|
|
182
199
|
message.use(async (e) => {
|
|
183
200
|
let subData = weiboPushData || { group: {}, private: {} };
|
|
201
|
+
// 如果聊天ID没有订阅数据,则删除该聊天ID
|
|
202
|
+
for (let chatType in subData) {
|
|
203
|
+
if (subData.hasOwnProperty(chatType)) {
|
|
204
|
+
subData[chatType] = Object.keys(subData[chatType]).reduce((nonEmptyData, chatId) => {
|
|
205
|
+
if (subData[chatType][chatId].length > 0) {
|
|
206
|
+
nonEmptyData[chatId] = subData[chatType][chatId];
|
|
207
|
+
}
|
|
208
|
+
return nonEmptyData;
|
|
209
|
+
}, {});
|
|
210
|
+
}
|
|
211
|
+
}
|
|
184
212
|
const messages = [];
|
|
185
213
|
const typeMap = {
|
|
186
214
|
DYNAMIC_TYPE_AV: '视频',
|
|
@@ -204,7 +232,7 @@ message.use(async (e) => {
|
|
|
204
232
|
}
|
|
205
233
|
});
|
|
206
234
|
}
|
|
207
|
-
messages.push(`${item.
|
|
235
|
+
messages.push(`${item.uid}:${item.name} ${types.size ? `[${Array.from(types).join('、')}]` : ' [全部动态]'}`);
|
|
208
236
|
});
|
|
209
237
|
e.reply(`推送列表如下:\n${messages.join('\n')}`);
|
|
210
238
|
}, [/^(#|\/)(yuki|优纪)?(微博|weibo|WEIBO)(推送|动态|订阅)列表$/]);
|