D
D
DaniPyzinski2019-11-22 21:55:21
Python
DaniPyzinski, 2019-11-22 21:55:21

How to implement access to information by password python bot?

implement a button, when you click on it, you are prompted to enter a login / password; if the password is correct, then display a certain text.
Tell me how to implement it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vincent, 2019-11-22
@wintreist

Here is a solution to check if the username/password is correct. It is assumed that you either separate the login\password from one message sent to the bot by the user. Or you will receive a pair of login \ password from 2 messages.

The code
def NewValideLogin(DataBase):
    DataBase[input("Введите новый валидный логин: ")] = input("Введите пароль, для нового логина: ")
    return DataBase

def RemoveLogin(DataBase):
    del DataBase[input("Введите логин, который нужно удалить: ")]
    return DataBase


DataBase = {'Admin':'AdminKrasavhicIMolodec228', 'User':'12340987'}
UserMessage1 = "Admin"
UserMessage2 = "AdminKrasavhicIMolodec228"
if UserMessage1 in DataBase:
    print('Логин засчитало')
    if UserMessage2 == DataBase[UserMessage1]:
        print('Пароль засчитало')
    else:
        print('Пароль не засчитало')
else:
    print("Логин не засчитало")

There are 2 functions in the attached code. One is for adding new login\password pairs to the list, the other is for deleting logins and passwords that are no longer needed from the list.
PS: Please note that when using these functions, you need to rewrite the DataBase variable
DataBase = NewValideLogin(DataBase)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question