What are the errors in this condition, because it is repeated? 'event 7' is button. Everything happens in an asynchronous function. I have seven conditions (seven buttons). Each button is repeated after pressing once, but the seventh condition is repeated each time and kills the chat. I can't put more code How to improve this?
if (msg.text === 'event 7') {
await bot.sendMessage(msg.chat.id, 'message 15', {
reply_markup: {
remove_keyboard: true
}
})
await bot.sendMessage(msg.chat.id, 'message 16')
await bot.sendMessage(msg.chat.id, 'message 17', {
reply_markup: {
keyboard: [
['yes'],
['no'],
]
}
})
const Cabel = msg.text
if (Cabel) {
const query = `INSERT INTO socialobject (Cabel) Value '%${Cabel}%'`;
//await sequelize.query(query);
}
//bot.on('message', async msg => {
if (msg.text === 'yes' || 'no') {
await bot.sendMessage(msg.chat.id, 'message 18', {
reply_markup: {
remove_keyboard: true
}
})
await bot.sendMessage(msg.chat.id, 'object 1')
await bot.sendMessage(msg.chat.id, 'object 2')
await bot.sendMessage(msg.chat.id, 'object 3')
await bot.sendMessage(msg.chat.id, 'object 4')
await bot.sendMessage(msg.chat.id, 'object 5')
await bot.sendMessage(msg.chat.id, 'object 6')
await bot.sendMessage(msg.chat.id, 'object 7')
await bot.sendMessage(msg.chat.id, 'message 19', {
reply_markup: {
keyboard: [
['yes'],
['no'],
]
}
})
const socialObjects = msg.text
if (socialObjects) {
const query = `INSERT INTO socialobject (socialObjects) Value '%${socialObjects}%'`;
//await sequelize.query(query);
}
}
//bot.on('message', async msg => {
if (msg.text === 'yes' || 'no') {
await bot.sendMessage(msg.chat.id, 'message 20', {
reply_markup: {
remove_keyboard: true
}
})
await bot.sendMessage(msg.chat.id, 'message 21', {
reply_markup: {
keyboard: [
['yes'],
['no'],
]
}
})
const socialObjectName = msg.text
if (socialObjectName) {
const query = `INSERT INTO socialobject (socialObjectName) Value '%${socialObjectName}%'`;
//await sequelize.query(query);
}
}
//})
//})
}