|
|
@@ -21,13 +21,13 @@ export async function handleCancelCommand(ctx: Context, env: Env): Promise<void>
|
|
|
// Get user credentials from KV storage
|
|
|
const telegramUserId = ctx.from?.id.toString();
|
|
|
if (!telegramUserId) {
|
|
|
- await ctx.reply("Could not identify your Telegram user ID.");
|
|
|
+ await ctx.reply("无法获取你的 Telegram 用户身份");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
const storedCredentials = await env.COSMOE_CREDENTIALS.get(telegramUserId);
|
|
|
if (!storedCredentials) {
|
|
|
- await ctx.reply("You need to login first using /login username password before canceling bookings.");
|
|
|
+ await ctx.reply("请先使用 /login 命令登录后再取消预约");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -38,7 +38,7 @@ export async function handleCancelCommand(ctx: Context, env: Env): Promise<void>
|
|
|
cosmoeClient.setCredentials(credentialsObj.user_id, credentialsObj.token);
|
|
|
|
|
|
if (!cosmoeClient.isAuthenticated()) {
|
|
|
- await ctx.reply("❌ Invalid credentials. Please try logging in again with /login.");
|
|
|
+ await ctx.reply("无效的凭证,请尝试使用 /login 命令重新登录");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -46,39 +46,40 @@ export async function handleCancelCommand(ctx: Context, env: Env): Promise<void>
|
|
|
const bookingsResult = await cosmoeClient.getMyBookings();
|
|
|
|
|
|
if (bookingsResult.code !== 200 || !bookingsResult.data) {
|
|
|
- await ctx.reply("❌ Could not retrieve booking details. Cannot proceed with cancellation.");
|
|
|
+ await ctx.reply("无法获取预约详情");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
const booking = bookingsResult.data.find(b => b.id === bookingId);
|
|
|
|
|
|
if (!booking) {
|
|
|
- await ctx.reply(`❌ Booking ID ${bookingId} not found.`);
|
|
|
+ await ctx.reply(`预约 ID ${bookingId} 未找到`);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// Create confirmation keyboard
|
|
|
const confirmationKeyboard = new InlineKeyboard()
|
|
|
- .text('✅ Confirm Cancellation', `confirm_cancel_${bookingId}`)
|
|
|
+ .text('确认', `confirm_cancel_${bookingId}`)
|
|
|
.row()
|
|
|
- .text('❌ Cancel', 'cancel_action');
|
|
|
+ .text('取消', 'cancel_action');
|
|
|
|
|
|
// Send confirmation message with inline keyboard
|
|
|
await ctx.reply(
|
|
|
- `Are you sure you want to cancel this booking?\n\n` +
|
|
|
- `Event: ${booking.event_name}\n` +
|
|
|
- `Date: ${booking.booking_date}\n` +
|
|
|
- `Time: ${booking.time_slot}\n` +
|
|
|
- `Status: ${booking.status}\n\n` +
|
|
|
- `⚠️ This action cannot be undone.`,
|
|
|
+ `确认取消此预约?\n\n` +
|
|
|
+ `*活动* ${booking.event_name}\n` +
|
|
|
+ `*日期* ${booking.booking_date}\n` +
|
|
|
+ `*时间* ${booking.time_slot}\n` +
|
|
|
+ `*状态* ${booking.status}\n\n` +
|
|
|
+ `⚠️ 此操作无法撤销!`,
|
|
|
{
|
|
|
+ parse_mode: "Markdown",
|
|
|
reply_markup: confirmationKeyboard,
|
|
|
}
|
|
|
);
|
|
|
}
|
|
|
} catch (error) {
|
|
|
console.error("Error handling cancel request:", error);
|
|
|
- await ctx.reply("An error occurred while preparing the cancellation request. Please try again.");
|
|
|
+ await ctx.reply("处理取消预约请求时出错,请稍后再试");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -92,13 +93,13 @@ export async function handleCancelConfirmation(ctx: Context, env: Env, action: s
|
|
|
// Get user credentials from KV storage
|
|
|
const telegramUserId = ctx.from?.id.toString();
|
|
|
if (!telegramUserId) {
|
|
|
- await ctx.editMessageText("Could not identify your Telegram user ID.");
|
|
|
+ await ctx.editMessageText("无法获取你的 Telegram 用户身份");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
const storedCredentials = await env.COSMOE_CREDENTIALS.get(telegramUserId);
|
|
|
if (!storedCredentials) {
|
|
|
- await ctx.editMessageText("You need to login first using /login username password before canceling bookings.");
|
|
|
+ await ctx.editMessageText("请先使用 /login 命令登录后再取消预约");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -109,7 +110,7 @@ export async function handleCancelConfirmation(ctx: Context, env: Env, action: s
|
|
|
cosmoeClient.setCredentials(credentialsObj.user_id, credentialsObj.token);
|
|
|
|
|
|
if (!cosmoeClient.isAuthenticated()) {
|
|
|
- await ctx.editMessageText("❌ Invalid credentials. Please try logging in again with /login.");
|
|
|
+ await ctx.editMessageText("无效的凭证,请尝试使用 /login 命令重新登录");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -117,15 +118,15 @@ export async function handleCancelConfirmation(ctx: Context, env: Env, action: s
|
|
|
const cancelResult = await cosmoeClient.cancelBooking(bookingId);
|
|
|
|
|
|
if (cancelResult.code === 200) {
|
|
|
- await ctx.editMessageText(`✅ Successfully canceled booking ID: ${bookingId}`);
|
|
|
+ await ctx.editMessageText(`成功取消预约 ID: ${bookingId}`);
|
|
|
} else {
|
|
|
- await ctx.editMessageText(`❌ Failed to cancel booking: ${cancelResult.msg || 'Unknown error'}`);
|
|
|
+ await ctx.editMessageText(`取消预约 ID: ${bookingId} 失败: ${cancelResult.msg || '未知错误'}`);
|
|
|
}
|
|
|
} else if (action === 'cancel_action') {
|
|
|
- await ctx.editMessageText('Cancellation has been canceled.');
|
|
|
+ await ctx.editMessageText('操作已取消');
|
|
|
}
|
|
|
} catch (error) {
|
|
|
console.error("Error handling cancel confirmation:", error);
|
|
|
- await ctx.editMessageText("An error occurred while processing your cancellation. Please try again.");
|
|
|
+ await ctx.editMessageText("处理取消预约请求时出错,请稍后再试");
|
|
|
}
|
|
|
}
|