R
R
RaymanPy2019-01-20 21:09:59
Python
RaymanPy, 2019-01-20 21:09:59

How to define different behavior of Telegram Bot for different users?

I have a Telegram bot similar to an online store.
How to define different behavior of Telegram Bot for different users?
Let's say there are ordinary users and there are Admins. And I want to make it work differently for admins. With advanced features. Admins will be identified by TelegramID .
But I don't know how to define them.
I would be grateful for any help)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail Trainin, 2019-01-20
@Stormx480

You have two bots. Bot A - for Mr. Admin, Bot B - for bom ... slaves.
Take out each of the bots in a separate file, you can call it that.
In the main script (where you put the webhook) do a check at the very beginning, you can use the decorator
If message.id == 'go to your admin':
botadmin.Bot()
else:
botbomzh.Bot()
Something like this, I think you understand.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question