koishi-plugin-weibo-post-monitor 1.0.1-beta.2 → 1.0.1-beta.4

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 +14 -14
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -356,13 +356,14 @@ async function getMessage(params, wbPost) {
356
356
  }
357
357
  const screenName = user?.screen_name || "";
358
358
  let weiboType = -1;
359
- if ("page_info" in wbPost) {
359
+ logger.info("wbPost = " + JSON.stringify(wbPost));
360
+ if (wbPost?.page_info) {
360
361
  weiboType = 0;
361
362
  }
362
- if ("pic_infos" in wbPost) {
363
+ if (wbPost?.pic_infos && wbPost?.pic_ids && wbPost.pic_ids.length > 0) {
363
364
  weiboType = 2;
364
365
  }
365
- if ("topic_struct" in wbPost || "retweeted_status" in wbPost) {
366
+ if (wbPost?.retweeted_status) {
366
367
  weiboType = 1;
367
368
  }
368
369
  let message_text = "";
@@ -371,7 +372,6 @@ async function getMessage(params, wbPost) {
371
372
  return null;
372
373
  }
373
374
  if (weiboType == 0) {
374
- logger.info("获取到类型 0-视频");
375
375
  const pageInfo = wbPost?.page_info;
376
376
  if (!pageInfo) {
377
377
  return null;
@@ -383,23 +383,21 @@ async function getMessage(params, wbPost) {
383
383
  }
384
384
  }
385
385
  if (weiboType == 1) {
386
- logger.info("获取到类型 1-转发微博");
387
386
  if (params.forward) {
388
387
  tempMessage += screenName + " 转发了微博:\n{temp_text}" || "";
389
388
  }
390
389
  }
391
390
  if (weiboType == 2) {
392
- logger.info("获取到类型 2-图文");
393
391
  const picIds = wbPost?.pic_ids || [];
394
392
  const picInfos = wbPost?.pic_infos || {};
395
393
  const firstPicUrl = picInfos?.[picIds[0]]?.large?.url || "";
396
394
  const picture = import_koishi2.h.image(firstPicUrl);
397
395
  tempMessage += screenName + " 发布了微博:\n{temp_text}\n" + picture || "";
398
396
  }
399
- logger.info("weiboType = " + weiboType);
400
397
  const mid = wbPost?.mid || "";
401
398
  const url = `https://m.weibo.cn/status/${mid}`;
402
399
  const detailMessage = await getDetailMessage(url);
400
+ logger.info("detailMessage = " + detailMessage);
403
401
  if (detailMessage) {
404
402
  message_text = detailMessage;
405
403
  } else {
@@ -446,16 +444,17 @@ function stripHtmlTags(html) {
446
444
  __name(stripHtmlTags, "stripHtmlTags");
447
445
  async function getDetailMessage(wb_url) {
448
446
  try {
449
- const cookie = getCookie();
450
- const userAgent = getUserAgent();
451
- if (!cookie) {
447
+ let auto_cookie2 = getCookie();
448
+ let now_user_agent2 = getUserAgent();
449
+ if (!auto_cookie2) {
452
450
  return null;
453
451
  }
454
452
  const headers = {
455
- "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
456
- "accept-language": "zh-CN,zh;q=0.9",
457
- "user-agent": userAgent || "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36",
458
- "cookie": cookie
453
+ "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
454
+ "accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
455
+ "cache-control": "no-cache",
456
+ "user-agent": now_user_agent2,
457
+ "cookie": auto_cookie2
459
458
  };
460
459
  const response = await import_axios2.default.get(wb_url, {
461
460
  headers,
@@ -487,6 +486,7 @@ async function getDetailMessage(wb_url) {
487
486
  const context = (0, import_vm.createContext)({});
488
487
  (0, import_vm.runInContext)(code, context);
489
488
  const renderData = context.$render_data;
489
+ logger.info("renderData = " + JSON.stringify(renderData));
490
490
  if (!renderData || !renderData.status || !renderData.status.text) {
491
491
  return null;
492
492
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-weibo-post-monitor",
3
3
  "description": "微博帖子更新推送插件,用于获取指定微博用户的最新帖子推送到指定群聊,参考代码https://github.com/moehuhu/weibo-monitor",
4
- "version": "1.0.1-beta.2",
4
+ "version": "1.0.1-beta.4",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [