Z
Z
Zhenia Bel2021-05-13 20:25:17
Python
Zhenia Bel, 2021-05-13 20:25:17

How to implement input to variable in python-telegram-bot?

How to implement input to variable in python-telegram-bot?

If possible please send a sample code.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mihoe9, 2021-09-12
@Mihoe9

I don't quite understand what you're talking about, but I'll leave it here.

import telebot
bot = telebot.TeleBot('token')
@bot.message_handler(content_types=['text'])
def start(message):
    if message.text == '/start':
        bot.send_message(message.from_user.id, "Введи переменную");
        bot.register_next_step_handler(message, get_var);
def get_var(message):
    global var;
    var = message.text;
    print(var)
bot.polling()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question