M
M
merchfck2022-02-11 16:10:18
Python
merchfck, 2022-02-11 16:10:18

How to assign a nickname to each user in a VK conversation?

You need to make aliases for each participant in the VKontakte conversation. It is necessary for me that when calling the /i command, the set nickname of the person is indicated, and when /i "NIKNAME" the nickname is recorded in the database. Also, I don’t quite understand, for example, I write if "/ I" in msg: I write everything that after me to the database, but how can I make it so that later, during other interactions with the bot, he would mention the user by his nickname?

def niki():
            me0 = msg.split() # тут я убираю /я
            fragm00 = "/я"
            new_words00 = []
            for word in me0:
                if fragm00 not in word:
                    new_words00.append(word)
            nicks0 = ' '.join(new_words00)
            nicks = FoobarDB("./mydb.db")
            nicks.set("name" , nicks0) #? как тут сделать так, чтобы ник записался не в "name", а к каждому пользователю?
            nick_enter = nicks.get("name")
            vk_session.method('messages.send', {'chat_id':id, "message" : f"{nick_enter}", 'random_id' : 0})
    if "/я".lower() in msg:
        niki()

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question