Spaces:
Sleeping
Sleeping
| /** | |
| * Bot Action Handlers | |
| * Handles specific bot commands and logic to keep bot.js clean. | |
| */ | |
| const { getUserSession, setAwaitingEdit } = require('./userSession'); | |
| /** | |
| * Handles the /edit_story command. | |
| * @param {Object} ctx - Telegram context. | |
| */ | |
| async function handleEditCommand(ctx) { | |
| const userId = ctx.from.id; | |
| const session = getUserSession(userId); | |
| if (!session.lastPrompt || !session.lastStory) { | |
| console.log(`[Actions] User ${userId} tried to edit without history.`); | |
| return ctx.reply("Сначала сгенерируйте историю. Просто отправьте мне тему для поста."); | |
| } | |
| // Set state: user is now expected to send edit instructions | |
| setAwaitingEdit(userId, true); | |
| await ctx.reply("Что исправить?"); | |
| } | |
| /** | |
| * Handles the /edit_image command. | |
| * @param {Object} ctx - Telegram context. | |
| */ | |
| async function handleEditImageCommand(ctx) { | |
| const userId = ctx.from.id; | |
| const session = getUserSession(userId); | |
| // Check if we have a last image to edit | |
| if (!session.lastImage) { | |
| console.log(`[Actions] User ${userId} tried to edit image without history.`); | |
| return ctx.reply("Сначала сгенерируйте изображение."); | |
| } | |
| const { setAwaitingImageEdit } = require('./userSession'); | |
| setAwaitingImageEdit(userId, true); | |
| await ctx.reply("Опишите, как изменить изображение?"); | |
| } | |
| module.exports = { | |
| handleEditCommand, | |
| handleEditImageCommand | |
| }; | |