koishi-plugin-bilibili-notify 0.1.0 → 0.1.1
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/comRegister.js +37 -0
- package/lib/generateImg.js +19 -15
- package/package.json +1 -1
package/lib/comRegister.js
CHANGED
|
@@ -131,6 +131,43 @@ class ComRegister {
|
|
|
131
131
|
}
|
|
132
132
|
}, 1000);
|
|
133
133
|
});
|
|
134
|
+
ctx.command('bili')
|
|
135
|
+
.subcommand('.unsub <uid:string>')
|
|
136
|
+
.usage('取消订阅')
|
|
137
|
+
.example('bili unsub 用户UID')
|
|
138
|
+
.action(({ session }, uid) => {
|
|
139
|
+
if (!uid)
|
|
140
|
+
return '用户UID不能为空';
|
|
141
|
+
// 定义是否存在
|
|
142
|
+
let exist = false;
|
|
143
|
+
this.subManager.forEach((sub, i) => {
|
|
144
|
+
if (sub.uid === uid) {
|
|
145
|
+
// 执行dispose方法,销毁定时器
|
|
146
|
+
this.subManager[i].dynamicDispose();
|
|
147
|
+
this.subManager[i].liveDispose();
|
|
148
|
+
// 将该订阅对象从订阅管理对象中移除
|
|
149
|
+
this.subManager = this.subManager.splice(i, i);
|
|
150
|
+
// 发送成功通知
|
|
151
|
+
session.send('已取消订阅该用户');
|
|
152
|
+
// 将存在flag设置为true
|
|
153
|
+
exist = true;
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
// 未订阅该用户,无需取消订阅
|
|
157
|
+
!exist && session.send('未订阅该用户,无需取消订阅');
|
|
158
|
+
});
|
|
159
|
+
ctx.command('bili')
|
|
160
|
+
.subcommand('.show')
|
|
161
|
+
.usage('展示订阅对象')
|
|
162
|
+
.example('bili show')
|
|
163
|
+
.action(async ({ session }) => {
|
|
164
|
+
let table = ``;
|
|
165
|
+
this.subManager.forEach(sub => {
|
|
166
|
+
table += 'UID:' + sub.uid + ' RoomID:' + sub.roomId + '\n';
|
|
167
|
+
});
|
|
168
|
+
!table && session.send('没有订阅任何UP');
|
|
169
|
+
table && session.send(table);
|
|
170
|
+
});
|
|
134
171
|
ctx.command('bili')
|
|
135
172
|
.subcommand('.sub <mid:string> [groupid:string]')
|
|
136
173
|
.option('live', '-l')
|
package/lib/generateImg.js
CHANGED
|
@@ -206,22 +206,26 @@ class GenerateImg extends koishi_1.Service {
|
|
|
206
206
|
// 最基本的图文处理
|
|
207
207
|
function basicDynamic() {
|
|
208
208
|
const module_dynamic = dynamicMajorData.modules.module_dynamic;
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
209
|
+
if (module_dynamic.desc) {
|
|
210
|
+
const richText = module_dynamic.desc.rich_text_nodes.reduce((accumulator, currentValue) => {
|
|
211
|
+
if (currentValue.emoji) {
|
|
212
|
+
return accumulator + `<img style="width:22px; height:22px;" src="${currentValue.emoji.icon_url}"/>`;
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
return accumulator + currentValue.text;
|
|
216
|
+
}
|
|
217
|
+
}, '');
|
|
218
|
+
// 查找\n
|
|
219
|
+
const text = richText.replace(/\n/g, '<br>');
|
|
220
|
+
// 拼接字符串
|
|
221
|
+
if (text) {
|
|
222
|
+
main += `
|
|
223
|
+
<div class="card-details">
|
|
224
|
+
${text}
|
|
225
|
+
</div>
|
|
226
|
+
`;
|
|
215
227
|
}
|
|
216
|
-
}
|
|
217
|
-
// 查找\n
|
|
218
|
-
const text = richText.replace(/\n/g, '<br>');
|
|
219
|
-
// 拼接字符串
|
|
220
|
-
text && (main += `
|
|
221
|
-
<div class="card-details">
|
|
222
|
-
${text}
|
|
223
|
-
</div>
|
|
224
|
-
`);
|
|
228
|
+
}
|
|
225
229
|
// 图片
|
|
226
230
|
let major = '';
|
|
227
231
|
if (module_dynamic.major && module_dynamic.major.draw) {
|