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.
@@ -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('194484313')
156
- const resizedImage = await Jimp.read(data.info.face).then(async image => {
157
- return await image.resize(100, 100).getBufferAsync(Jimp.MIME_PNG)
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
- const resizedImage = await jimp_1.default.read(uData.info.face).then(async (image) => {
997
- return await image.resize(100, 100).getBufferAsync(jimp_1.default.MIME_PNG);
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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-bilibili-notify",
3
3
  "description": "Koishi bilibili notify plugin",
4
- "version": "1.2.7",
4
+ "version": "1.2.8",
5
5
  "contributors": [
6
6
  "Akokko <admin@akokko.com>"
7
7
  ],
package/readme.md CHANGED
@@ -141,6 +141,7 @@
141
141
  - ver 1.2.5 修复了在多群订阅的情况下,其中一个群推送失败会导致其余的群全部重新推送的bug。更换图片处理依赖以解决在插件市场中被标记为不安全插件的问题
142
142
  - ver 1.2.6 现在可以随机生成UA,并更新了UA
143
143
  - ver 1.2.7 修复不论选择什么渲染模式都是render模式的bug,优化直播卡片推送逻辑
144
+ - ver 1.2.8 修复例如像UP主籽岷使用webp格式的头像,下播通知无法发出的bug
144
145
 
145
146
  ## 交流群
146
147