koishi-plugin-weibo-post-monitor 0.0.4 → 0.0.6
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 +46 -38
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -46,7 +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
|
+
blockwords: import_koishi.Schema.string().description("屏蔽词(多个屏蔽词用分号分隔)"),
|
|
50
50
|
keywords: import_koishi.Schema.string().description("关键词(多个关键词用分号分隔)"),
|
|
51
51
|
groupID: import_koishi.Schema.string().description("需要发送的群组"),
|
|
52
52
|
sendAll: import_koishi.Schema.boolean().default(false).description("@全体成员")
|
|
@@ -90,10 +90,22 @@ var getWeiboAndSendMessageToGroup = /* @__PURE__ */ __name(async (ctx, params) =
|
|
|
90
90
|
}
|
|
91
91
|
let message = result;
|
|
92
92
|
if (params.sendAll) {
|
|
93
|
-
message =
|
|
93
|
+
message = import_koishi.h.at("all") + " " + message;
|
|
94
94
|
}
|
|
95
|
-
|
|
95
|
+
console.log(message);
|
|
96
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");
|
|
97
109
|
var getMessage = /* @__PURE__ */ __name((params, wbPost) => {
|
|
98
110
|
if (!wbPost) {
|
|
99
111
|
return null;
|
|
@@ -116,8 +128,6 @@ var getMessage = /* @__PURE__ */ __name((params, wbPost) => {
|
|
|
116
128
|
weiboType = 1;
|
|
117
129
|
}
|
|
118
130
|
let message = "";
|
|
119
|
-
let keywordsList = params.keywords?.split(";") || [];
|
|
120
|
-
let blockwordsList = params.blockwords?.split(";") || [];
|
|
121
131
|
if (weiboType == 0) {
|
|
122
132
|
const pageInfo = wbPost?.page_info;
|
|
123
133
|
if (!pageInfo) {
|
|
@@ -140,35 +150,14 @@ var getMessage = /* @__PURE__ */ __name((params, wbPost) => {
|
|
|
140
150
|
const picIds = wbPost?.pic_ids || [];
|
|
141
151
|
const picInfos = wbPost?.pic_infos || {};
|
|
142
152
|
const firstPicUrl = picInfos?.[picIds[0]]?.large?.url || "";
|
|
143
|
-
const picture =
|
|
153
|
+
const picture = import_koishi.h.image(firstPicUrl);
|
|
144
154
|
message += screenName + " 发布了微博:\n" + text + "\n" + picture || "";
|
|
145
155
|
}
|
|
146
156
|
const mid = wbPost?.mid || "";
|
|
147
157
|
const url = `
|
|
148
158
|
链接:https://m.weibo.cn/status/${mid}`;
|
|
149
|
-
if (
|
|
150
|
-
|
|
151
|
-
for (const keyword of keywordsList) {
|
|
152
|
-
if (message.includes(keyword)) {
|
|
153
|
-
hasKeywords = true;
|
|
154
|
-
break;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
if (!hasKeywords) {
|
|
158
|
-
return null;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
if (blockwordsList.length > 0) {
|
|
162
|
-
let hasBlockwords = false;
|
|
163
|
-
for (const blockword of blockwordsList) {
|
|
164
|
-
if (message.includes(blockword)) {
|
|
165
|
-
hasBlockwords = true;
|
|
166
|
-
break;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
if (hasBlockwords) {
|
|
170
|
-
return null;
|
|
171
|
-
}
|
|
159
|
+
if (!checkWords(params, wbPost?.text_raw)) {
|
|
160
|
+
return null;
|
|
172
161
|
}
|
|
173
162
|
const wbpost = message ? message + url : screenName + " 发布了微博:\n" + wbPost?.text_raw + url || "";
|
|
174
163
|
return { post: wbpost, islast: true };
|
|
@@ -242,18 +231,37 @@ var parseDateString = /* @__PURE__ */ __name((dateString) => {
|
|
|
242
231
|
date.setUTCMinutes(date.getUTCMinutes() - timezoneOffset);
|
|
243
232
|
return date;
|
|
244
233
|
}, "parseDateString");
|
|
245
|
-
var
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
234
|
+
var checkWords = /* @__PURE__ */ __name((params, message) => {
|
|
235
|
+
if (message == null)
|
|
236
|
+
return false;
|
|
237
|
+
let keywordsList = params.keywords?.split(";") || [];
|
|
238
|
+
let blockwordsList = params.blockwords?.split(";") || [];
|
|
239
|
+
if (keywordsList.length > 0) {
|
|
240
|
+
let hasKeywords = false;
|
|
241
|
+
for (const keyword of keywordsList) {
|
|
242
|
+
if (message.includes(keyword)) {
|
|
243
|
+
hasKeywords = true;
|
|
244
|
+
break;
|
|
245
|
+
}
|
|
250
246
|
}
|
|
251
|
-
if (
|
|
252
|
-
return
|
|
247
|
+
if (!hasKeywords) {
|
|
248
|
+
return false;
|
|
253
249
|
}
|
|
254
250
|
}
|
|
255
|
-
|
|
256
|
-
|
|
251
|
+
if (blockwordsList.length > 0) {
|
|
252
|
+
let hasBlockwords = false;
|
|
253
|
+
for (const blockword of blockwordsList) {
|
|
254
|
+
if (message.includes(blockword)) {
|
|
255
|
+
hasBlockwords = true;
|
|
256
|
+
break;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
if (hasBlockwords) {
|
|
260
|
+
return false;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
return true;
|
|
264
|
+
}, "checkWords");
|
|
257
265
|
// Annotate the CommonJS export names for ESM import in node:
|
|
258
266
|
0 && (module.exports = {
|
|
259
267
|
Config,
|
package/package.json
CHANGED