koishi-plugin-bilibili-notify 1.2.6 → 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.
@@ -103,15 +103,6 @@ class ComRegister {
103
103
  session.send(await ctx.biliAPI.getTimeNow())
104
104
  })
105
105
 
106
- testCom
107
- .subcommand('.exist')
108
- .usage('测试写法')
109
- .example('test.exist')
110
- .action(async () => {
111
- let num = 1;
112
- console.log(num && `Hello World`);
113
- })
114
-
115
106
  testCom
116
107
  .subcommand('.gimg <uid:string> <index:number>')
117
108
  .usage('测试图片生成')
@@ -161,13 +152,19 @@ class ComRegister {
161
152
  // logger
162
153
  this.logger.info('调用test gimg指令')
163
154
  // 获取主播信息
164
- const { data } = await ctx.biliAPI.getMasterInfo('194484313')
165
- const resizedImage = await Jimp.read(data.info.face).then(async image => {
166
- return await image.resize(100, 100).getBufferAsync(Jimp.MIME_PNG)
167
- })
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
+ }
168
165
  // 发送下播提示语
169
166
  await session.send(
170
- <>{h.image(resizedImage, 'image/png')} 主播{data.info.uname}已下播</>
167
+ <>{resizedImage && h.image(resizedImage, 'image/png')} 主播{data.info.uname}已下播</>
171
168
  )
172
169
  })
173
170
 
@@ -854,11 +851,11 @@ class ComRegister {
854
851
  // 如果pic存在,则直接返回pic
855
852
  if (pic) {
856
853
  // pic存在,使用的是render模式
857
- await this.sendMsg(ctx, guildId, bot, pic + dUrl);
854
+ await this.sendMsg(ctx, guildId, bot, pic + (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: dUrl }));
858
855
  }
859
856
  else {
860
857
  // pic不存在,说明使用的是page模式
861
- await this.sendMsg(ctx, guildId, bot, koishi_1.h.image(buffer, 'image/png' + dUrl));
858
+ await this.sendMsg(ctx, guildId, bot, (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [koishi_1.h.image(buffer, 'image/png'), " ", dUrl] }));
862
859
  }
863
860
  // 更新时间点为最新发布动态的发布时间
864
861
  switch (num) {
@@ -906,27 +903,13 @@ class ComRegister {
906
903
  }
907
904
  }
908
905
  // 推送直播信息
909
- if (!liveStartMsg) {
910
- // pic 存在,使用的是render模式
911
- if (pic)
912
- return await this.sendMsg(ctx, guildId, bot, pic);
913
- // pic不存在,说明使用的是page模式
914
- await this.sendMsg(ctx, guildId, bot, koishi_1.h.image(buffer, 'image/png'));
915
- }
916
- else if (liveStartMsg && atAll) {
917
- // pic 存在,使用的是render模式
918
- if (pic)
919
- return await this.sendMsg(ctx, guildId, bot, pic + (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("at", { type: "all" }), " ", liveStartMsg, " "] }));
920
- // pic不存在,说明使用的是page模式
921
- await this.sendMsg(ctx, guildId, bot, koishi_1.h.image(buffer, 'image/png' + (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("at", { type: "all" }), " ", liveStartMsg] })));
922
- }
923
- else {
924
- // pic 存在,使用的是render模式
925
- if (pic)
926
- return await this.sendMsg(ctx, guildId, bot, pic + liveStartMsg);
927
- // pic不存在,说明使用的是page模式
928
- await this.sendMsg(ctx, guildId, bot, koishi_1.h.image(buffer, 'image/png' + liveStartMsg));
906
+ // pic 存在,使用的是render模式
907
+ if (pic) {
908
+ let msg = (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [atAll && (0, jsx_runtime_1.jsx)("at", { type: "all" }), " ", liveStartMsg && liveStartMsg] });
909
+ return await this.sendMsg(ctx, guildId, bot, pic + msg);
929
910
  }
911
+ // pic不存在,说明使用的是page模式
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] }));
930
913
  };
931
914
  return async () => {
932
915
  try {
@@ -1000,11 +983,21 @@ class ComRegister {
1000
983
  .replace('-name', uData.info.uname)
1001
984
  .replace('-time', await ctx.gimg.getTimeDifference(liveTime));
1002
985
  // 获取头像并缩放
1003
- const resizedImage = await jimp_1.default.read(uData.info.face).then(async (image) => {
1004
- return await image.resize(100, 100).getBufferAsync(jimp_1.default.MIME_PNG);
1005
- });
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
+ }
1006
999
  // 发送下播通知
1007
- 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] }));
1008
1001
  }
1009
1002
  // 未进循环,还未开播,继续循环
1010
1003
  break;
package/lib/index.js CHANGED
@@ -158,7 +158,7 @@ class ServerManager extends koishi_1.Service {
158
158
  super(ctx, 'sm');
159
159
  }
160
160
  start() {
161
- this.registerPlugin();
161
+ // 根据用户设置的渲染模式设置
162
162
  switch (globalConfig.renderType) {
163
163
  case 'render':
164
164
  this.renderType = 0;
@@ -167,6 +167,8 @@ class ServerManager extends koishi_1.Service {
167
167
  this.renderType = 1;
168
168
  break;
169
169
  }
170
+ // 注册插件
171
+ this.registerPlugin();
170
172
  }
171
173
  registerPlugin = () => {
172
174
  const biliApi = this.ctx.plugin(biliAPI_1.default);
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.6",
4
+ "version": "1.2.8",
5
5
  "contributors": [
6
6
  "Akokko <admin@akokko.com>"
7
7
  ],
package/readme.md CHANGED
@@ -139,6 +139,9 @@
139
139
  - ver 1.2.3 完善主播下播消息发送头像功能,优化控制台订阅信息显示
140
140
  - ver 1.2.4 优化了下播消息发送头像图片的质量和插件重启提示
141
141
  - ver 1.2.5 修复了在多群订阅的情况下,其中一个群推送失败会导致其余的群全部重新推送的bug。更换图片处理依赖以解决在插件市场中被标记为不安全插件的问题
142
+ - ver 1.2.6 现在可以随机生成UA,并更新了UA
143
+ - ver 1.2.7 修复不论选择什么渲染模式都是render模式的bug,优化直播卡片推送逻辑
144
+ - ver 1.2.8 修复例如像UP主籽岷使用webp格式的头像,下播通知无法发出的bug
142
145
 
143
146
  ## 交流群
144
147