koishi-plugin-weibo-post-monitor 1.0.1-beta.0 → 1.0.1-beta.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.
- package/lib/index.d.ts +2 -1
- package/lib/index.js +13 -3
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Context } from 'koishi';
|
|
1
|
+
import { Context, Logger } from 'koishi';
|
|
2
2
|
import { Config, type Config as ConfigType } from './services/config';
|
|
3
3
|
export declare const name = "weibo-post-monitor";
|
|
4
4
|
export { Config };
|
|
5
|
+
export declare let logger: Logger;
|
|
5
6
|
export declare function apply(ctx: Context, config: ConfigType): void;
|
package/lib/index.js
CHANGED
|
@@ -32,9 +32,11 @@ var src_exports = {};
|
|
|
32
32
|
__export(src_exports, {
|
|
33
33
|
Config: () => Config,
|
|
34
34
|
apply: () => apply,
|
|
35
|
+
logger: () => logger,
|
|
35
36
|
name: () => name
|
|
36
37
|
});
|
|
37
38
|
module.exports = __toCommonJS(src_exports);
|
|
39
|
+
var import_koishi3 = require("koishi");
|
|
38
40
|
|
|
39
41
|
// src/services/config.ts
|
|
40
42
|
var import_koishi = require("koishi");
|
|
@@ -327,7 +329,6 @@ async function getWeiboAndSendMessageToGroup(ctx, params) {
|
|
|
327
329
|
message = import_koishi2.h.at("all") + " " + message;
|
|
328
330
|
}
|
|
329
331
|
ctx.bots[`${params.plantform}:${params.account}`].sendMessage(params.groupID, message);
|
|
330
|
-
console.log(message);
|
|
331
332
|
}
|
|
332
333
|
__name(getWeiboAndSendMessageToGroup, "getWeiboAndSendMessageToGroup");
|
|
333
334
|
async function getLastPost(params, weiboList) {
|
|
@@ -350,6 +351,9 @@ async function getMessage(params, wbPost) {
|
|
|
350
351
|
const { created_at, user } = wbPost;
|
|
351
352
|
const time = parseDateString(created_at);
|
|
352
353
|
const lastCheckTime = Date.now() - (params.waitMinutes > 0 ? params.waitMinutes * 60 * 1e3 : 6e4);
|
|
354
|
+
if (time.getTime() < lastCheckTime) {
|
|
355
|
+
return null;
|
|
356
|
+
}
|
|
353
357
|
const screenName = user?.screen_name || "";
|
|
354
358
|
let weiboType = -1;
|
|
355
359
|
if ("page_info" in wbPost) {
|
|
@@ -367,35 +371,39 @@ async function getMessage(params, wbPost) {
|
|
|
367
371
|
return null;
|
|
368
372
|
}
|
|
369
373
|
if (weiboType == 0) {
|
|
374
|
+
logger.info("获取到类型 0-视频");
|
|
370
375
|
const pageInfo = wbPost?.page_info;
|
|
371
376
|
if (!pageInfo) {
|
|
372
377
|
return null;
|
|
373
378
|
}
|
|
374
379
|
const objType = pageInfo?.object_type || "";
|
|
375
380
|
if (objType == "video") {
|
|
376
|
-
const text = wbPost?.text_raw || "";
|
|
377
381
|
const video = pageInfo?.media_info?.h5_url || "";
|
|
378
382
|
tempMessage += screenName + " 发布了微博:\n{temp_text}\n" + video || "";
|
|
379
383
|
}
|
|
380
384
|
}
|
|
381
385
|
if (weiboType == 1) {
|
|
386
|
+
logger.info("获取到类型 1-转发微博");
|
|
382
387
|
if (params.forward) {
|
|
383
388
|
tempMessage += screenName + " 转发了微博:\n{temp_text}" || "";
|
|
384
389
|
}
|
|
385
390
|
}
|
|
386
391
|
if (weiboType == 2) {
|
|
387
|
-
|
|
392
|
+
logger.info("获取到类型 2-图文");
|
|
388
393
|
const picIds = wbPost?.pic_ids || [];
|
|
389
394
|
const picInfos = wbPost?.pic_infos || {};
|
|
390
395
|
const firstPicUrl = picInfos?.[picIds[0]]?.large?.url || "";
|
|
391
396
|
const picture = import_koishi2.h.image(firstPicUrl);
|
|
392
397
|
tempMessage += screenName + " 发布了微博:\n{temp_text}\n" + picture || "";
|
|
393
398
|
}
|
|
399
|
+
logger.info("weiboType = " + weiboType);
|
|
394
400
|
const mid = wbPost?.mid || "";
|
|
395
401
|
const url = `https://m.weibo.cn/status/${mid}`;
|
|
396
402
|
const detailMessage = await getDetailMessage(url);
|
|
397
403
|
if (detailMessage) {
|
|
398
404
|
message_text = detailMessage;
|
|
405
|
+
} else {
|
|
406
|
+
message_text = wbPost?.text_raw;
|
|
399
407
|
}
|
|
400
408
|
const urlMessage = `
|
|
401
409
|
微博链接:${url}`;
|
|
@@ -494,6 +502,7 @@ __name(getDetailMessage, "getDetailMessage");
|
|
|
494
502
|
|
|
495
503
|
// src/index.ts
|
|
496
504
|
var name = "weibo-post-monitor";
|
|
505
|
+
var logger = new import_koishi3.Logger(name);
|
|
497
506
|
function apply(ctx, config) {
|
|
498
507
|
const commonConfig = {
|
|
499
508
|
account: config.account,
|
|
@@ -515,5 +524,6 @@ __name(apply, "apply");
|
|
|
515
524
|
0 && (module.exports = {
|
|
516
525
|
Config,
|
|
517
526
|
apply,
|
|
527
|
+
logger,
|
|
518
528
|
name
|
|
519
529
|
});
|
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.
|
|
4
|
+
"version": "1.0.1-beta.2",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"files": [
|