<type><owner_id>_<media_id>
, а в ссылке вообще другой import vk_api
from vk_api.bot_longpoll import VkBotLongPoll, VkBotEventType
from vk_api.utils import get_random_id
import time, datetime
def write_message(id, message):
vk.method('messages.send', {'chat_id': id, 'message': message, 'random_id': 123456})
token = "ТОКЕН"
vk = vk_api.VkApi(token=token) # Авторизуемся как сообщество
longpoll = VkBotLongPoll(vk, group_id = 'ID ГРУППЫ')
print("Бот запущен")
for event in longpoll.listen():
if event.type == VkBotEventType.MESSAGE_NEW:
try:
if event.obj.attachments != []:
if event.obj.attachments[0]['type'] == 'photo':
print("A")
elif event.obj.attachments[0]['type'] == 'wall':
print("B")
elif event.obj.attachments[0]['type'] == 'video':
print("C")
else:
print("D")
except:
print("Тип не найден.")
else:
pass #Игнорирует все сообщения кроме выше...
for event in longpoll.listen():
if event.type == VkBotEventType.MESSAGE_NEW:
try:
if event.obj.attachments != []:
if event.obj.attachments[0]['type'] == 'photo':
print("A")
elif event.obj.attachments[0]['type'] == 'wall':
print("B")
elif event.obj.attachments[0]['type'] == 'video':
print("C")
else:
print("D")
except:
print("Тип не найден.")