koishi-plugin-bilibili-notify 1.2.7 → 1.2.9-alpha.0

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
 
@@ -844,12 +850,14 @@ class ComRegister {
844
850
  const dUrl = this.config.dynamicUrl ? `${upName}发布了一条动态:https://t.bilibili.com/${dynamicId}` : '';
845
851
  // 如果pic存在,则直接返回pic
846
852
  if (pic) {
853
+ console.log('render mode');
847
854
  // pic存在,使用的是render模式
848
855
  await this.sendMsg(ctx, guildId, bot, pic + (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: dUrl }));
849
856
  }
850
857
  else {
858
+ console.log('page mode');
851
859
  // pic不存在,说明使用的是page模式
852
- await this.sendMsg(ctx, guildId, bot, (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [koishi_1.h.image(buffer, 'image/png'), " ", dUrl] }));
860
+ await this.sendMsg(ctx, guildId, bot, (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("img", { src: 'data:image/png;base64,' + buffer.toString('base64') }), " ", dUrl] }));
853
861
  }
854
862
  // 更新时间点为最新发布动态的发布时间
855
863
  switch (num) {
@@ -903,23 +911,7 @@ class ComRegister {
903
911
  return await this.sendMsg(ctx, guildId, bot, pic + msg);
904
912
  }
905
913
  // pic不存在,说明使用的是page模式
906
- 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
- } */
914
+ await this.sendMsg(ctx, guildId, bot, (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("img", { src: 'data:image/png;base64,' + buffer.toString('base64') }), " ", atAll && (0, jsx_runtime_1.jsx)("at", { type: "all" }), " ", liveStartMsg && liveStartMsg] }));
923
915
  };
924
916
  return async () => {
925
917
  try {
@@ -993,11 +985,21 @@ class ComRegister {
993
985
  .replace('-name', uData.info.uname)
994
986
  .replace('-time', await ctx.gimg.getTimeDifference(liveTime));
995
987
  // 获取头像并缩放
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
- });
988
+ let resizedImage;
989
+ // Jimp无法处理Webp格式,直接跳过
990
+ try {
991
+ resizedImage = await jimp_1.default.read(uData.info.face).then(async (image) => {
992
+ return await image.resize(100, 100).getBufferAsync(jimp_1.default.MIME_PNG);
993
+ });
994
+ }
995
+ catch (e) {
996
+ if (e.message === 'Unsupported MIME type: image/webp')
997
+ console.log('主播使用的是webp格式头像,无法进行渲染');
998
+ else
999
+ console.log(e);
1000
+ }
999
1001
  // 发送下播通知
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] }));
1002
+ 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
1003
  }
1002
1004
  // 未进循环,还未开播,继续循环
1003
1005
  break;
package/lib/database.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.apply = exports.name = void 0;
3
+ exports.name = void 0;
4
+ exports.apply = apply;
4
5
  exports.name = 'Database';
5
6
  function apply(ctx) {
6
7
  // 新增LoginBili表
@@ -22,4 +23,3 @@ function apply(ctx) {
22
23
  time: 'timestamp'
23
24
  }, { autoInc: true });
24
25
  }
25
- exports.apply = apply;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { Context, Schema, Service } from "koishi";
3
2
  declare module 'koishi' {
4
3
  interface Context {
package/lib/index.js CHANGED
@@ -26,7 +26,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.apply = exports.Config = exports.name = exports.inject = void 0;
29
+ exports.Config = exports.name = exports.inject = void 0;
30
+ exports.apply = apply;
30
31
  const koishi_1 = require("koishi");
31
32
  // import plugins
32
33
  // import Authority from './authority'
@@ -263,4 +264,3 @@ function apply(ctx, config) {
263
264
  }
264
265
  });
265
266
  }
266
- exports.apply = apply;
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.9-alpha.0",
5
5
  "contributors": [
6
6
  "Akokko <admin@akokko.com>"
7
7
  ],
@@ -24,11 +24,11 @@
24
24
  "bilibili"
25
25
  ],
26
26
  "peerDependencies": {
27
- "koishi": "^4.17.2"
27
+ "koishi": "^4.17.4"
28
28
  },
29
29
  "dependencies": {
30
- "axios": "^1.6.7",
31
- "axios-cookiejar-support": "^5.0.0",
30
+ "axios": "^1.6.8",
31
+ "axios-cookiejar-support": "^5.0.1",
32
32
  "jimp": "^0.22.12",
33
33
  "jsdom": "^24.0.0",
34
34
  "luxon": "^3.4.4",
@@ -41,7 +41,7 @@
41
41
  "@types/md5": "^2",
42
42
  "@types/qrcode": "^1",
43
43
  "@types/tough-cookie": "^4",
44
- "koishi-plugin-puppeteer": "^3.8.2"
44
+ "koishi-plugin-puppeteer": "^3.8.4"
45
45
  },
46
46
  "koishi": {
47
47
  "service": {
package/readme.md CHANGED
@@ -141,6 +141,8 @@
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
145
+ - ver 1.2.9-alpha.0 bug测试版本,请跳过
144
146
 
145
147
  ## 交流群
146
148