Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

158
Vistas
The condition is repeated every time. How to fulfill the condition only once? Telegram bot

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); 
    }
  } 
  //})
//})

}

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda