N
N
newbie632021-07-15 22:52:03
Python
newbie63, 2021-07-15 22:52:03

How to get values ​​after post?

How can the bot get the values ​​after the "submit" message. Bot receives messages: send (currency) (amount)
For example: send euro 500 and the bot should receive two values ​​(currency) and (amount)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
o5a, 2021-07-16
@newbie63

All data in message.text. Split by split and take what you need
Accordingly, for the case of "send euro 500" you need to take everything except the first element . Only it is worth adding checks (depending on the planned work logic) in case the parameters are not specified. Also, aiogram has its own method, message.get_args() returning a string of arguments, but it will return a string, which will also need to be split by split()
currency, amount = message.text.split()[1:]

B
BPRO, 2021-07-16
@BPRO

Dig towards FSM
Example for aiogram - click

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question