koishi-plugin-bilibili-notify 1.2.5 → 1.2.7

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/biliAPI.d.ts CHANGED
@@ -28,6 +28,7 @@ declare class BiliAPI extends Service {
28
28
  getLiveRoomInfo(roomId: string): Promise<any>;
29
29
  getMasterInfo(mid: string): Promise<any>;
30
30
  disposeNotifier(): void;
31
+ getRandomUserAgent(): string;
31
32
  createNewClient(): void;
32
33
  getTimeOfUTC8(): number;
33
34
  getCookies(): string;
package/lib/biliAPI.js CHANGED
@@ -150,13 +150,29 @@ class BiliAPI extends koishi_1.Service {
150
150
  }
151
151
  }
152
152
  disposeNotifier() { this.loginNotifier && this.loginNotifier.dispose(); }
153
+ getRandomUserAgent() {
154
+ const userAgents = [
155
+ // Chrome
156
+ 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36',
157
+ // Firefox
158
+ 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:97.0) Gecko/20100101 Firefox/97.0',
159
+ // Safari
160
+ 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.3 Safari/605.1.15',
161
+ // Internet Explorer
162
+ 'Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; AS; rv:11.0) like Gecko',
163
+ // Edge
164
+ 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36 Edg/98.0.1108.62',
165
+ ];
166
+ const index = Math.floor(Math.random() * userAgents.length);
167
+ return userAgents[index];
168
+ }
153
169
  createNewClient() {
154
170
  this.jar = new tough_cookie_1.CookieJar();
155
171
  this.client = (0, axios_cookiejar_support_1.wrapper)(axios_1.default.create({
156
172
  jar: this.jar,
157
173
  headers: {
158
174
  'Content-Type': 'application/json',
159
- 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
175
+ 'User-Agent': this.getRandomUserAgent(),
160
176
  'Origin': 'https://www.bilibili.com',
161
177
  'Referer': 'https://www.bilibili.com/'
162
178
  }
@@ -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('测试图片生成')
@@ -854,11 +845,11 @@ class ComRegister {
854
845
  // 如果pic存在,则直接返回pic
855
846
  if (pic) {
856
847
  // pic存在,使用的是render模式
857
- await this.sendMsg(ctx, guildId, bot, pic + dUrl);
848
+ await this.sendMsg(ctx, guildId, bot, pic + (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: dUrl }));
858
849
  }
859
850
  else {
860
851
  // pic不存在,说明使用的是page模式
861
- await this.sendMsg(ctx, guildId, bot, koishi_1.h.image(buffer, 'image/png' + dUrl));
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] }));
862
853
  }
863
854
  // 更新时间点为最新发布动态的发布时间
864
855
  switch (num) {
@@ -906,27 +897,29 @@ class ComRegister {
906
897
  }
907
898
  }
908
899
  // 推送直播信息
909
- if (!liveStartMsg) {
900
+ // pic 存在,使用的是render模式
901
+ if (pic) {
902
+ let msg = (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [atAll && (0, jsx_runtime_1.jsx)("at", { type: "all" }), " ", liveStartMsg && liveStartMsg] });
903
+ return await this.sendMsg(ctx, guildId, bot, pic + msg);
904
+ }
905
+ // 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) {
910
908
  // pic 存在,使用的是render模式
911
- if (pic)
912
- return await this.sendMsg(ctx, guildId, bot, pic);
909
+ if (pic) return await this.sendMsg(ctx, guildId, bot, pic)
913
910
  // pic不存在,说明使用的是page模式
914
- await this.sendMsg(ctx, guildId, bot, koishi_1.h.image(buffer, 'image/png'));
915
- }
916
- else if (liveStartMsg && atAll) {
911
+ await this.sendMsg(ctx, guildId, bot, h.image(buffer, 'image/png'))
912
+ } else if (liveStartMsg && atAll) {
917
913
  // 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, " "] }));
914
+ if (pic) return await this.sendMsg(ctx, guildId, bot, pic + <><at type="all" /> {liveStartMsg} </>)
920
915
  // 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 {
916
+ await this.sendMsg(ctx, guildId, bot, <>{h.image(buffer, 'image/png')} <at type="all" /> {liveStartMsg}</>)
917
+ } else {
924
918
  // pic 存在,使用的是render模式
925
- if (pic)
926
- return await this.sendMsg(ctx, guildId, bot, pic + liveStartMsg);
919
+ if (pic) return await this.sendMsg(ctx, guildId, bot, pic + <>{liveStartMsg}</>)
927
920
  // pic不存在,说明使用的是page模式
928
- await this.sendMsg(ctx, guildId, bot, koishi_1.h.image(buffer, 'image/png' + liveStartMsg));
929
- }
921
+ await this.sendMsg(ctx, guildId, bot, h.image(buffer, 'image/png' + liveStartMsg))
922
+ } */
930
923
  };
931
924
  return async () => {
932
925
  try {
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.5",
4
+ "version": "1.2.7",
5
5
  "contributors": [
6
6
  "Akokko <admin@akokko.com>"
7
7
  ],
package/readme.md CHANGED
@@ -139,6 +139,8 @@
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,优化直播卡片推送逻辑
142
144
 
143
145
  ## 交流群
144
146