Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

153
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda