don't show keyboard after card selection

This commit is contained in:
Kirill Ivlev 2024-11-13 19:03:59 +04:00
parent 666240dfb8
commit e2cf582b9f

View file

@ -20,36 +20,36 @@ export class RemoveCardFromUserCommandHandler implements ICommandHandler<RemoveC
}
async execute(command: RemoveCardFromUserCommand): Promise<any> {
const guest = await this.guestService.findById(command.telegramId);
const data = await this.sharedService.getConfig(`buttons_${command.telegramId}`);
const extra = {
reply_markup: {
remove_keyboard: false,
keyboard: [],
},
};
const buttons = JSON.parse(data.value);
let found = false;
buttons.reply_markup.keyboard.forEach((item) => {
if (item[0].text.includes(command.card.description) && !found) {
found = true;
} else {
extra.reply_markup.keyboard.push(
[ { ...item[0] } ]
)
}
});
if (extra.reply_markup.keyboard.length === 0) {
extra.reply_markup.remove_keyboard = true;
}
await this.sharedService.setConfig(`buttons_${command.telegramId}`, JSON.stringify(extra));
this.telegramService.emit<MqtMessageModel, ChatMessageRequestModel>({
cmd: CommandsConsts.SendMessage,
}, {
chatId: guest.chatId,
message: Messages.SELECT_CARD,
extra: extra,
})
// const guest = await this.guestService.findById(command.telegramId);
// const data = await this.sharedService.getConfig(`buttons_${command.telegramId}`);
// const extra = {
// reply_markup: {
// remove_keyboard: false,
// keyboard: [],
// },
// };
// const buttons = JSON.parse(data.value);
// let found = false;
// buttons.reply_markup.keyboard.forEach((item) => {
// if (item[0].text.includes(command.card.description) && !found) {
// found = true;
// } else {
// extra.reply_markup.keyboard.push(
// [ { ...item[0] } ]
// )
// }
// });
// if (extra.reply_markup.keyboard.length === 0) {
// extra.reply_markup.remove_keyboard = true;
// }
// await this.sharedService.setConfig(`buttons_${command.telegramId}`, JSON.stringify(extra));
// this.telegramService.emit<MqtMessageModel, ChatMessageRequestModel>({
// cmd: CommandsConsts.SendMessage,
// }, {
// chatId: guest.chatId,
// message: Messages.SELECT_CARD,
// extra: extra,
// })
}
}