Z
Z
zombieman2019-08-08 23:26:05
Python
zombieman, 2019-08-08 23:26:05

How to set up data forwarding from a bot?

@bot.message_handler(commands=['help'])  
def start(message):
  sent = bot.send_message(message.chat.id, 'введите номер телефона')
  bot.register_next_step_handler(sent, hello)

def hello(message):
    open('problem.txt', 'w').write(message.chat.id + ' | ' + message.text + '||')
    bot.send_message(message.chat.id, 'Thank you!')
    #bot.send_message(message.chat.id + ' | ' + message.text)
    #bot.send_message(message.chat.id, 'Привет, {name}! Рад тебя видеть!'.format(name=message.text))

It is necessary for the bot to request a number and so on from the user and send it either to a txt file or to the specified person's personal.
I don’t have time to figure it out because of the timing and lack of knowledge.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Yakushenko, 2019-08-09
@zombieman

Here is the implementation of the state machine using the aiogram library as an example, you need it. Follow the example and do it, the concept is the same.
Here is the .txt entry:

with open('file.txt', 'w') as f:
    f.write('some text\n')

Sending a message is already in your code.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question