koishi-plugin-weibo-post-monitor 0.0.3 → 0.0.5
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.js +43 -23
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -46,6 +46,7 @@ var Config = import_koishi.Schema.object({
|
|
|
46
46
|
sendINFO: import_koishi.Schema.array(import_koishi.Schema.object({
|
|
47
47
|
weiboUID: import_koishi.Schema.string().description("微博用户UID"),
|
|
48
48
|
forward: import_koishi.Schema.boolean().default(false).description("是否监听转发"),
|
|
49
|
+
blockwords: import_koishi.Schema.string().description("屏蔽词(多个屏蔽词用分号分隔)"),
|
|
49
50
|
keywords: import_koishi.Schema.string().description("关键词(多个关键词用分号分隔)"),
|
|
50
51
|
groupID: import_koishi.Schema.string().description("需要发送的群组"),
|
|
51
52
|
sendAll: import_koishi.Schema.boolean().default(false).description("@全体成员")
|
|
@@ -89,10 +90,22 @@ var getWeiboAndSendMessageToGroup = /* @__PURE__ */ __name(async (ctx, params) =
|
|
|
89
90
|
}
|
|
90
91
|
let message = result;
|
|
91
92
|
if (params.sendAll) {
|
|
92
|
-
message =
|
|
93
|
+
message = import_koishi.h.at("all") + " " + message;
|
|
93
94
|
}
|
|
94
95
|
ctx.bots[`${params.plantform}:${params.account}`].sendMessage(params.groupID, message);
|
|
95
96
|
}, "getWeiboAndSendMessageToGroup");
|
|
97
|
+
var getLastPost = /* @__PURE__ */ __name((params, weiboList) => {
|
|
98
|
+
for (const wb_element of weiboList) {
|
|
99
|
+
const result = getMessage(params, wb_element);
|
|
100
|
+
if (!result) {
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
if (result.islast) {
|
|
104
|
+
return result.post;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return null;
|
|
108
|
+
}, "getLastPost");
|
|
96
109
|
var getMessage = /* @__PURE__ */ __name((params, wbPost) => {
|
|
97
110
|
if (!wbPost) {
|
|
98
111
|
return null;
|
|
@@ -115,7 +128,6 @@ var getMessage = /* @__PURE__ */ __name((params, wbPost) => {
|
|
|
115
128
|
weiboType = 1;
|
|
116
129
|
}
|
|
117
130
|
let message = "";
|
|
118
|
-
let keywordsList = params.keywords?.split(";") || [];
|
|
119
131
|
if (weiboType == 0) {
|
|
120
132
|
const pageInfo = wbPost?.page_info;
|
|
121
133
|
if (!pageInfo) {
|
|
@@ -138,23 +150,14 @@ var getMessage = /* @__PURE__ */ __name((params, wbPost) => {
|
|
|
138
150
|
const picIds = wbPost?.pic_ids || [];
|
|
139
151
|
const picInfos = wbPost?.pic_infos || {};
|
|
140
152
|
const firstPicUrl = picInfos?.[picIds[0]]?.large?.url || "";
|
|
141
|
-
const picture =
|
|
153
|
+
const picture = import_koishi.h.image(firstPicUrl);
|
|
142
154
|
message += screenName + " 发布了微博:\n" + text + "\n" + picture || "";
|
|
143
155
|
}
|
|
144
156
|
const mid = wbPost?.mid || "";
|
|
145
157
|
const url = `
|
|
146
158
|
链接:https://m.weibo.cn/status/${mid}`;
|
|
147
|
-
if (
|
|
148
|
-
|
|
149
|
-
for (const keyword of keywordsList) {
|
|
150
|
-
if (message.includes(keyword)) {
|
|
151
|
-
hasKeywords = true;
|
|
152
|
-
break;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
if (!hasKeywords) {
|
|
156
|
-
return null;
|
|
157
|
-
}
|
|
159
|
+
if (!checkWords(params, message)) {
|
|
160
|
+
return null;
|
|
158
161
|
}
|
|
159
162
|
const wbpost = message ? message + url : screenName + " 发布了微博:\n" + wbPost?.text_raw + url || "";
|
|
160
163
|
return { post: wbpost, islast: true };
|
|
@@ -228,18 +231,35 @@ var parseDateString = /* @__PURE__ */ __name((dateString) => {
|
|
|
228
231
|
date.setUTCMinutes(date.getUTCMinutes() - timezoneOffset);
|
|
229
232
|
return date;
|
|
230
233
|
}, "parseDateString");
|
|
231
|
-
var
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
234
|
+
var checkWords = /* @__PURE__ */ __name((params, message) => {
|
|
235
|
+
let keywordsList = params.keywords?.split(";") || [];
|
|
236
|
+
let blockwordsList = params.blockwords?.split(";") || [];
|
|
237
|
+
if (keywordsList.length > 0) {
|
|
238
|
+
let hasKeywords = false;
|
|
239
|
+
for (const keyword of keywordsList) {
|
|
240
|
+
if (message.includes(keyword)) {
|
|
241
|
+
hasKeywords = true;
|
|
242
|
+
break;
|
|
243
|
+
}
|
|
236
244
|
}
|
|
237
|
-
if (
|
|
238
|
-
return
|
|
245
|
+
if (!hasKeywords) {
|
|
246
|
+
return false;
|
|
239
247
|
}
|
|
240
248
|
}
|
|
241
|
-
|
|
242
|
-
|
|
249
|
+
if (blockwordsList.length > 0) {
|
|
250
|
+
let hasBlockwords = false;
|
|
251
|
+
for (const blockword of blockwordsList) {
|
|
252
|
+
if (message.includes(blockword)) {
|
|
253
|
+
hasBlockwords = true;
|
|
254
|
+
break;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
if (hasBlockwords) {
|
|
258
|
+
return false;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
return true;
|
|
262
|
+
}, "checkWords");
|
|
243
263
|
// Annotate the CommonJS export names for ESM import in node:
|
|
244
264
|
0 && (module.exports = {
|
|
245
265
|
Config,
|
package/package.json
CHANGED