koishi-plugin-aka-sa-caller 0.0.2 → 0.0.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.
Files changed (2) hide show
  1. package/lib/index.js +12 -4
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -65,14 +65,22 @@ function apply(ctx, config) {
65
65
  }
66
66
  }
67
67
  __name(submitAnalysis, "submitAnalysis");
68
- async function pollTaskStatus(taskId) {
68
+ async function pollTaskStatus(taskId, symbol) {
69
69
  for (let i = 0; i < config.maxPollAttempts; i++) {
70
70
  try {
71
71
  const response = await ctx.http.get(`${config.apiUrl}/api/analysis/task/${taskId}`);
72
72
  if (response.success) {
73
73
  const task = response.task;
74
74
  if (task.status === "completed" && task.result) {
75
- return task.result;
75
+ const analyses = task.result.analyses;
76
+ if (analyses && analyses.length > 0) {
77
+ const analysis = analyses.find((a) => a.symbol === symbol);
78
+ if (analysis) {
79
+ return analysis;
80
+ }
81
+ ctx.logger.warn(`未找到 ${symbol} 的分析结果,返回第一个结果`);
82
+ return analyses[0];
83
+ }
76
84
  } else if (task.status === "failed") {
77
85
  ctx.logger.error(`任务失败: ${task.error}`);
78
86
  return null;
@@ -144,7 +152,7 @@ function apply(ctx, config) {
144
152
  if (!taskId) {
145
153
  return "❌ 提交分析任务失败,请稍后重试";
146
154
  }
147
- const result = await pollTaskStatus(taskId);
155
+ const result = await pollTaskStatus(taskId, stock.symbol);
148
156
  if (!result) {
149
157
  return "❌ 分析失败或超时,请稍后重试";
150
158
  }
@@ -176,7 +184,7 @@ function apply(ctx, config) {
176
184
  if (!taskId) {
177
185
  return "❌ 提交分析任务失败,请稍后重试";
178
186
  }
179
- const result = await pollTaskStatus(taskId);
187
+ const result = await pollTaskStatus(taskId, stock.symbol);
180
188
  if (!result) {
181
189
  return "❌ 分析失败或超时,请稍后重试";
182
190
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-aka-sa-caller",
3
3
  "description": "集成 Stock Advisor 的 Koishi 插件,提供股票分析功能",
4
- "version": "0.0.2",
4
+ "version": "0.0.3",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [