koishi-plugin-wordpress-notifier 2.9.0 → 2.9.3
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/README.md +263 -748
- package/lib/commands.d.ts +16 -0
- package/lib/commands.js +325 -0
- package/lib/index.d.ts +21 -95
- package/lib/index.js +129 -1948
- package/lib/push.d.ts +32 -0
- package/lib/push.js +346 -0
- package/lib/schedule.d.ts +32 -0
- package/lib/schedule.js +328 -0
- package/lib/storage.d.ts +65 -0
- package/lib/storage.js +361 -0
- package/lib/wordpress.d.ts +128 -0
- package/lib/wordpress.js +492 -0
- package/package.json +40 -46
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Context } from 'koishi';
|
|
2
|
+
import { Config } from './index';
|
|
3
|
+
import { WordPressService } from './wordpress';
|
|
4
|
+
import { StorageService } from './storage';
|
|
5
|
+
import { ScheduleService } from './schedule';
|
|
6
|
+
export declare class CommandService {
|
|
7
|
+
private ctx;
|
|
8
|
+
private config;
|
|
9
|
+
private wordpressService;
|
|
10
|
+
private storageService;
|
|
11
|
+
private scheduleService;
|
|
12
|
+
constructor(ctx: Context, config: Config, wordpressService: WordPressService, storageService: StorageService, scheduleService: ScheduleService);
|
|
13
|
+
private isSuperAdmin;
|
|
14
|
+
private isAdmin;
|
|
15
|
+
private initCommands;
|
|
16
|
+
}
|
package/lib/commands.js
ADDED
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CommandService = void 0;
|
|
4
|
+
// WordPress 推送插件命令系统 - 全新设计
|
|
5
|
+
class CommandService {
|
|
6
|
+
constructor(ctx, config, wordpressService, storageService, scheduleService) {
|
|
7
|
+
this.ctx = ctx;
|
|
8
|
+
this.config = config;
|
|
9
|
+
this.wordpressService = wordpressService;
|
|
10
|
+
this.storageService = storageService;
|
|
11
|
+
this.scheduleService = scheduleService;
|
|
12
|
+
// 添加调试:确认服务已注入
|
|
13
|
+
if (!this.scheduleService) {
|
|
14
|
+
this.ctx.logger.error('致命错误: ScheduleService 未注入!');
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
this.ctx.logger.info('CommandService 初始化成功,ScheduleService 已就绪');
|
|
18
|
+
}
|
|
19
|
+
this.initCommands();
|
|
20
|
+
}
|
|
21
|
+
// 检查用户是否为超级管理员
|
|
22
|
+
isSuperAdmin(userId) {
|
|
23
|
+
return this.config.superAdminUserIds?.includes(userId) || false;
|
|
24
|
+
}
|
|
25
|
+
// 检查用户是否为管理员(超级管理员或拥有足够权限)
|
|
26
|
+
isAdmin(session) {
|
|
27
|
+
const userId = session?.userId;
|
|
28
|
+
if (!userId)
|
|
29
|
+
return false;
|
|
30
|
+
// 优先检查超级管理员
|
|
31
|
+
if (this.isSuperAdmin(userId)) {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
// 然后检查权限等级
|
|
35
|
+
return session?.user?.authority >= 3;
|
|
36
|
+
}
|
|
37
|
+
initCommands() {
|
|
38
|
+
// 直接注册所有命令为独立命令,使用 wp-xxx 格式
|
|
39
|
+
// 查看最新文章
|
|
40
|
+
this.ctx.command('wp-news [count]', '查看最新文章 (默认5篇)')
|
|
41
|
+
.action(async (argv, count) => {
|
|
42
|
+
try {
|
|
43
|
+
const articleCount = Math.min(parseInt(count || '5') || 5, 20);
|
|
44
|
+
const articles = await this.wordpressService.getLatestPosts(articleCount);
|
|
45
|
+
if (!articles || articles.length === 0) {
|
|
46
|
+
return '📭 暂无最新文章';
|
|
47
|
+
}
|
|
48
|
+
let message = '📰 最新文章\n\n';
|
|
49
|
+
articles.forEach((article, index) => {
|
|
50
|
+
const title = article.title?.rendered || '无标题';
|
|
51
|
+
const date = new Date(article.date).toLocaleDateString('zh-CN');
|
|
52
|
+
const link = article.link || this.config.wordpressUrl;
|
|
53
|
+
const author = article.author_name || '未知作者';
|
|
54
|
+
message += `${index + 1}. ${title}\n👤 ${author} | 📅 ${date}\n🔗 ${link}\n\n`;
|
|
55
|
+
});
|
|
56
|
+
return message;
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
this.ctx.logger.error('获取最新文章失败:', error);
|
|
60
|
+
return `❌ 获取最新文章失败:${error instanceof Error ? error.message : '未知错误'}`;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
// 浏览文章列表
|
|
64
|
+
this.ctx.command('wp-list [page]', '浏览文章列表 (每页10篇)')
|
|
65
|
+
.action(async (argv, page) => {
|
|
66
|
+
try {
|
|
67
|
+
const pageNum = Math.max(1, parseInt(page || '1') || 1);
|
|
68
|
+
const perPage = 10;
|
|
69
|
+
const articles = await this.wordpressService.getLatestPosts(perPage, pageNum);
|
|
70
|
+
if (!articles || articles.length === 0) {
|
|
71
|
+
return '📭 暂无文章';
|
|
72
|
+
}
|
|
73
|
+
let message = `📋 文章列表 (第 ${pageNum} 页)\n\n`;
|
|
74
|
+
articles.forEach((article, index) => {
|
|
75
|
+
const title = article.title?.rendered || '无标题';
|
|
76
|
+
const date = new Date(article.date).toLocaleDateString('zh-CN');
|
|
77
|
+
const link = article.link || this.config.wordpressUrl;
|
|
78
|
+
const author = article.author_name || '未知作者';
|
|
79
|
+
message += `${index + 1}. ${title}\n👤 ${author} | 📅 ${date}\n🔗 ${link}\n\n`;
|
|
80
|
+
});
|
|
81
|
+
return message;
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
this.ctx.logger.error('获取文章列表失败:', error);
|
|
85
|
+
return `❌ 获取文章列表失败:${error instanceof Error ? error.message : '未知错误'}`;
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
// 查看文章详情
|
|
89
|
+
this.ctx.command('wp-post <id>', '查看指定文章详情')
|
|
90
|
+
.action(async (argv, id) => {
|
|
91
|
+
try {
|
|
92
|
+
const articleId = parseInt(id);
|
|
93
|
+
if (isNaN(articleId) || articleId <= 0) {
|
|
94
|
+
return '❌ 请输入有效的文章 ID';
|
|
95
|
+
}
|
|
96
|
+
const article = await this.wordpressService.getPostById(articleId);
|
|
97
|
+
if (!article) {
|
|
98
|
+
return '📭 文章不存在';
|
|
99
|
+
}
|
|
100
|
+
const title = article.title?.rendered || '无标题';
|
|
101
|
+
const author = article.author_name || '未知作者';
|
|
102
|
+
const date = new Date(article.date).toLocaleString('zh-CN');
|
|
103
|
+
const content = article.content?.rendered || '无内容';
|
|
104
|
+
const link = article.link || this.config.wordpressUrl;
|
|
105
|
+
const plainContent = content.replace(/<[^>]+>/g, '').trim();
|
|
106
|
+
const displayContent = plainContent.length > 500 ? plainContent.substring(0, 500) + '...' : plainContent;
|
|
107
|
+
return `📄 文章详情\n\n` +
|
|
108
|
+
`🎯 标题:${title}\n` +
|
|
109
|
+
`👤 作者:${author}\n` +
|
|
110
|
+
`📅 时间:${date}\n\n` +
|
|
111
|
+
`📝 内容:${displayContent}\n\n` +
|
|
112
|
+
`🔗 阅读全文:${link}`;
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
this.ctx.logger.error(`获取文章详情失败:`, error);
|
|
116
|
+
return `❌ 获取文章详情失败:${error instanceof Error ? error.message : '未知错误'}`;
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
// 控制推送开关(管理员)
|
|
120
|
+
this.ctx.command('wp-push [status]', '控制群推送开关 (仅管理员)')
|
|
121
|
+
.userFields(['authority'])
|
|
122
|
+
.action(async (argv, status) => {
|
|
123
|
+
try {
|
|
124
|
+
const session = argv.session;
|
|
125
|
+
if (!this.isAdmin(session)) {
|
|
126
|
+
return '❌ 权限不足,需要管理员权限';
|
|
127
|
+
}
|
|
128
|
+
const groupId = session.channelId || 'global';
|
|
129
|
+
const pushConfig = await this.storageService.getPushConfig(groupId);
|
|
130
|
+
const currentStatus = pushConfig?.enabled || false;
|
|
131
|
+
if (!status) {
|
|
132
|
+
return `📡 当前推送状态:${currentStatus ? '开启' : '关闭'}`;
|
|
133
|
+
}
|
|
134
|
+
const newStatus = status === 'on' ? true : status === 'off' ? false : !currentStatus;
|
|
135
|
+
if (newStatus === currentStatus) {
|
|
136
|
+
return `📡 推送状态未变化:${currentStatus ? '开启' : '关闭'}`;
|
|
137
|
+
}
|
|
138
|
+
await this.storageService.setPushConfig({
|
|
139
|
+
groupId,
|
|
140
|
+
enabled: newStatus,
|
|
141
|
+
enableUpdatePush: pushConfig?.enableUpdatePush || true,
|
|
142
|
+
enableAtAll: pushConfig?.enableAtAll || false,
|
|
143
|
+
lastPushTime: new Date()
|
|
144
|
+
});
|
|
145
|
+
return `📡 推送开关已${newStatus ? '开启' : '关闭'}`;
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
this.ctx.logger.error('控制推送开关失败:', error);
|
|
149
|
+
return `❌ 操作失败:${error instanceof Error ? error.message : '未知错误'}`;
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
// 管理个人订阅
|
|
153
|
+
this.ctx.command('wp-sub [status]', '管理个人推送订阅')
|
|
154
|
+
.action(async (argv, status) => {
|
|
155
|
+
try {
|
|
156
|
+
const session = argv.session;
|
|
157
|
+
if (!session?.userId) {
|
|
158
|
+
return '❌ 请在私聊或群聊中使用此命令';
|
|
159
|
+
}
|
|
160
|
+
const userId = session.userId;
|
|
161
|
+
const groupId = session.channelId || 'private';
|
|
162
|
+
const currentStatus = await this.storageService.isUserSubscribed(userId, groupId);
|
|
163
|
+
if (!status) {
|
|
164
|
+
return `🔔 当前订阅状态:${currentStatus ? '开启' : '关闭'}`;
|
|
165
|
+
}
|
|
166
|
+
const newStatus = status === 'on' ? true : status === 'off' ? false : !currentStatus;
|
|
167
|
+
if (newStatus === currentStatus) {
|
|
168
|
+
return `🔔 订阅状态未变化:${currentStatus ? '开启' : '关闭'}`;
|
|
169
|
+
}
|
|
170
|
+
await this.storageService.setUserSubscription(userId, groupId, newStatus);
|
|
171
|
+
return `🔔 订阅状态已${newStatus ? '开启' : '关闭'}`;
|
|
172
|
+
}
|
|
173
|
+
catch (error) {
|
|
174
|
+
this.ctx.logger.error('管理订阅失败:', error);
|
|
175
|
+
return `❌ 操作失败:${error instanceof Error ? error.message : '未知错误'}`;
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
// 手动检查推送(管理员)
|
|
179
|
+
this.ctx.command('wp-check', '手动触发一次推送检查 (仅管理员)')
|
|
180
|
+
.userFields(['authority'])
|
|
181
|
+
.action(async (argv) => {
|
|
182
|
+
try {
|
|
183
|
+
const session = argv.session;
|
|
184
|
+
// 1. 再次确认权限 (防御性编程)
|
|
185
|
+
if (!this.isAdmin(session)) {
|
|
186
|
+
this.ctx.logger.warn(`用户 ${session?.userId} 权限不足,尝试执行 wp-check`);
|
|
187
|
+
return '❌ 权限不足,需要管理员权限';
|
|
188
|
+
}
|
|
189
|
+
this.ctx.logger.info(`用户 ${session.userId} 手动触发推送检查`);
|
|
190
|
+
// 2. 执行检查
|
|
191
|
+
await this.scheduleService.triggerCheck();
|
|
192
|
+
// 3. 返回明确的成功消息,不要返回 undefined 或空
|
|
193
|
+
return '🔄 已触发推送检查\n\n' +
|
|
194
|
+
'⏰ 检查过程可能需要几分钟\n' +
|
|
195
|
+
'⚠️ 请勿重复触发,避免推送风暴\n' +
|
|
196
|
+
'📢 检查结果将通过群聊通知';
|
|
197
|
+
}
|
|
198
|
+
catch (error) {
|
|
199
|
+
this.ctx.logger.error('手动检查推送内部错误:', error);
|
|
200
|
+
return `❌ 触发检查时发生内部错误:${error instanceof Error ? error.message : '未知错误'}`;
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
// 查看详细帮助
|
|
204
|
+
this.ctx.command('wp-help', '查看详细使用说明')
|
|
205
|
+
.action(() => {
|
|
206
|
+
return '📖 WordPress 推送插件帮助\n\n' +
|
|
207
|
+
'【文章相关】\n' +
|
|
208
|
+
'wp-news [数量] 查看最新文章 (默认5篇)\n' +
|
|
209
|
+
'wp-list [页码] 浏览文章列表 (每页10篇)\n' +
|
|
210
|
+
'wp-post <ID> 查看指定文章详情\n\n' +
|
|
211
|
+
'【推送管理】\n' +
|
|
212
|
+
'wp-push [on|off] 控制群推送开关 (管理员)\n' +
|
|
213
|
+
'wp-sub [on|off] 管理个人订阅\n' +
|
|
214
|
+
'wp-check 手动检查推送 (管理员)\n' +
|
|
215
|
+
'wp-status 查看插件状态\n' +
|
|
216
|
+
'wp-help 查看详细帮助\n\n' +
|
|
217
|
+
'【使用示例】\n' +
|
|
218
|
+
'• wp-news 8 → 查看最新8篇文章\n' +
|
|
219
|
+
'• wp-list 2 → 查看第2页文章\n' +
|
|
220
|
+
'• wp-post 456 → 查看ID为456的文章\n' +
|
|
221
|
+
'• wp-push on → 开启群推送\n' +
|
|
222
|
+
'• wp-sub off → 取消个人订阅\n' +
|
|
223
|
+
'• wp-check → 手动检查推送\n' +
|
|
224
|
+
'• wp-status → 查看插件状态\n\n' +
|
|
225
|
+
'💡 提示:所有命令都以 wp- 开头\n' +
|
|
226
|
+
'👑 管理员可以使用所有命令\n' +
|
|
227
|
+
'🙋 普通用户可以使用文章查询和个人订阅命令';
|
|
228
|
+
});
|
|
229
|
+
// 查看插件状态
|
|
230
|
+
this.ctx.command('wp-status', '查看插件状态')
|
|
231
|
+
.action(async (argv) => {
|
|
232
|
+
try {
|
|
233
|
+
const session = argv.session;
|
|
234
|
+
const groupId = session.channelId || 'global';
|
|
235
|
+
// 获取推送配置
|
|
236
|
+
const pushConfig = await this.storageService.getPushConfig(groupId);
|
|
237
|
+
// 获取 WordPress 服务状态
|
|
238
|
+
const wordpressStatus = this.wordpressService.getStatus();
|
|
239
|
+
// 构建状态信息
|
|
240
|
+
let statusMessage = '📊 WordPress 推送插件状态\n\n';
|
|
241
|
+
// 基本信息
|
|
242
|
+
statusMessage += '【基本信息】\n';
|
|
243
|
+
statusMessage += `WordPress 站点:${this.config.wordpressUrl}\n`;
|
|
244
|
+
statusMessage += `API 端点:${this.config.apiEndpoint || '/wp-json/wp/v2'}\n`;
|
|
245
|
+
statusMessage += `WordPress 连接:${wordpressStatus.isAuthenticated ? '正常' : '连接失败'}\n`;
|
|
246
|
+
if (wordpressStatus.inCooldown) {
|
|
247
|
+
statusMessage += `认证冷却中:${wordpressStatus.cooldownTimeRemaining} 秒\n`;
|
|
248
|
+
}
|
|
249
|
+
statusMessage += `推送间隔:${this.config.checkInterval || 30} 分钟\n\n`;
|
|
250
|
+
// 推送配置
|
|
251
|
+
statusMessage += '【推送配置】\n';
|
|
252
|
+
statusMessage += `群推送状态:${pushConfig?.enabled ? '开启' : '关闭'}\n`;
|
|
253
|
+
statusMessage += `更新推送:${pushConfig?.enableUpdatePush ? '开启' : '关闭'}\n`;
|
|
254
|
+
statusMessage += `允许@全体:${pushConfig?.enableAtAll ? '开启' : '关闭'}\n`;
|
|
255
|
+
if (pushConfig?.lastPushTime) {
|
|
256
|
+
statusMessage += `上次推送:${new Date(pushConfig.lastPushTime).toLocaleString('zh-CN')}\n`;
|
|
257
|
+
}
|
|
258
|
+
statusMessage += '\n';
|
|
259
|
+
// 个人订阅状态
|
|
260
|
+
if (session?.userId) {
|
|
261
|
+
const isSubscribed = await this.storageService.isUserSubscribed(session.userId, groupId);
|
|
262
|
+
statusMessage += '【个人订阅】\n';
|
|
263
|
+
statusMessage += `订阅状态:${isSubscribed ? '开启' : '关闭'}\n\n`;
|
|
264
|
+
}
|
|
265
|
+
// 推送时间范围
|
|
266
|
+
statusMessage += '【推送时间】\n';
|
|
267
|
+
const startHour = this.config.pushStartTime || 9;
|
|
268
|
+
const endHour = this.config.pushEndTime || 22;
|
|
269
|
+
statusMessage += `允许推送时间:${startHour}:00-${endHour}:00\n`;
|
|
270
|
+
const currentHour = new Date().getHours();
|
|
271
|
+
const isPushTime = currentHour >= startHour && currentHour <= endHour;
|
|
272
|
+
statusMessage += `当前是否允许推送:${isPushTime ? '是' : '否'}\n\n`;
|
|
273
|
+
// 服务统计
|
|
274
|
+
statusMessage += '【服务统计】\n';
|
|
275
|
+
statusMessage += `总请求数:${wordpressStatus.stats.totalRequests}\n`;
|
|
276
|
+
statusMessage += `成功请求:${wordpressStatus.stats.successfulRequests}\n`;
|
|
277
|
+
statusMessage += `失败请求:${wordpressStatus.stats.failedRequests}\n`;
|
|
278
|
+
statusMessage += `成功率:${wordpressStatus.stats.successRate}\n`;
|
|
279
|
+
statusMessage += `平均响应时间:${wordpressStatus.stats.averageResponseTime}\n`;
|
|
280
|
+
statusMessage += `命令调用次数:${wordpressStatus.stats.commandCount}\n\n`;
|
|
281
|
+
// 缓存信息
|
|
282
|
+
statusMessage += '【缓存信息】\n';
|
|
283
|
+
statusMessage += `缓存大小:${wordpressStatus.cache.size}\n`;
|
|
284
|
+
statusMessage += `缓存时长:${wordpressStatus.cache.duration} 秒\n`;
|
|
285
|
+
statusMessage += `清理间隔:${wordpressStatus.cache.cleanupInterval} 秒\n\n`;
|
|
286
|
+
// 并发控制
|
|
287
|
+
statusMessage += '【并发控制】\n';
|
|
288
|
+
statusMessage += `最大并发:${wordpressStatus.concurrency.max}\n\n`;
|
|
289
|
+
// 功能特性
|
|
290
|
+
statusMessage += '【功能特性】\n';
|
|
291
|
+
statusMessage += `重试机制:${wordpressStatus.features.retryEnabled ? '开启' : '关闭'}\n`;
|
|
292
|
+
statusMessage += `重试次数:${wordpressStatus.features.retryLimit}\n`;
|
|
293
|
+
statusMessage += `缓存机制:${wordpressStatus.features.cacheEnabled ? '开启' : '关闭'}\n`;
|
|
294
|
+
statusMessage += `并发控制:${wordpressStatus.features.concurrencyControl ? '开启' : '关闭'}\n\n`;
|
|
295
|
+
// 命令提示
|
|
296
|
+
statusMessage += '💡 提示:\n';
|
|
297
|
+
statusMessage += '• 使用 wp-push on/off 开启/关闭群推送\n';
|
|
298
|
+
statusMessage += '• 使用 wp-sub on/off 开启/关闭个人订阅\n';
|
|
299
|
+
statusMessage += '• 使用 wp-check 手动触发推送检查\n';
|
|
300
|
+
statusMessage += '• 使用 wp-help 查看详细帮助';
|
|
301
|
+
return statusMessage;
|
|
302
|
+
}
|
|
303
|
+
catch (error) {
|
|
304
|
+
this.ctx.logger.error('获取插件状态失败:', error);
|
|
305
|
+
return `❌ 获取插件状态失败:${error instanceof Error ? error.message : '未知错误'}`;
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
// 主命令
|
|
309
|
+
this.ctx.command('wp', 'WordPress 推送插件主命令')
|
|
310
|
+
.action(() => {
|
|
311
|
+
return 'WordPress 推送插件命令帮助\n\n' +
|
|
312
|
+
'📖 可用命令:\n' +
|
|
313
|
+
'- wp-news [数量] 查看最新文章\n' +
|
|
314
|
+
'- wp-list [页码] 浏览文章列表\n' +
|
|
315
|
+
'- wp-post <ID> 查看文章详情\n' +
|
|
316
|
+
'- wp-push [on|off] 控制群推送开关 (管理员)\n' +
|
|
317
|
+
'- wp-sub [on|off] 管理个人订阅\n' +
|
|
318
|
+
'- wp-check 手动检查推送 (管理员)\n' +
|
|
319
|
+
'- wp-status 查看插件状态\n' +
|
|
320
|
+
'- wp-help 查看详细帮助\n\n' +
|
|
321
|
+
'💡 示例:wp-news 10 查看最新10篇文章';
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
exports.CommandService = CommandService;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,99 +1,25 @@
|
|
|
1
1
|
import { Context, Schema } from 'koishi';
|
|
2
|
+
import { MessageType } from './push';
|
|
3
|
+
export declare const name = "wordpress-push";
|
|
2
4
|
export declare const inject: string[];
|
|
3
|
-
export declare const name = "wordpress-notifier";
|
|
4
|
-
declare module 'koishi' {
|
|
5
|
-
interface Tables {
|
|
6
|
-
wordpress_post_updates: WordPressPostUpdateRecord;
|
|
7
|
-
wordpress_user_registrations: WordPressUserRegistrationRecord;
|
|
8
|
-
wordpress_config: WordPressConfigRecord;
|
|
9
|
-
wordpress_version: WordPressVersionRecord;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
export interface WordPressVersionRecord {
|
|
13
|
-
id: string;
|
|
14
|
-
version: string;
|
|
15
|
-
updatedAt: Date;
|
|
16
|
-
}
|
|
17
|
-
export interface WordPressConfigRecord {
|
|
18
|
-
id: string;
|
|
19
|
-
key: string;
|
|
20
|
-
value: string;
|
|
21
|
-
updatedAt: Date;
|
|
22
|
-
}
|
|
23
|
-
export interface WordPressSiteConfig {
|
|
24
|
-
id: string;
|
|
25
|
-
name: string;
|
|
26
|
-
url: string;
|
|
27
|
-
interval: number;
|
|
28
|
-
targets: string[];
|
|
29
|
-
enableAutoPush: boolean;
|
|
30
|
-
enableUpdatePush: boolean;
|
|
31
|
-
enableUserPush: boolean;
|
|
32
|
-
mentionAll: boolean;
|
|
33
|
-
maxArticles: number;
|
|
34
|
-
username?: string;
|
|
35
|
-
applicationPassword?: string;
|
|
36
|
-
pushTemplate: {
|
|
37
|
-
showExcerpt: boolean;
|
|
38
|
-
dateFormat: string;
|
|
39
|
-
linkPosition: 'top' | 'bottom' | 'none';
|
|
40
|
-
showAuthor: boolean;
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
5
|
export interface Config {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
author: string;
|
|
64
|
-
categories: string[];
|
|
65
|
-
tags: string[];
|
|
66
|
-
}
|
|
67
|
-
export interface WordPressUser {
|
|
68
|
-
id: string;
|
|
69
|
-
name: string;
|
|
70
|
-
slug: string;
|
|
71
|
-
date?: string;
|
|
72
|
-
date_registered?: string;
|
|
73
|
-
registered_date?: string;
|
|
74
|
-
user_registered?: string;
|
|
75
|
-
created_at?: string;
|
|
76
|
-
registeredAt?: string;
|
|
77
|
-
email: string;
|
|
78
|
-
roles: string[];
|
|
79
|
-
[key: string]: any;
|
|
80
|
-
}
|
|
81
|
-
export interface WordPressPostUpdateRecord {
|
|
82
|
-
id: number;
|
|
83
|
-
siteId: string;
|
|
84
|
-
postId: number;
|
|
85
|
-
lastModified: Date;
|
|
86
|
-
pushedAt: Date;
|
|
87
|
-
}
|
|
88
|
-
export interface WordPressUserRegistrationRecord {
|
|
89
|
-
id: number;
|
|
90
|
-
siteId: string;
|
|
91
|
-
userId: number;
|
|
92
|
-
pushedAt: Date;
|
|
93
|
-
}
|
|
94
|
-
export interface WordPressNotification {
|
|
95
|
-
type: 'post' | 'update' | 'user';
|
|
96
|
-
data: any;
|
|
97
|
-
}
|
|
98
|
-
export declare const Config: Schema<Config>;
|
|
6
|
+
wordpressUrl: string;
|
|
7
|
+
apiEndpoint?: string;
|
|
8
|
+
authType?: 'none' | 'basic' | 'application-password';
|
|
9
|
+
username?: string;
|
|
10
|
+
password?: string;
|
|
11
|
+
checkInterval?: number;
|
|
12
|
+
enableAutoPush?: boolean;
|
|
13
|
+
enableUpdatePush?: boolean;
|
|
14
|
+
enableUserRegisterPush?: boolean;
|
|
15
|
+
defaultGroups?: string[];
|
|
16
|
+
allowAtAll?: boolean;
|
|
17
|
+
messageType?: MessageType;
|
|
18
|
+
signatureKey?: string;
|
|
19
|
+
adminUserId?: string;
|
|
20
|
+
superAdminUserIds?: string[];
|
|
21
|
+
pushStartTime?: number;
|
|
22
|
+
pushEndTime?: number;
|
|
23
|
+
}
|
|
24
|
+
export declare const schema: Schema<Config>;
|
|
99
25
|
export declare function apply(ctx: Context, config: Config): void;
|