C
C
Chainik02020-01-19 18:18:45
Python
Chainik0, 2020-01-19 18:18:45

Admin list/list how to write list or admin class?

Good day.
Here is the code for example

elif msg.startswith("!") and event.user_id == 57253548:
    
elif msg.startswith("!") and event.user_id == 31377746:
     

хочу создать список админов которым будет доступна эта команда, а не как я сейчас сделал ибо я  понимаю, что это лишние строки 
Кто поможет?  использую лонгпул, вк апи, страничный бот

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
sergeyfilippov4, 2020-01-19
@sergeyfilippov4

admins = [1, 2]

if msg.startswith("!") and event.user_id in admins:
    do_something()

A
Andrey, 2020-01-19
@anerev

admin_list = [341377646, 572543528]
elif msg.startswith("!") and event.user_id in admin_list:

P
pavelkhat, 2020-01-20
@pavelkhat

I have not worked with the VK bot, but if this is a frequent use, then it is better to write a function or a decorator to process such messages, and not write 1k times

elif msg.startswith("!") and event.user_id == 572543548:

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question