koishi-plugin-bilibili-notify 1.2.0-alpha.4 → 1.2.0-alpha.5

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.
@@ -660,8 +660,9 @@ class ComRegister {
660
660
  break;
661
661
  }
662
662
  catch (e) {
663
+ this.logger.error('dynamicDetect generateLiveImg() 推送卡片发送失败,原因:' + e.toString());
663
664
  if (i === attempts - 1) { // 如果已经尝试了三次,那么抛出错误
664
- throw e;
665
+ return this.sendMsg(guildId, bot, '插件可能出现某些未知错误,请尝试重启插件,如果仍然发生该错误,请带着日志向作者反馈');
665
666
  }
666
667
  }
667
668
  }
@@ -709,9 +710,9 @@ class ComRegister {
709
710
  break;
710
711
  }
711
712
  catch (e) {
712
- this.logger.error('liveDetect generateLiveImg() 推送卡片发送失败');
713
+ this.logger.error('liveDetect generateLiveImg() 推送卡片发送失败,原因:' + e.toString());
713
714
  if (i === attempts - 1) { // 已尝试三次
714
- return this.sendMsg(guildId, bot, '插件可能出现某些未知错误,请尝试重启插件,如果仍然会发生该错误,请向作者反馈');
715
+ return this.sendMsg(guildId, bot, '插件可能出现某些未知错误,请尝试重启插件,如果仍然发生该错误,请带着日志向作者反馈');
715
716
  }
716
717
  }
717
718
  }
package/lib/database.js CHANGED
@@ -6,8 +6,8 @@ function apply(ctx) {
6
6
  // 新增LoginBili表
7
7
  ctx.model.extend('loginBili', {
8
8
  id: 'unsigned',
9
- bili_cookies: 'string',
10
- bili_refresh_token: 'string'
9
+ bili_cookies: 'text',
10
+ bili_refresh_token: 'text'
11
11
  });
12
12
  // 新增Bilibili表
13
13
  ctx.model.extend('bilibili', {
@@ -185,30 +185,41 @@ class GenerateImg extends koishi_1.Service {
185
185
  </body>
186
186
  </html>
187
187
  `;
188
- // 判断渲染方式
189
- if (this.giConfig.renderType) { // 为1则为真,进入page模式
190
- const htmlPath = 'file://' + __dirname.replaceAll('\\', '/') + '/page/0.html';
191
- const page = await this.ctx.puppeteer.page();
192
- await page.goto(htmlPath);
193
- await page.setContent(html, { waitUntil: 'networkidle0' });
194
- const elementHandle = await page.$('html');
195
- const boundingBox = await elementHandle.boundingBox();
196
- const buffer = await page.screenshot({
197
- type: 'png',
198
- clip: {
199
- x: boundingBox.x,
200
- y: boundingBox.y,
201
- width: boundingBox.width,
202
- height: boundingBox.height
188
+ // 多次尝试生成图片
189
+ let attempts = 3;
190
+ for (let i = 0; i < attempts; i++) {
191
+ try {
192
+ // 判断渲染方式
193
+ if (this.giConfig.renderType) { // 为1则为真,进入page模式
194
+ const htmlPath = 'file://' + __dirname.replaceAll('\\', '/') + '/page/0.html';
195
+ const page = await this.ctx.puppeteer.page();
196
+ await page.goto(htmlPath);
197
+ await page.setContent(html, { waitUntil: 'networkidle0' });
198
+ const elementHandle = await page.$('html');
199
+ const boundingBox = await elementHandle.boundingBox();
200
+ const buffer = await page.screenshot({
201
+ type: 'png',
202
+ clip: {
203
+ x: boundingBox.x,
204
+ y: boundingBox.y,
205
+ width: boundingBox.width,
206
+ height: boundingBox.height
207
+ }
208
+ });
209
+ await elementHandle.dispose();
210
+ await page.close();
211
+ return { buffer };
212
+ }
213
+ // 使用render模式渲染
214
+ const pic = await this.ctx.puppeteer.render(html);
215
+ return { pic };
216
+ }
217
+ catch (e) {
218
+ if (i === attempts - 1) { // 已尝试三次
219
+ throw new Error('生成图片失败!错误: ' + e.toString());
203
220
  }
204
- });
205
- await elementHandle.dispose();
206
- await page.close();
207
- return { buffer };
221
+ }
208
222
  }
209
- // 使用render模式渲染
210
- const pic = await this.ctx.puppeteer.render(html);
211
- return { pic };
212
223
  }
213
224
  async generateDynamicImg(data) {
214
225
  // module_author
@@ -1257,30 +1268,41 @@ class GenerateImg extends koishi_1.Service {
1257
1268
  </body>
1258
1269
  </html>
1259
1270
  `;
1260
- // 判断渲染方式
1261
- if (this.giConfig.renderType) { // 为1则为真,进入page模式
1262
- const htmlPath = 'file://' + __dirname.replaceAll('\\', '/') + '/page/0.html';
1263
- const page = await this.ctx.puppeteer.page();
1264
- await page.goto(htmlPath);
1265
- await page.setContent(html, { waitUntil: 'networkidle0' });
1266
- const elementHandle = await page.$('html');
1267
- const boundingBox = await elementHandle.boundingBox();
1268
- const buffer = await page.screenshot({
1269
- type: 'png',
1270
- clip: {
1271
- x: boundingBox.x,
1272
- y: boundingBox.y,
1273
- width: boundingBox.width,
1274
- height: boundingBox.height
1271
+ // 多次尝试生成图片
1272
+ let attempts = 3;
1273
+ for (let i = 0; i < attempts; i++) {
1274
+ try {
1275
+ // 判断渲染方式
1276
+ if (this.giConfig.renderType) { // 为1则为真,进入page模式
1277
+ const htmlPath = 'file://' + __dirname.replaceAll('\\', '/') + '/page/0.html';
1278
+ const page = await this.ctx.puppeteer.page();
1279
+ await page.goto(htmlPath);
1280
+ await page.setContent(html, { waitUntil: 'networkidle0' });
1281
+ const elementHandle = await page.$('html');
1282
+ const boundingBox = await elementHandle.boundingBox();
1283
+ const buffer = await page.screenshot({
1284
+ type: 'png',
1285
+ clip: {
1286
+ x: boundingBox.x,
1287
+ y: boundingBox.y,
1288
+ width: boundingBox.width,
1289
+ height: boundingBox.height
1290
+ }
1291
+ });
1292
+ await elementHandle.dispose();
1293
+ await page.close();
1294
+ return { buffer, link };
1295
+ }
1296
+ // 使用render模式渲染
1297
+ const pic = await this.ctx.puppeteer.render(html);
1298
+ return { pic, link };
1299
+ }
1300
+ catch (e) {
1301
+ if (i === attempts - 1) { // 已尝试三次
1302
+ throw new Error('生成图片失败!错误: ' + e.toString());
1275
1303
  }
1276
- });
1277
- await elementHandle.dispose();
1278
- await page.close();
1279
- return { buffer, link };
1304
+ }
1280
1305
  }
1281
- // 使用render模式渲染
1282
- const pic = await this.ctx.puppeteer.render(html);
1283
- return { pic, link };
1284
1306
  }
1285
1307
  async getLiveStatus(time, liveStatus) {
1286
1308
  let titleStatus;
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.0-alpha.4",
4
+ "version": "1.2.0-alpha.5",
5
5
  "contributors": [
6
6
  "Akokko <admin@akokko.com>"
7
7
  ],
package/readme.md CHANGED
@@ -105,6 +105,7 @@
105
105
  - ver 1.2.0-alpha.2 支持QQ群多群推送(实验性),修复了一些bug
106
106
  - ver 1.2.0-alpha.3 修复了指定QQ群订阅时的一个bug
107
107
  - ver 1.2.0-alpha.4 对时间获取进行了优化,能够适应不同环境下的时间获取,修复了一些bug
108
+ - ver 1.2.0-alpha.5 修复了与PostgreSQL不兼容的问题,优化了图片推送,增强了推送容错
108
109
 
109
110
  ## 感谢
110
111