koishi-plugin-bilibili-videolink-analysis 1.0.0 → 1.0.2

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.
Files changed (2) hide show
  1. package/lib/index.js +23 -15
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -128,7 +128,7 @@ function apply(ctx, config) {
128
128
  });
129
129
 
130
130
  ctx.command('B站点播')
131
- ctx.command('退出登录', '退出B站账号')
131
+ ctx.command('B站点播/退出登录', '退出B站账号')
132
132
  .action(async ({ session }) => {
133
133
  const page = await ctx.puppeteer.page();
134
134
  await page.goto('https://www.bilibili.com/', { waitUntil: 'networkidle2' });
@@ -138,7 +138,8 @@ function apply(ctx, config) {
138
138
 
139
139
  if (!isLoggedIn) {
140
140
  await page.close();
141
- return '您尚未登录。';
141
+ await session.send(h.text('您尚未登录。'))
142
+ return;
142
143
  }
143
144
 
144
145
  const avatarLinkSelector = '.header-entry-mini';
@@ -147,23 +148,26 @@ function apply(ctx, config) {
147
148
  try {
148
149
  const avatarElement = await page.$(avatarLinkSelector);
149
150
  if (avatarElement) {
150
- await avatarElement.hover();
151
- await page.waitForSelector(logoutButtonSelector, { visible: true });
151
+ await avatarElement.hover();
152
+ await page.waitForSelector(logoutButtonSelector, { visible: true });
152
153
 
153
154
  await page.click(logoutButtonSelector);
154
155
 
155
156
  await new Promise(resolve => setTimeout(resolve, 1000));
156
157
 
157
158
  await page.close();
158
- return '已成功退出登录。';
159
+ await session.send(h.text('已成功退出登录。'))
160
+ return;
159
161
  } else {
160
162
  await page.close();
161
- return '找不到用户头像,无法退出登录。';
163
+ await session.send(h.text('找不到用户头像,无法退出登录。'))
164
+ return;
162
165
  }
163
166
  } catch (error) {
164
167
  await page.close();
165
- console.error('Error during logout:', error);
166
- return '退出登录时出错。';
168
+ logger.error('Error during logout:', error);
169
+ await session.send(h.text('退出登录时出错。'))
170
+ return;
167
171
  }
168
172
  });
169
173
 
@@ -178,7 +182,8 @@ function apply(ctx, config) {
178
182
 
179
183
  if (isLoggedIn) {
180
184
  await page.close();
181
- return '您已经登录了。';
185
+ await session.send(h.text('您已经登录了。'))
186
+ return;
182
187
  }
183
188
 
184
189
  await page.click(loginButtonSelector);
@@ -206,8 +211,8 @@ function apply(ctx, config) {
206
211
  }
207
212
 
208
213
  await page.close();
209
-
210
- return loginSuccessful ? '登录成功!' : '登录失败,请重试。';
214
+ await session.send(h.text(loginSuccessful ? '登录成功!' : '登录失败,请重试。'))
215
+ return;
211
216
  });
212
217
 
213
218
  if (config.loggerinfo) {
@@ -326,7 +331,8 @@ function apply(ctx, config) {
326
331
  .action(async ({ options, session }, keyword) => {
327
332
  if (!keyword) {
328
333
  await session.execute('点播 -h')
329
- return '没输入点播内容'
334
+ await session.send(h.text('没输入点播内容'))
335
+ return
330
336
  }
331
337
 
332
338
 
@@ -399,7 +405,8 @@ display: none !important;
399
405
 
400
406
  if (videos.length === 0) {
401
407
  await page.close()
402
- return '未找到相关视频。'
408
+ await session.send(h.text('未找到相关视频。'))
409
+ return
403
410
  }
404
411
 
405
412
  // 动态调整窗口大小以适应视频数量
@@ -430,7 +437,8 @@ display: none !important;
430
437
  const userChoice = await session.prompt(config.timeout * 1000)
431
438
  const choiceIndex = parseInt(userChoice) - 1
432
439
  if (isNaN(choiceIndex) || choiceIndex < 0 || choiceIndex >= videos.length) {
433
- return '输入无效,请输入正确的序号。'
440
+ await session.send(h.text('输入无效,请输入正确的序号。'))
441
+ return
434
442
  }
435
443
 
436
444
  // 返回用户选择的视频ID
@@ -586,7 +594,7 @@ display: none !important;
586
594
  }
587
595
 
588
596
  if (config.loggerinfo) {
589
- logger.info(`视频信息内容:\n ${JSON.stringify(mediaData)}`);
597
+ //logger.info(`视频信息内容:\n ${JSON.stringify(mediaData)}`);
590
598
  logger.info(`机器人发送完整消息为:\n ${ret}`);
591
599
  }
592
600
  return;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "koishi-plugin-bilibili-videolink-analysis",
3
3
  "description": "[<ruby>Bilibili视频解析<rp>(</rp><rt>点我查看食用方法</rt><rp>)</rp></ruby>](https://www.npmjs.com/package/koishi-plugin-bilibili-videolink-analysis)解析B站链接(支持小程序卡片)支持搜索点播功能!灵感来自完美的 [bili-parser](/market?keyword=bili-parser) !",
4
4
  "license": "MIT",
5
- "version": "1.0.0",
5
+ "version": "1.0.2",
6
6
  "main": "lib/index.js",
7
7
  "typings": "lib/index.d.ts",
8
8
  "files": [