i am developing a telegram bot.
there are commands and in my case it's
/leaderboard
commands can have parameters (basically anything following the command).
i would like to add a parameter int for a page and an int param for category. they both are optional.
i was wondering to do something like:
/leaderboard {page} {category}
so i can do:
page, category = text.split(" ")
since both are optional my problem is: how can i get rid of the problem that i don't know if the first arg is referred to page or category (in case page is not specified and left as optional). Because if the user doesn't specify the page, the category takes the first place.
i would like to make it userfriendly.
i was thinking something like:
/leaderboard page={int} categ={int}
and then
for arg in text.split(" "):
if arg.startswith("page"):
page = arg.split("=")[1]
elif arg.startswith("categ"):
categ = arg.split("=")[1]
i just wrote the code here so it may be wrong, but i am more worried about the concept to use, not if in the code. So i ask if you have solutions better than these. Thanks in advance.