fix(core): 🐛 修复消息ID类型转换并完善错误日志
在保存电报消息记录时,将 message_id 强制转换为字符串类型,以确保数据一致性。同时在捕获异常时添加 console.error 输出,以便于调试 Token 提交失败的问题。 - 转换 msg.message_id 为字符串格式 - 在 catch 块中记录详细的错误信息 - 优化了错误处理的逻辑结构
This commit is contained in:
@@ -809,7 +809,7 @@ async function relayToTopic(msg, u, env) {
|
||||
if (forwardedMsg && forwardedMsg.message_id) {
|
||||
const storeText = msg.text || "[Media]";
|
||||
await sql(env, "INSERT OR REPLACE INTO messages (user_id, message_id, text, date, topic_message_id) VALUES (?,?,?,?,?)",
|
||||
[uid, msg.message_id, storeText, msg.date, forwardedMsg.message_id.toString()]);
|
||||
[uid, msg.message_id.toString(), storeText, msg.date, forwardedMsg.message_id.toString()]);
|
||||
}
|
||||
|
||||
// 下游归档链路:数据备份
|
||||
@@ -1025,14 +1025,17 @@ async function handleTokenSubmit(req, env) {
|
||||
await api(env.BOT_TOKEN, "sendMessage", { chat_id: verifiedUserId, text: "✅ 验证通过!\n现在您可以直接发送消息,我会帮您转达给管理员。" });
|
||||
}
|
||||
return new Response(JSON.stringify({ success: true }));
|
||||
} catch { return new Response(JSON.stringify({ success: false }), { status: 400 }); }
|
||||
} catch (e) {
|
||||
console.error("Token Submit Failed:", e);
|
||||
return new Response(JSON.stringify({ success: false }), { status: 400 });
|
||||
}
|
||||
}
|
||||
|
||||
async function verifyAnswer(id, ans, env) {
|
||||
if (ans.trim() === (await getCfg('verif_a', env)).trim()) {
|
||||
await updUser(id, { user_state: "verified" }, env);
|
||||
await api(env.BOT_TOKEN, "sendMessage", { chat_id: id, text: "✅ 验证通过!\n现在您可以直接发送消息,我会帮您转达给管理员。" });
|
||||
} else await api(env.BOT_TOKEN, "sendMessage", { chat_id: id, text: "❌ 错误" });
|
||||
return api(env.BOT_TOKEN, "sendMessage", { chat_id: id, text: "✅ 验证通过!\n现在您可以直接发送消息,我会帮您转达给管理员。" });
|
||||
} else return api(env.BOT_TOKEN, "sendMessage", { chat_id: id, text: "❌ 错误" });
|
||||
}
|
||||
|
||||
// --- 8. 菜单回调调度控制室 ---
|
||||
|
||||
Reference in New Issue
Block a user