Answer the question
In order to leave comments, you need to log in
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
This method messages.getChat
is 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 questionAsk a Question
731 491 924 answers to any question