koishi-plugin-bilibili-notify 1.2.7 → 1.2.8
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 +25 -25
- package/package.json +1 -1
- package/readme.md +1 -0
package/lib/comRegister.js
CHANGED
|
@@ -152,13 +152,19 @@ class ComRegister {
|
|
|
152
152
|
// logger
|
|
153
153
|
this.logger.info('调用test gimg指令')
|
|
154
154
|
// 获取主播信息
|
|
155
|
-
const { data } = await ctx.biliAPI.getMasterInfo('
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
155
|
+
const { data } = await ctx.biliAPI.getMasterInfo('686127')
|
|
156
|
+
let resizedImage: Buffer
|
|
157
|
+
try {
|
|
158
|
+
resizedImage = await Jimp.read(data.info.face).then(async image => {
|
|
159
|
+
return await image.resize(100, 100).getBufferAsync(Jimp.MIME_PNG)
|
|
160
|
+
})
|
|
161
|
+
} catch (e) {
|
|
162
|
+
if (e.message === 'Unsupported MIME type: image/webp') console.log('主播使用的是webp格式头像,无法进行渲染');
|
|
163
|
+
else console.log(e);
|
|
164
|
+
}
|
|
159
165
|
// 发送下播提示语
|
|
160
166
|
await session.send(
|
|
161
|
-
<>{h.image(resizedImage, 'image/png')} 主播{data.info.uname}已下播</>
|
|
167
|
+
<>{resizedImage && h.image(resizedImage, 'image/png')} 主播{data.info.uname}已下播</>
|
|
162
168
|
)
|
|
163
169
|
})
|
|
164
170
|
|
|
@@ -904,22 +910,6 @@ class ComRegister {
|
|
|
904
910
|
}
|
|
905
911
|
// pic不存在,说明使用的是page模式
|
|
906
912
|
await this.sendMsg(ctx, guildId, bot, (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [koishi_1.h.image(buffer, 'image/png'), " ", atAll && (0, jsx_runtime_1.jsx)("at", { type: "all" }), " ", liveStartMsg && liveStartMsg] }));
|
|
907
|
-
/* if (!liveStartMsg) {
|
|
908
|
-
// pic 存在,使用的是render模式
|
|
909
|
-
if (pic) return await this.sendMsg(ctx, guildId, bot, pic)
|
|
910
|
-
// pic不存在,说明使用的是page模式
|
|
911
|
-
await this.sendMsg(ctx, guildId, bot, h.image(buffer, 'image/png'))
|
|
912
|
-
} else if (liveStartMsg && atAll) {
|
|
913
|
-
// pic 存在,使用的是render模式
|
|
914
|
-
if (pic) return await this.sendMsg(ctx, guildId, bot, pic + <><at type="all" /> {liveStartMsg} </>)
|
|
915
|
-
// pic不存在,说明使用的是page模式
|
|
916
|
-
await this.sendMsg(ctx, guildId, bot, <>{h.image(buffer, 'image/png')} <at type="all" /> {liveStartMsg}</>)
|
|
917
|
-
} else {
|
|
918
|
-
// pic 存在,使用的是render模式
|
|
919
|
-
if (pic) return await this.sendMsg(ctx, guildId, bot, pic + <>{liveStartMsg}</>)
|
|
920
|
-
// pic不存在,说明使用的是page模式
|
|
921
|
-
await this.sendMsg(ctx, guildId, bot, h.image(buffer, 'image/png' + liveStartMsg))
|
|
922
|
-
} */
|
|
923
913
|
};
|
|
924
914
|
return async () => {
|
|
925
915
|
try {
|
|
@@ -993,11 +983,21 @@ class ComRegister {
|
|
|
993
983
|
.replace('-name', uData.info.uname)
|
|
994
984
|
.replace('-time', await ctx.gimg.getTimeDifference(liveTime));
|
|
995
985
|
// 获取头像并缩放
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
986
|
+
let resizedImage;
|
|
987
|
+
// Jimp无法处理Webp格式,直接跳过
|
|
988
|
+
try {
|
|
989
|
+
resizedImage = await jimp_1.default.read(uData.info.face).then(async (image) => {
|
|
990
|
+
return await image.resize(100, 100).getBufferAsync(jimp_1.default.MIME_PNG);
|
|
991
|
+
});
|
|
992
|
+
}
|
|
993
|
+
catch (e) {
|
|
994
|
+
if (e.message === 'Unsupported MIME type: image/webp')
|
|
995
|
+
console.log('主播使用的是webp格式头像,无法进行渲染');
|
|
996
|
+
else
|
|
997
|
+
console.log(e);
|
|
998
|
+
}
|
|
999
999
|
// 发送下播通知
|
|
1000
|
-
await this.sendMsg(ctx, guildId, bot, (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [koishi_1.h.image(resizedImage, 'image/png'), " ", liveEndMsg] }));
|
|
1000
|
+
await this.sendMsg(ctx, guildId, bot, (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [resizedImage && koishi_1.h.image(resizedImage, 'image/png'), " ", liveEndMsg] }));
|
|
1001
1001
|
}
|
|
1002
1002
|
// 未进循环,还未开播,继续循环
|
|
1003
1003
|
break;
|
package/package.json
CHANGED
package/readme.md
CHANGED