koishi-plugin-aka-60s-api 0.0.7 → 0.0.8
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 +0 -49
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -159,7 +159,6 @@ function apply(ctx, config) {
|
|
|
159
159
|
}
|
|
160
160
|
try {
|
|
161
161
|
logInfo("60s API: 用户请求新闻图片", { userId });
|
|
162
|
-
await argv.session.send("正在获取60秒新闻图片,请稍候...");
|
|
163
162
|
const imageBuffer = await get60sNewsImage();
|
|
164
163
|
const imageMessage = import_koishi.h.image(imageBuffer, "image/png");
|
|
165
164
|
await argv.session.send(imageMessage);
|
|
@@ -167,7 +166,6 @@ function apply(ctx, config) {
|
|
|
167
166
|
size: imageBuffer.length,
|
|
168
167
|
userId
|
|
169
168
|
});
|
|
170
|
-
return "📰 60秒读懂世界新闻图片已发送";
|
|
171
169
|
} catch (error) {
|
|
172
170
|
logError("60s API: 处理新闻图片请求失败", {
|
|
173
171
|
error,
|
|
@@ -177,53 +175,6 @@ function apply(ctx, config) {
|
|
|
177
175
|
return "获取新闻图片失败,请稍后重试";
|
|
178
176
|
}
|
|
179
177
|
});
|
|
180
|
-
ctx.command("60s重置", "重置60秒新闻冷却时间").action(async (argv) => {
|
|
181
|
-
const userId = argv.session.userId;
|
|
182
|
-
const hadCooldown = cooldowns.has(userId);
|
|
183
|
-
cooldowns.delete(userId);
|
|
184
|
-
logInfo("60s API: 手动重置冷却时间", { userId, hadCooldown });
|
|
185
|
-
return hadCooldown ? "已重置冷却时间,可以重新使用新闻指令" : "当前没有冷却时间";
|
|
186
|
-
});
|
|
187
|
-
ctx.command("新闻定时", "管理定时发送新闻").subcommand(".设置 <time>", "设置定时发送时间").action(async (argv, time) => {
|
|
188
|
-
if (!time) {
|
|
189
|
-
return "请提供时间格式,例如: 08:00 / 1d";
|
|
190
|
-
}
|
|
191
|
-
config.scheduleTime = time;
|
|
192
|
-
await setupSchedule();
|
|
193
|
-
return `定时发送时间已设置为: ${time}`;
|
|
194
|
-
}).subcommand(".频道 <channels...>", "设置定时发送频道").action(async (argv, ...channels) => {
|
|
195
|
-
if (!channels || channels.length === 0) {
|
|
196
|
-
return "请提供频道ID,例如: 新闻定时.频道 123456789 987654321";
|
|
197
|
-
}
|
|
198
|
-
config.scheduleChannels = channels;
|
|
199
|
-
await setupSchedule();
|
|
200
|
-
return `定时发送频道已设置为: ${channels.join(", ")}`;
|
|
201
|
-
}).subcommand(".启用", "启用定时发送").action(async (argv) => {
|
|
202
|
-
config.enableSchedule = true;
|
|
203
|
-
await setupSchedule();
|
|
204
|
-
return "定时发送已启用";
|
|
205
|
-
}).subcommand(".禁用", "禁用定时发送").action(async (argv) => {
|
|
206
|
-
config.enableSchedule = false;
|
|
207
|
-
if (scheduleInterval) {
|
|
208
|
-
clearInterval(scheduleInterval);
|
|
209
|
-
scheduleInterval = null;
|
|
210
|
-
}
|
|
211
|
-
return "定时发送已禁用";
|
|
212
|
-
}).subcommand(".状态", "查看定时发送状态").action(async (argv) => {
|
|
213
|
-
const status = config.enableSchedule ? "启用" : "禁用";
|
|
214
|
-
const time = config.scheduleTime;
|
|
215
|
-
const channels = config.scheduleChannels.length > 0 ? config.scheduleChannels.join(", ") : "未设置";
|
|
216
|
-
return `定时发送状态: ${status}
|
|
217
|
-
发送时间: ${time}
|
|
218
|
-
发送频道: ${channels}`;
|
|
219
|
-
}).subcommand(".测试", "测试定时发送功能").action(async (argv) => {
|
|
220
|
-
try {
|
|
221
|
-
await sendNewsToChannels();
|
|
222
|
-
return "测试发送完成";
|
|
223
|
-
} catch (error) {
|
|
224
|
-
return `测试发送失败: ${error.message}`;
|
|
225
|
-
}
|
|
226
|
-
});
|
|
227
178
|
ctx.on("ready", async () => {
|
|
228
179
|
await setupSchedule();
|
|
229
180
|
});
|