N
N
nnikolyaa2020-06-22 13:44:43
Python
nnikolyaa, 2020-06-22 13:44:43

How to make messages.getChat match the name of the conversation in str?

How to send a question to the VK server so that the answer is the name of the conversation from which the message came

title=messages.getChatPreview()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
WolfInChains, 2020-06-22
@nnikolyaa

This method messages.getChatis not available for bots.
In your case you can usemessages.getConversationsById

def get_chat_title(chat):
    return vk.method("messages.getConversationsById", {"peer_ids": chat})['items'][0]['chat_settings']['title']

while True:
    try:
       for event in longpoll.listen():
           if event.type == VkBotEventType.MESSAGE_NEW:
               print('Название беседы: ' + get_chat_title(event.obj.peer_id))
    except Exception as e:
        print(repr(e))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question