B
B
B1oomEe2020-09-27 22:16:09
Python
B1oomEe, 2020-09-27 22:16:09

How to put just sent message into variable (pyTelegramBotAPI)?

if message.text == 'Оставить отзыв':
  bot.send_message(message.chat.id, 'Пиши')
  time.sleep(10)
  otziv = message.text
  bot.send_message('my_id', 'Вам оставили отзыв!')
  bot.send_message('my_id', otziv)


Instead of what the user writes, the bot sends me 'Leave feedback'

How can I make the bot send me what the user sent after 'Write'?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2020-09-27
@SoreMix

Use next_step_handler
https://github.com/eternnoir/pyTelegramBotAPI/blob...

if message.text == 'Оставить отзыв':
  msg = bot.send_message(message.chat.id, 'Пиши')
  time.sleep(10)
  otziv = message.text
  bot.send_message('my_id', 'Вам оставили отзыв!')
  bot.send_message('my_id', otziv)
  bot.register_next_step_handler(msg, text_step)

# ...

def text_step(message):
  print(message)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question