Answer the question
In order to leave comments, you need to log in
How to record 2 next messages of the user, and issue a response?
I am creating a bot for a microcredit company. Walking through the user menu in one of the sections, first enter the loan term in days, and then the amount. What should the bot answer about its final return.
Example:
bot: enter the number of days
user: 30
bot: enter the loan amount
user: 30000
Bot: The overpayment amount will be 3000 rubles. The total amount is 33000.
In development, a complete newbie, sorry
@bot.callback_query_handler(func=lambda c: True)
def inline(c):
if c.data == 'Зaказать займ':
bot.edit_message_text(chat_id=c.message.chat.id, message_id=c.message.message_id, text="""*Расчитать займ*
Введите сумму получения займа
от *100 000* до *5 000 000*.""", parse_mode='Markdown')
Answer the question
In order to leave comments, you need to log in
Save responses to the database and count them for each user response, or wait for a specific response, or wait for a response after a specific bot message. If the quantity is suitable, then only answer.
@bot.callback_query_handler(func=lambda c: True)
def inline(c):
if c.data == 'Calculate loan':
bot.edit_message_text(chat_id=c.message.chat.id, message_id=c.message.message_id , text="""*Calculate loan*
Enter the loan amount
from *100,000* to *5,000,000*.""", parse_mode='Markdown')
bot.register_next_step_handler(inline, rasch)
def rasch(m):
day = str(message_from_user.text)
workfile = open("fi2.py", "w+")
workfile.write("b=" + day)
workfile.close()
bot.send_message(m.message.chat.id, 'text')
gives the following error and the bot stops:
chat_id = message.chat.id
AttributeError: 'function' object has no attribute 'chat'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question