@anyul/koishi-plugin-rss 5.3.2 → 5.3.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.
- package/lib/commands/index.js +0 -2
- package/lib/commands/subscription-management.js +0 -2
- package/lib/commands/utils.d.ts +0 -5
- package/lib/commands/utils.js +0 -16
- package/lib/config.js +0 -8
- package/lib/core/feeder-arg.js +3 -38
- package/lib/core/feeder-runtime.js +0 -5
- package/lib/core/feeder.js +0 -10
- package/lib/core/item-processor-runtime.d.ts +4 -2
- package/lib/core/item-processor-runtime.js +4 -12
- package/lib/core/notification-queue-sender.js +0 -5
- package/lib/core/notification-queue.js +0 -7
- package/lib/core/telegram-video-restore.js +3 -8
- package/lib/index.js +3 -11
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types.d.ts +0 -9
- package/lib/utils/common.d.ts +6 -0
- package/lib/utils/common.js +15 -25
- package/lib/utils/error-handler.d.ts +49 -0
- package/lib/utils/error-handler.js +111 -1
- package/lib/utils/fetcher.js +11 -37
- package/lib/utils/logger.d.ts +6 -0
- package/lib/utils/logger.js +82 -14
- package/lib/utils/proxy.d.ts +37 -0
- package/lib/utils/proxy.js +60 -0
- package/package.json +1 -1
- package/lib/commands/error-handler.d.ts +0 -53
- package/lib/commands/error-handler.js +0 -120
- package/lib/commands/rss-subscribe.d.ts +0 -11
- package/lib/commands/rss-subscribe.js +0 -323
- package/lib/core/feeder-old.d.ts +0 -15
- package/lib/core/feeder-old.js +0 -403
- package/lib/utils/error-tracker.d.ts +0 -127
- package/lib/utils/error-tracker.js +0 -352
- package/lib/utils/metrics.d.ts +0 -184
- package/lib/utils/metrics.js +0 -401
- package/lib/utils/structured-logger.d.ts +0 -135
- package/lib/utils/structured-logger.js +0 -248
package/lib/commands/index.js
CHANGED
|
@@ -11,7 +11,6 @@ exports.handleCacheClear = handleCacheClear;
|
|
|
11
11
|
exports.handleCacheCleanup = handleCacheCleanup;
|
|
12
12
|
exports.handleCachePull = handleCachePull;
|
|
13
13
|
const error_handler_1 = require("../utils/error-handler");
|
|
14
|
-
const error_tracker_1 = require("../utils/error-tracker");
|
|
15
14
|
const logger_1 = require("../utils/logger");
|
|
16
15
|
const message_cache_1 = require("../utils/message-cache");
|
|
17
16
|
const utils_1 = require("./utils");
|
|
@@ -525,7 +524,6 @@ async function resolveCacheMessageById(cmdCtx, realId) {
|
|
|
525
524
|
function logCacheError(config, error, scope, context) {
|
|
526
525
|
const normalizedError = (0, error_handler_1.normalizeError)(error);
|
|
527
526
|
(0, logger_1.debug)(config, normalizedError, scope, 'error', context);
|
|
528
|
-
(0, error_tracker_1.trackError)(normalizedError, context);
|
|
529
527
|
}
|
|
530
528
|
var subscription_management_1 = require("./subscription-management");
|
|
531
529
|
Object.defineProperty(exports, "registerSubscriptionManagementCommands", { enumerable: true, get: function () { return subscription_management_1.registerSubscriptionManagementCommands; } });
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.registerSubscriptionManagementCommands = registerSubscriptionManagementCommands;
|
|
4
4
|
const error_handler_1 = require("../utils/error-handler");
|
|
5
|
-
const error_tracker_1 = require("../utils/error-tracker");
|
|
6
5
|
const logger_1 = require("../utils/logger");
|
|
7
6
|
const utils_1 = require("./utils");
|
|
8
7
|
function registerSubscriptionManagementCommands(deps) {
|
|
@@ -121,7 +120,6 @@ function registerPullCommand(deps) {
|
|
|
121
120
|
catch (error) {
|
|
122
121
|
const normalizedError = (0, error_handler_1.normalizeError)(error);
|
|
123
122
|
(0, logger_1.debug)(deps.config, normalizedError, 'pull error', 'error', logContext);
|
|
124
|
-
(0, error_tracker_1.trackError)(normalizedError, logContext);
|
|
125
123
|
return `拉取失败: ${(0, error_handler_1.getFriendlyErrorMessage)(error, '获取订阅数据')}`;
|
|
126
124
|
}
|
|
127
125
|
});
|
package/lib/commands/utils.d.ts
CHANGED
|
@@ -33,11 +33,6 @@ export declare function extractSessionInfo(session: Session): SessionInfo;
|
|
|
33
33
|
* 构建命令日志上下文
|
|
34
34
|
*/
|
|
35
35
|
export declare function buildCommandLogContext(session: Session, command?: string, operation?: string): Record<string, any>;
|
|
36
|
-
/**
|
|
37
|
-
* 命令错误处理包装器
|
|
38
|
-
* 统一处理命令执行中的错误
|
|
39
|
-
*/
|
|
40
|
-
export declare function withCommandErrorHandling(config: Config, operation: string, handler: () => Promise<string>, context?: Record<string, any>): Promise<string>;
|
|
41
36
|
/**
|
|
42
37
|
* 权限检查辅助函数
|
|
43
38
|
*/
|
package/lib/commands/utils.js
CHANGED
|
@@ -6,14 +6,10 @@
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.extractSessionInfo = extractSessionInfo;
|
|
8
8
|
exports.buildCommandLogContext = buildCommandLogContext;
|
|
9
|
-
exports.withCommandErrorHandling = withCommandErrorHandling;
|
|
10
9
|
exports.checkAuthority = checkAuthority;
|
|
11
10
|
exports.parseTarget = parseTarget;
|
|
12
11
|
exports.parseTargets = parseTargets;
|
|
13
12
|
exports.isValidUrl = isValidUrl;
|
|
14
|
-
const error_handler_1 = require("../utils/error-handler");
|
|
15
|
-
const error_tracker_1 = require("../utils/error-tracker");
|
|
16
|
-
const logger_1 = require("../utils/logger");
|
|
17
13
|
/**
|
|
18
14
|
* 从会话中提取信息
|
|
19
15
|
*/
|
|
@@ -39,18 +35,6 @@ function buildCommandLogContext(session, command, operation) {
|
|
|
39
35
|
context.operation = operation;
|
|
40
36
|
return context;
|
|
41
37
|
}
|
|
42
|
-
/**
|
|
43
|
-
* 命令错误处理包装器
|
|
44
|
-
* 统一处理命令执行中的错误
|
|
45
|
-
*/
|
|
46
|
-
function withCommandErrorHandling(config, operation, handler, context) {
|
|
47
|
-
return handler().catch((error) => {
|
|
48
|
-
const normalizedError = (0, error_handler_1.normalizeError)(error);
|
|
49
|
-
(0, logger_1.debug)(config, normalizedError, `${operation} error`, 'error', context);
|
|
50
|
-
(0, error_tracker_1.trackError)(normalizedError, context);
|
|
51
|
-
return Promise.resolve(`${operation}失败: ${(0, error_handler_1.getFriendlyErrorMessage)(error, operation)}`);
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
38
|
/**
|
|
55
39
|
* 权限检查辅助函数
|
|
56
40
|
*/
|
package/lib/config.js
CHANGED
|
@@ -191,14 +191,6 @@ exports.Config = koishi_1.Schema.object({
|
|
|
191
191
|
contextFields: koishi_1.Schema.array(koishi_1.Schema.string()).description('要包含的上下文字段(如 guildId, platform 等)').default([]),
|
|
192
192
|
sanitizeLogs: koishi_1.Schema.boolean().description('自动脱敏日志中的敏感信息').default(true),
|
|
193
193
|
}).description('日志设置'),
|
|
194
|
-
errorTracking: koishi_1.Schema.object({
|
|
195
|
-
enabled: koishi_1.Schema.boolean().description('启用错误追踪').default(false),
|
|
196
|
-
dsn: koishi_1.Schema.string().role('secret').description('Sentry DSN').default(''),
|
|
197
|
-
environment: koishi_1.Schema.string().description('错误追踪环境').default('production'),
|
|
198
|
-
release: koishi_1.Schema.string().description('错误追踪版本号').default('5.2.48'),
|
|
199
|
-
tracesSampleRate: koishi_1.Schema.number().min(0).max(1).description('性能追踪采样率').default(0.1),
|
|
200
|
-
profilesSampleRate: koishi_1.Schema.number().min(0).max(1).description('性能分析采样率').default(0.1),
|
|
201
|
-
}).description('错误追踪设置'),
|
|
202
194
|
tdl: koishi_1.Schema.object({
|
|
203
195
|
enabled: koishi_1.Schema.boolean().description('启用 Telegram 大视频 tdl 兜底下载<br>当 RSSHub 返回 "Video is too big" 占位时,调用外部 tdl 直接从 Telegram 拉取原始视频。<br><b>需宿主机自行安装</b>: `go install github.com/iyear/tdl@latest` 或下载 [Release](https://github.com/iyear/tdl/releases),并执行 `tdl login` 完成登录。<br>插件运行时探测 PATH,缺失则跳过、不阻塞主流程。').default(false),
|
|
204
196
|
binPath: koishi_1.Schema.string().description('tdl 二进制路径,默认从 PATH 探测<br>Docker/容器场景下若 tdl 装在持久卷(如 /koishi/bin/tdl),在此指定可避免依赖容器 PATH').default(''),
|
package/lib/core/feeder-arg.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.formatArg = formatArg;
|
|
4
4
|
exports.mixinArg = mixinArg;
|
|
5
5
|
const legacy_config_1 = require("../utils/legacy-config");
|
|
6
|
+
const proxy_1 = require("../utils/proxy");
|
|
6
7
|
const logger_1 = require("../utils/logger");
|
|
7
8
|
const ARG_ENTRY_KEYS = [
|
|
8
9
|
'forceLength',
|
|
@@ -102,45 +103,9 @@ function parseProxyAgentArg(value, auth) {
|
|
|
102
103
|
return undefined;
|
|
103
104
|
}
|
|
104
105
|
}
|
|
105
|
-
|
|
106
|
-
(0, logger_1.debug)(config, `合并代理配置 - argProxy: ${JSON.stringify(argProxy)}, configProxy.enabled: ${configProxy?.enabled}`, 'proxy merge debug', 'details');
|
|
107
|
-
if (argProxy?.enabled === false) {
|
|
108
|
-
(0, logger_1.debug)(config, '订阅明确禁用代理', 'proxy merge', 'details');
|
|
109
|
-
return { enabled: false };
|
|
110
|
-
}
|
|
111
|
-
if (argProxy?.enabled === true && argProxy?.host) {
|
|
112
|
-
(0, logger_1.debug)(config, '使用订阅的代理配置', 'proxy merge', 'details');
|
|
113
|
-
return argProxy;
|
|
114
|
-
}
|
|
115
|
-
const shouldUseConfigProxy = !argProxy || Object.keys(argProxy || {}).length === 0 || argProxy?.enabled === undefined || argProxy?.enabled === null;
|
|
116
|
-
if (shouldUseConfigProxy) {
|
|
117
|
-
if (configProxy?.enabled) {
|
|
118
|
-
const result = {
|
|
119
|
-
enabled: true,
|
|
120
|
-
protocol: configProxy.protocol,
|
|
121
|
-
host: configProxy.host,
|
|
122
|
-
port: configProxy.port,
|
|
123
|
-
auth: configProxy.auth?.enabled ? configProxy.auth : undefined,
|
|
124
|
-
};
|
|
125
|
-
(0, logger_1.debug)(config, `使用全局代理: ${result.protocol}://${result.host}:${result.port}`, 'proxy merge', 'info');
|
|
126
|
-
return result;
|
|
127
|
-
}
|
|
128
|
-
(0, logger_1.debug)(config, '全局代理未启用', 'proxy merge', 'details');
|
|
129
|
-
}
|
|
130
|
-
if (argProxy?.enabled === true && !argProxy?.host) {
|
|
131
|
-
const result = {
|
|
132
|
-
...configProxy,
|
|
133
|
-
...argProxy,
|
|
134
|
-
auth: configProxy?.auth?.enabled ? configProxy.auth : undefined,
|
|
135
|
-
};
|
|
136
|
-
(0, logger_1.debug)(config, '订阅代理配置不完整,补充全局配置', 'proxy merge', 'details');
|
|
137
|
-
return result;
|
|
138
|
-
}
|
|
139
|
-
(0, logger_1.debug)(config, '代理未配置,使用默认(禁用)', 'proxy merge', 'details');
|
|
140
|
-
return { enabled: false };
|
|
141
|
-
}
|
|
106
|
+
// mergeProxyAgent 已提升到 utils/proxy.ts,统一代理 helper 归属
|
|
142
107
|
function mergeProxyAgentWithLog(argProxy, configProxy, config) {
|
|
143
|
-
const result = mergeProxyAgent(argProxy, configProxy, config);
|
|
108
|
+
const result = (0, proxy_1.mergeProxyAgent)(argProxy, configProxy, config);
|
|
144
109
|
(0, logger_1.debug)(config, `[DEBUG_PROXY] mergeProxyAgent input: arg=${JSON.stringify(argProxy)} conf=${JSON.stringify(configProxy)} output=${JSON.stringify(result)}`, 'proxy merge', 'details');
|
|
145
110
|
return result;
|
|
146
111
|
}
|
|
@@ -13,7 +13,6 @@ const koishi_1 = require("koishi");
|
|
|
13
13
|
const constants_1 = require("../constants");
|
|
14
14
|
const common_1 = require("../utils/common");
|
|
15
15
|
const error_handler_1 = require("../utils/error-handler");
|
|
16
|
-
const error_tracker_1 = require("../utils/error-tracker");
|
|
17
16
|
const legacy_config_1 = require("../utils/legacy-config");
|
|
18
17
|
const logger_1 = require("../utils/logger");
|
|
19
18
|
const parser_1 = require("./parser");
|
|
@@ -101,10 +100,6 @@ async function fetchRssItems(ctx, config, $http, rssItem, arg, feedDebug) {
|
|
|
101
100
|
feedDebug(`Fetch failed for ${rssItem.title}: ${normalizedError.message}`, 'feeder', 'error', {
|
|
102
101
|
stage: 'fetch',
|
|
103
102
|
});
|
|
104
|
-
(0, error_tracker_1.trackError)(normalizedError, {
|
|
105
|
-
...buildFeedLogContext(rssItem),
|
|
106
|
-
stage: 'fetch',
|
|
107
|
-
});
|
|
108
103
|
return [];
|
|
109
104
|
}
|
|
110
105
|
}
|
package/lib/core/feeder.js
CHANGED
|
@@ -40,7 +40,6 @@ exports.stopFeeder = stopFeeder;
|
|
|
40
40
|
const koishi_1 = require("koishi");
|
|
41
41
|
const common_1 = require("../utils/common");
|
|
42
42
|
const error_handler_1 = require("../utils/error-handler");
|
|
43
|
-
const error_tracker_1 = require("../utils/error-tracker");
|
|
44
43
|
const legacy_config_1 = require("../utils/legacy-config");
|
|
45
44
|
const logger_1 = require("../utils/logger");
|
|
46
45
|
const feeder_arg_1 = require("./feeder-arg");
|
|
@@ -171,7 +170,6 @@ async function feeder(deps, processor) {
|
|
|
171
170
|
const normalizedError = (0, error_handler_1.normalizeError)(err);
|
|
172
171
|
const feedContext = (0, feeder_runtime_1.buildFeedLogContext)(rssItem);
|
|
173
172
|
(0, logger_1.debug)(config, `Feeder error for ${rssItem.url}: ${normalizedError.message}`, 'feeder', 'error', feedContext);
|
|
174
|
-
(0, error_tracker_1.trackError)(normalizedError, feedContext);
|
|
175
173
|
}
|
|
176
174
|
}
|
|
177
175
|
}
|
|
@@ -185,10 +183,6 @@ function startFeeder(ctx, config, $http, processor, queueManager) {
|
|
|
185
183
|
lifecycleDebug(`Initial feeder run failed: ${normalizedError.message}`, 'feeder', 'error', {
|
|
186
184
|
operation: 'initial-feeder-run',
|
|
187
185
|
});
|
|
188
|
-
(0, error_tracker_1.trackError)(normalizedError, {
|
|
189
|
-
lifecycle: 'feeder',
|
|
190
|
-
operation: 'initial-feeder-run',
|
|
191
|
-
});
|
|
192
186
|
});
|
|
193
187
|
// 启动生产者定时器(抓取 RSS)
|
|
194
188
|
const refreshInterval = (config.basic?.refresh || 600) * 1000;
|
|
@@ -211,10 +205,6 @@ function startFeeder(ctx, config, $http, processor, queueManager) {
|
|
|
211
205
|
lifecycleDebug(`Initial queue processing failed: ${normalizedError.message}`, 'queue', 'error', {
|
|
212
206
|
operation: 'initial-queue-processing',
|
|
213
207
|
});
|
|
214
|
-
(0, error_tracker_1.trackError)(normalizedError, {
|
|
215
|
-
lifecycle: 'feeder',
|
|
216
|
-
operation: 'initial-queue-processing',
|
|
217
|
-
});
|
|
218
208
|
});
|
|
219
209
|
lifecycleDebug('Feeder started', 'feeder', 'info', {
|
|
220
210
|
refreshInterval,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as cheerio from 'cheerio';
|
|
2
2
|
import { Context } from 'koishi';
|
|
3
3
|
import { Config, rssArg } from '../types';
|
|
4
|
+
import { normalizeText } from '../utils/common';
|
|
4
5
|
export interface ItemProcessorRuntimeDeps {
|
|
5
6
|
ctx: Context;
|
|
6
7
|
config: Config;
|
|
@@ -13,8 +14,10 @@ interface RenderDescriptionOptions {
|
|
|
13
14
|
}
|
|
14
15
|
/**
|
|
15
16
|
* 标准化 RSS 字段内容,统一数组 / 空值 / 非字符串输入。
|
|
17
|
+
*
|
|
18
|
+
* 实现已收敛到 `utils/common.ts`,此处 re-export 以维持现有 import 路径不变。
|
|
16
19
|
*/
|
|
17
|
-
export
|
|
20
|
+
export { normalizeText };
|
|
18
21
|
/**
|
|
19
22
|
* 解析并去重 HTML 中的图片资源,返回原图到最终地址的映射表。
|
|
20
23
|
*/
|
|
@@ -48,4 +51,3 @@ export declare function formatVideoList(videoList: Array<[string, string]>): str
|
|
|
48
51
|
* 统一执行图片渲染,兼容 base64 / File / assets / HTML 回退。
|
|
49
52
|
*/
|
|
50
53
|
export declare function renderImage(htmlContent: string, deps: ItemProcessorRuntimeDeps, arg: rssArg): Promise<string>;
|
|
51
|
-
export {};
|
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.normalizeText =
|
|
36
|
+
exports.normalizeText = void 0;
|
|
37
37
|
exports.buildResolvedImageMap = buildResolvedImageMap;
|
|
38
38
|
exports.renderImageListFromHtml = renderImageListFromHtml;
|
|
39
39
|
exports.renderLoadedHtml = renderLoadedHtml;
|
|
@@ -44,6 +44,8 @@ exports.renderImage = renderImage;
|
|
|
44
44
|
const cheerio = __importStar(require("cheerio"));
|
|
45
45
|
const koishi_1 = require("koishi");
|
|
46
46
|
const marked_1 = require("marked");
|
|
47
|
+
const common_1 = require("../utils/common");
|
|
48
|
+
Object.defineProperty(exports, "normalizeText", { enumerable: true, get: function () { return common_1.normalizeText; } });
|
|
47
49
|
const logger_1 = require("../utils/logger");
|
|
48
50
|
const media_1 = require("../utils/media");
|
|
49
51
|
const renderer_1 = require("./renderer");
|
|
@@ -62,7 +64,7 @@ function collectUniqueImageSources(html) {
|
|
|
62
64
|
return [...new Set(imageSources)];
|
|
63
65
|
}
|
|
64
66
|
async function prependAiSummarySection(config, htmlContent, item, options) {
|
|
65
|
-
const aiSummary = normalizeText(item?.aiSummary).trim();
|
|
67
|
+
const aiSummary = (0, common_1.normalizeText)(item?.aiSummary).trim();
|
|
66
68
|
if (!aiSummary || !isImageRenderEnabled(config))
|
|
67
69
|
return htmlContent;
|
|
68
70
|
const aiSummaryHtml = await (0, marked_1.marked)(aiSummary);
|
|
@@ -99,16 +101,6 @@ async function prepareHtmlForRender(deps, html, arg, useXml = false) {
|
|
|
99
101
|
html('img').attr('style', 'object-fit:scale-down;max-width:100%;height:auto;');
|
|
100
102
|
return useXml ? html.xml() : html.html();
|
|
101
103
|
}
|
|
102
|
-
/**
|
|
103
|
-
* 标准化 RSS 字段内容,统一数组 / 空值 / 非字符串输入。
|
|
104
|
-
*/
|
|
105
|
-
function normalizeText(value) {
|
|
106
|
-
if (Array.isArray(value))
|
|
107
|
-
return value.join('');
|
|
108
|
-
if (value === undefined || value === null)
|
|
109
|
-
return '';
|
|
110
|
-
return String(value);
|
|
111
|
-
}
|
|
112
104
|
/**
|
|
113
105
|
* 解析并去重 HTML 中的图片资源,返回原图到最终地址的映射表。
|
|
114
106
|
*/
|
|
@@ -36,7 +36,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.NotificationQueueSender = void 0;
|
|
37
37
|
exports.downgradeQueueMessage = downgradeQueueMessage;
|
|
38
38
|
const error_handler_1 = require("../utils/error-handler");
|
|
39
|
-
const error_tracker_1 = require("../utils/error-tracker");
|
|
40
39
|
const notification_queue_retry_1 = require("./notification-queue-retry");
|
|
41
40
|
function downgradeQueueMessage(content) {
|
|
42
41
|
if (content.isDowngraded) {
|
|
@@ -108,10 +107,6 @@ class NotificationQueueSender {
|
|
|
108
107
|
catch (err) {
|
|
109
108
|
const normalizedError = (0, error_handler_1.normalizeError)(err);
|
|
110
109
|
taskDebug(`缓存消息失败: ${normalizedError.message}`, 'cache', 'info');
|
|
111
|
-
(0, error_tracker_1.trackError)(normalizedError, {
|
|
112
|
-
...this.deps.buildTaskLogContext(task),
|
|
113
|
-
operation: 'cacheMessage',
|
|
114
|
-
});
|
|
115
110
|
}
|
|
116
111
|
}
|
|
117
112
|
}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NotificationQueueManager = void 0;
|
|
4
4
|
const error_handler_1 = require("../utils/error-handler");
|
|
5
|
-
const error_tracker_1 = require("../utils/error-tracker");
|
|
6
5
|
const logger_1 = require("../utils/logger");
|
|
7
6
|
const notification_queue_retry_1 = require("./notification-queue-retry");
|
|
8
7
|
const notification_queue_sender_1 = require("./notification-queue-sender");
|
|
@@ -109,7 +108,6 @@ class NotificationQueueManager {
|
|
|
109
108
|
catch (err) {
|
|
110
109
|
const normalizedError = (0, error_handler_1.normalizeError)(err);
|
|
111
110
|
(0, logger_1.debug)(this.config, `队列处理异常: ${normalizedError.message}`, 'queue', 'error', { processing: true });
|
|
112
|
-
(0, error_tracker_1.trackError)(normalizedError, { operation: 'processQueue' });
|
|
113
111
|
}
|
|
114
112
|
finally {
|
|
115
113
|
this.processing = false;
|
|
@@ -139,11 +137,6 @@ class NotificationQueueManager {
|
|
|
139
137
|
const classification = (0, notification_queue_retry_1.classifyQueueError)(error, task.content);
|
|
140
138
|
const normalizedError = classification.normalizedError;
|
|
141
139
|
const errorMsg = normalizedError.message || 'Unknown error';
|
|
142
|
-
(0, error_tracker_1.trackError)(normalizedError, {
|
|
143
|
-
...this.buildTaskLogContext(task),
|
|
144
|
-
failReason: errorMsg,
|
|
145
|
-
queueErrorAction: classification.action,
|
|
146
|
-
});
|
|
147
140
|
if (classification.action === 'FAILED') {
|
|
148
141
|
await this.store.markTaskFailed(task.id, errorMsg);
|
|
149
142
|
taskDebug(`✗ 永久性失败,放弃重试: [${task.rssId}] ${task.content.title} - ${errorMsg}`, 'queue', 'error', {
|
|
@@ -54,6 +54,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
54
54
|
})();
|
|
55
55
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
56
56
|
exports.restoreTelegramVideos = restoreTelegramVideos;
|
|
57
|
+
const common_1 = require("../utils/common");
|
|
57
58
|
const logger_1 = require("../utils/logger");
|
|
58
59
|
const media_1 = require("../utils/media");
|
|
59
60
|
const tdl_1 = require("../utils/tdl");
|
|
@@ -82,7 +83,7 @@ async function restoreTelegramVideos(html, item, arg, config, ffmpegExe) {
|
|
|
82
83
|
return false;
|
|
83
84
|
if (!(0, tdl_1.detectVideoTooBig)(html))
|
|
84
85
|
return false;
|
|
85
|
-
const link = normalizeText(item?.link);
|
|
86
|
+
const link = (0, common_1.normalizeText)(item?.link);
|
|
86
87
|
const linkInfo = (0, tdl_1.parseTelegramLink)(link);
|
|
87
88
|
if (!linkInfo) {
|
|
88
89
|
(0, logger_1.debug)(config, `检测到 Video is too big 但 link 非 Telegram 消息链接,跳过: ${link}`, 'tg-restore', 'info');
|
|
@@ -237,10 +238,4 @@ function replaceTooBigBlockquotesIndexed(html, builder, onEach) {
|
|
|
237
238
|
function escapeAttr(s) {
|
|
238
239
|
return String(s || '').replace(/"/g, '"');
|
|
239
240
|
}
|
|
240
|
-
|
|
241
|
-
if (Array.isArray(v))
|
|
242
|
-
return v.join('');
|
|
243
|
-
if (v === undefined || v === null)
|
|
244
|
-
return '';
|
|
245
|
-
return String(v);
|
|
246
|
-
}
|
|
241
|
+
// normalizeText 已收敛到 utils/common.ts
|
package/lib/index.js
CHANGED
|
@@ -25,7 +25,6 @@ Object.defineProperty(exports, "templateList", { enumerable: true, get: function
|
|
|
25
25
|
exports.name = '@anyul/koishi-plugin-rss';
|
|
26
26
|
const fetcher_1 = require("./utils/fetcher");
|
|
27
27
|
const media_1 = require("./utils/media");
|
|
28
|
-
const error_tracker_1 = require("./utils/error-tracker");
|
|
29
28
|
const tdl_1 = require("./utils/tdl");
|
|
30
29
|
const logger_1 = require("./utils/logger");
|
|
31
30
|
const commands_1 = require("./commands");
|
|
@@ -42,6 +41,9 @@ exports.inject = { required: ["database"], optional: ["puppeteer", "censor", "as
|
|
|
42
41
|
function apply(ctx, config) {
|
|
43
42
|
// Setup database
|
|
44
43
|
(0, database_1.setupDatabase)(ctx);
|
|
44
|
+
// 把 config.debug 同步到 Koishi 原生日志分级(Logger.levels['rss-owl']),
|
|
45
|
+
// 让 WebUI 的 logger 插件 / 全局 levels 都能控制本插件日志可见性。
|
|
46
|
+
(0, logger_1.applyDebugLevel)(config);
|
|
45
47
|
// 启用时探测 tdl 外部二进制可用性,并报告 Koishi ffmpeg 服务注入状态,便于用户排查
|
|
46
48
|
// 探测异步进行、失败仅打日志,不阻塞插件加载
|
|
47
49
|
// 注意:tdl 的版本命令是 `version` 子命令,不是 `-v` flag
|
|
@@ -55,16 +57,6 @@ function apply(ctx, config) {
|
|
|
55
57
|
(0, logger_1.debug)(config, `Telegram 大视频工具探测:tdl=${hasTdl ? '✓' + tdlLoc : '✗(请安装 iyear/tdl 并 tdl login)'},ffmpeg=${ffmpegStatus}`, 'tdl', 'info');
|
|
56
58
|
}).catch(() => { });
|
|
57
59
|
}
|
|
58
|
-
if (config.errorTracking?.enabled) {
|
|
59
|
-
(0, error_tracker_1.initErrorTracker)({
|
|
60
|
-
enabled: config.errorTracking.enabled ?? false,
|
|
61
|
-
dsn: config.errorTracking.dsn || '',
|
|
62
|
-
environment: config.errorTracking.environment,
|
|
63
|
-
release: config.errorTracking.release,
|
|
64
|
-
tracesSampleRate: config.errorTracking.tracesSampleRate,
|
|
65
|
-
profilesSampleRate: config.errorTracking.profilesSampleRate,
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
60
|
// Initialize request manager and HTTP function
|
|
69
61
|
const requestManager = new fetcher_1.RequestManager(3, 2, 10);
|
|
70
62
|
const $http = (0, fetcher_1.createHttpFunction)(ctx, config, requestManager);
|