koishi-plugin-bilibili-notify 1.2.0-alpha.5 → 1.2.0-rc.1

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.
@@ -21,6 +21,7 @@ declare class ComRegister {
21
21
  qqguildBot: Bot<Context>;
22
22
  oneBot: Bot<Context>;
23
23
  redBot: Bot<Context>;
24
+ telegramBot: Bot<Context>;
24
25
  constructor(ctx: Context, config: ComRegister.Config);
25
26
  dynamicDetect(ctx: Context, bot: Bot<Context>, uid: string, guildId: Array<string>): () => Promise<void>;
26
27
  sendMsg(targets: Array<string>, bot: Bot<Context>, content: any): Promise<void>;
@@ -38,6 +39,8 @@ declare namespace ComRegister {
38
39
  liveStartAtAll: boolean;
39
40
  pushTime: number;
40
41
  liveLoopTime: number;
42
+ customLiveStart: string;
43
+ customLiveEnd: string;
41
44
  dynamicLoopTime: number;
42
45
  dynamicCheckNumber: number;
43
46
  }
@@ -29,6 +29,8 @@ class ComRegister {
29
29
  oneBot;
30
30
  // Red机器人
31
31
  redBot;
32
+ // Telegram机器人
33
+ telegramBot;
32
34
  constructor(ctx, config) {
33
35
  this.logger = ctx.logger('commandRegister');
34
36
  this.config = config;
@@ -44,7 +46,12 @@ class ComRegister {
44
46
  case 'onebot':
45
47
  this.oneBot = bot;
46
48
  break;
47
- case 'red': this.redBot = bot;
49
+ case 'red':
50
+ this.redBot = bot;
51
+ break;
52
+ case 'telegram':
53
+ this.telegramBot = bot;
54
+ break;
48
55
  }
49
56
  });
50
57
  // 从数据库获取订阅
@@ -293,6 +300,15 @@ class ComRegister {
293
300
  .example('bili sub 1194210119 目标QQ群号(实验性) -l -d 订阅UID为1194210119的UP主的动态和直播')
294
301
  .action(async ({ session, options }, mid, ...guildId) => {
295
302
  this.logger.info('调用bili.sub指令');
303
+ // 检查是否是不支持的平台
304
+ switch (session.event.platform) {
305
+ case 'red':
306
+ case 'onebot':
307
+ case 'telegram':
308
+ case 'qq':
309
+ case 'qqguild': break;
310
+ default: return '暂不支持该平台';
311
+ }
296
312
  // 检查是否登录
297
313
  if (!(await this.checkIfIsLogin(ctx))) {
298
314
  // 未登录直接返回
@@ -489,6 +505,9 @@ class ComRegister {
489
505
  case 'red':
490
506
  bot = this.redBot;
491
507
  break;
508
+ case 'telegram':
509
+ bot = this.telegramBot;
510
+ break;
492
511
  default: return '非法调用';
493
512
  }
494
513
  // 开始循环检测
@@ -530,6 +549,9 @@ class ComRegister {
530
549
  case 'red':
531
550
  bot = this.redBot;
532
551
  break;
552
+ case 'telegram':
553
+ bot = this.telegramBot;
554
+ break;
533
555
  default: return '非法调用';
534
556
  }
535
557
  // 开始循环检测
@@ -784,8 +806,12 @@ class ComRegister {
784
806
  open = false;
785
807
  // 下播了将定时器清零
786
808
  timer = 0;
809
+ // 定义下播通知消息
810
+ let liveEndMsg = this.config.customLiveEnd
811
+ .replace('-name', uData.info.uname)
812
+ .replace('-time', await ctx.gimg.getTimeDifference(liveTime));
787
813
  // 发送下播通知
788
- await this.sendMsg(guildId, bot, `${uData.info.uname}下播啦,本次直播了${await ctx.gimg.getTimeDifference(liveTime)}`);
814
+ await this.sendMsg(guildId, bot, liveEndMsg);
789
815
  }
790
816
  // 未进循环,还未开播,继续循环
791
817
  break;
@@ -816,12 +842,19 @@ class ComRegister {
816
842
  }
817
843
  // 主播信息不会变,开播时刷新一次即可
818
844
  uData = userData;
845
+ // 定义开播通知语
846
+ let liveStartMsg = this.config.customLiveStart
847
+ .replace('-name', uData.info.uname)
848
+ .replace('-time', await ctx.gimg.getTimeDifference(liveTime));
819
849
  // 发送直播通知卡片
820
850
  await sendLiveNotifyCard(data, uData, LiveType.StartBroadcasting);
821
851
  // 判断是否需要@全体成员
822
852
  if (this.config.liveStartAtAll) {
823
853
  // 发送@全体成员通知
824
- await this.sendMsg(guildId, bot, (0, jsx_runtime_1.jsx)("at", { type: "all" }));
854
+ await this.sendMsg(guildId, bot, (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("at", { type: "all" }), " ", liveStartMsg, " "] }));
855
+ }
856
+ else {
857
+ await this.sendMsg(guildId, bot, liveStartMsg);
825
858
  }
826
859
  }
827
860
  else { // 还在直播
@@ -920,9 +953,9 @@ class ComRegister {
920
953
  const subData = await ctx.database.get('bilibili', { id: { $gt: 0 } });
921
954
  // 设定订阅数量
922
955
  this.num = subData.length;
923
- // 如果订阅数量超过三个则被非法修改数据库
924
- // 在控制台提示重新订阅
956
+ // 如果订阅数量超过三个则数据库被非法修改
925
957
  if (!this.config.unlockSubLimits && this.num > 3) {
958
+ // 在控制台提示重新订阅
926
959
  ctx.notifier.create({
927
960
  type: 'danger',
928
961
  content: '您未解锁订阅限制,且订阅数大于3人,请您手动删除bilibili表中多余的数据后重启本插件'
@@ -954,6 +987,9 @@ class ComRegister {
954
987
  case 'red':
955
988
  bot = this.redBot;
956
989
  break;
990
+ case 'telegram':
991
+ bot = this.telegramBot;
992
+ break;
957
993
  default: {
958
994
  // 本条数据被篡改,删除该条订阅
959
995
  ctx.database.remove('bilibili', { id: sub.id });
@@ -1119,6 +1155,8 @@ class ComRegister {
1119
1155
  liveStartAtAll: koishi_1.Schema.boolean().required(),
1120
1156
  pushTime: koishi_1.Schema.number().required(),
1121
1157
  liveLoopTime: koishi_1.Schema.number().default(10),
1158
+ customLiveStart: koishi_1.Schema.string().required(),
1159
+ customLiveEnd: koishi_1.Schema.string().required(),
1122
1160
  dynamicLoopTime: koishi_1.Schema.number().default(60),
1123
1161
  dynamicCheckNumber: koishi_1.Schema.number().required()
1124
1162
  });
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;
package/lib/index.d.ts CHANGED
@@ -6,18 +6,22 @@ export interface Config {
6
6
  key: string;
7
7
  basicSettings: {};
8
8
  unlockSubLimits: boolean;
9
- liveStartAtAll: boolean;
10
- pushTime: number;
9
+ renderType: 'render' | 'page';
10
+ dynamic: {};
11
11
  dynamicCheckNumber: number;
12
12
  dynamicLoopTime: '1分钟' | '2分钟' | '3分钟' | '5分钟';
13
- renderType: 'render' | 'page';
14
- filter: {};
13
+ live: {};
14
+ pushTime: number;
15
+ liveStartAtAll: boolean;
16
+ customLiveStart: string;
17
+ customLiveEnd: string;
15
18
  style: {};
16
19
  removeBorder: boolean;
17
20
  cardColorStart: string;
18
21
  cardColorEnd: string;
19
22
  enableLargeFont: boolean;
20
23
  font: string;
24
+ filter: {};
21
25
  }
22
26
  export declare const Config: Schema<Config>;
23
27
  export declare function apply(ctx: Context, config: Config): void;
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'
@@ -49,15 +50,11 @@ exports.Config = koishi_1.Schema.object({
49
50
  unlockSubLimits: koishi_1.Schema.boolean()
50
51
  .default(false)
51
52
  .description('解锁3个订阅限制,默认只允许订阅3位UP主。订阅过多用户可能有导致IP暂时被封禁的风险'),
52
- liveStartAtAll: koishi_1.Schema.boolean()
53
- .default(false)
54
- .description('直播开始时艾特全体成员,默认关闭'),
55
- pushTime: koishi_1.Schema.number()
56
- .min(0)
57
- .max(12)
58
- .step(0.5)
59
- .default(1)
60
- .description('设定隔多长时间推送一次直播状态,单位为小时,默认为一小时'),
53
+ renderType: koishi_1.Schema.union(['render', 'page'])
54
+ .role('')
55
+ .default('render')
56
+ .description('渲染类型,默认为render模式,渲染速度更快,但会出现乱码问题,若出现乱码问题,请切换到page模式。若使用自定义字体,建议选择render模式'),
57
+ dynamic: koishi_1.Schema.object({}).description('动态推送设置'),
61
58
  dynamicCheckNumber: koishi_1.Schema.number()
62
59
  .min(2)
63
60
  .max(10)
@@ -69,10 +66,41 @@ exports.Config = koishi_1.Schema.object({
69
66
  .role('')
70
67
  .default('2分钟')
71
68
  .description('设定多久检测一次动态。若需动态的时效性,可以设置为1分钟。若订阅的UP主经常在短时间内连着发多条动态应该将该值提高,否则会出现动态漏推送和晚推送的问题,默认值为2分钟'),
72
- renderType: koishi_1.Schema.union(['render', 'page'])
73
- .role('')
74
- .default('render')
75
- .description('渲染类型,默认为render模式,渲染速度更快,但会出现乱码问题,若出现乱码问题,请切换到page模式。若使用自定义字体,建议选择render模式'),
69
+ live: koishi_1.Schema.object({}).description('直播推送设置'),
70
+ liveStartAtAll: koishi_1.Schema.boolean()
71
+ .default(false)
72
+ .description('直播开始时艾特全体成员,默认关闭'),
73
+ pushTime: koishi_1.Schema.number()
74
+ .min(0)
75
+ .max(12)
76
+ .step(0.5)
77
+ .default(1)
78
+ .description('设定隔多长时间推送一次直播状态,单位为小时,默认为一小时'),
79
+ customLiveStart: koishi_1.Schema.string()
80
+ .default('-name开播啦')
81
+ .experimental()
82
+ .description('自定义开播提示语,-name代表UP昵称。例如-name开播啦,会发送为xxxUP开播啦'),
83
+ customLiveEnd: koishi_1.Schema.string()
84
+ .default('-name下播啦,本次直播了-time')
85
+ .experimental()
86
+ .description('自定义下播提示语,-name代表UP昵称,-time代表开播时长。例如-name下播啦,本次直播了-time,会发送为xxxUP下播啦,直播时长为xx小时xx分钟xx秒'),
87
+ style: koishi_1.Schema.object({}).description('美化设置'),
88
+ removeBorder: koishi_1.Schema.boolean()
89
+ .default(false)
90
+ .description('移除推送卡片边框'),
91
+ cardColorStart: koishi_1.Schema.string()
92
+ .pattern(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/)
93
+ .default('#F38AB5')
94
+ .description('推送卡片的开始渐变背景色,请填入16进制颜色代码,参考网站:https://webkul.github.io/coolhue/'),
95
+ cardColorEnd: koishi_1.Schema.string()
96
+ .pattern(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/)
97
+ .default('#F9CCDF')
98
+ .description('推送卡片的结束渐变背景色,请填入16进制颜色代码,参考网站:https://colorate.azurewebsites.net/'),
99
+ enableLargeFont: koishi_1.Schema.boolean()
100
+ .default(false)
101
+ .description('是否开启动态推送卡片大字体模式,默认为小字体。小字体更漂亮,但阅读比较吃力,大字体更易阅读,但相对没这么好看'),
102
+ font: koishi_1.Schema.string()
103
+ .description('推送卡片的字体样式,如果你想用你自己的字体可以在此填写,例如:Microsoft YaHei'),
76
104
  filter: koishi_1.Schema.intersect([
77
105
  koishi_1.Schema.object({
78
106
  enable: koishi_1.Schema.boolean()
@@ -91,23 +119,6 @@ exports.Config = koishi_1.Schema.object({
91
119
  koishi_1.Schema.object({})
92
120
  ])
93
121
  ]),
94
- style: koishi_1.Schema.object({}).description('美化设置'),
95
- removeBorder: koishi_1.Schema.boolean()
96
- .default(false)
97
- .description('移除推送卡片边框'),
98
- cardColorStart: koishi_1.Schema.string()
99
- .pattern(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/)
100
- .default('#F38AB5')
101
- .description('推送卡片的开始渐变背景色,请填入16进制颜色代码,参考网站:https://webkul.github.io/coolhue/'),
102
- cardColorEnd: koishi_1.Schema.string()
103
- .pattern(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/)
104
- .default('#F9CCDF')
105
- .description('推送卡片的结束渐变背景色,请填入16进制颜色代码,参考网站:https://colorate.azurewebsites.net/'),
106
- enableLargeFont: koishi_1.Schema.boolean()
107
- .default(false)
108
- .description('是否开启动态推送卡片大字体模式,默认为小字体。小字体更漂亮,但阅读比较吃力,大字体更易阅读,但相对没这么好看'),
109
- font: koishi_1.Schema.string()
110
- .description('推送卡片的字体样式,如果你想用你自己的字体可以在此填写,例如:Microsoft YaHei')
111
122
  });
112
123
  function apply(ctx, config) {
113
124
  // 设置提示
@@ -168,6 +179,8 @@ function apply(ctx, config) {
168
179
  unlockSubLimits: config.unlockSubLimits,
169
180
  liveStartAtAll: config.liveStartAtAll,
170
181
  pushTime: config.pushTime,
182
+ customLiveStart: config.customLiveStart,
183
+ customLiveEnd: config.customLiveEnd,
171
184
  dynamicCheckNumber: config.dynamicCheckNumber,
172
185
  dynamicLoopTime
173
186
  });
@@ -181,4 +194,3 @@ function apply(ctx, config) {
181
194
  }
182
195
  });
183
196
  }
184
- 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.0-alpha.5",
4
+ "version": "1.2.0-rc.1",
5
5
  "contributors": [
6
6
  "Akokko <admin@akokko.com>"
7
7
  ],
@@ -24,7 +24,7 @@
24
24
  "bilibili"
25
25
  ],
26
26
  "peerDependencies": {
27
- "koishi": "^4.17.1"
27
+ "koishi": "^4.17.2"
28
28
  },
29
29
  "dependencies": {
30
30
  "axios": "^1.6.7",
package/readme.md CHANGED
@@ -1,4 +1,4 @@
1
- # Bilibili-Botify
1
+ # Bilibili-Notify
2
2
 
3
3
  基于 [koishi](../../../../koishijs/koishi) 框架的B站推送插件
4
4
 
@@ -10,6 +10,7 @@
10
10
  - [使用方法](#使用方法)
11
11
  - [注意事项](#注意事项)
12
12
  - [更新日志](#更新日志)
13
+ - [交流群](#交流群)
13
14
  - [感谢](#感谢)
14
15
  - [License](#License)
15
16
 
@@ -106,6 +107,11 @@
106
107
  - ver 1.2.0-alpha.3 修复了指定QQ群订阅时的一个bug
107
108
  - ver 1.2.0-alpha.4 对时间获取进行了优化,能够适应不同环境下的时间获取,修复了一些bug
108
109
  - ver 1.2.0-alpha.5 修复了与PostgreSQL不兼容的问题,优化了图片推送,增强了推送容错
110
+ - ver 1.2.0-rc.0 现已支持自定义开播和下播提示语(实验性)
111
+ - ver 1.2.0-rc.1 现已支持Telegram平台(实验性)
112
+
113
+ ## 交流群
114
+ 801338523 使用问题或bug都可以在群里提出
109
115
 
110
116
  ## 感谢
111
117