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