#!/usr/bin/env python
import random
import vk
import vk_api
import vkapi
from vk_api.bot_longpoll import VkBotLongPoll, VkBotEventType
token = "тут токен"
access_token = "сервисный ключ"
group_id = "-186540911"
vk_session = vk_api.VkApi(token=token)
vk = vk_session.get_api()
longpoll = VkBotLongPoll(vk_session, 186108970)
def get_random_wall_picture(group_id, token):
max_num = vk.photos.get(owner_id=group_id, album_id='wall', count=0, access_token=token)['count']
num = random.randint(1, max_num)
photo = vk.photos.get(owner_id=str(group_id), album_id='wall', count=1, offset=num, access_token=token)['items'][0]['id']
attachment = 'photo' + str(group_id) + '_' + str(photo)
while True:
for event in longpoll.listen():
if event.type == VkBotEventType.MESSAGE_NEW:
if event.object.peer_id != event.object.from_id:
if event.object.text.lower() == "гуг":
vk.messages.send(peer_id=event.object.peer_id, message='ГЭНГ', random_id=0)
if event.object.text.lower() == "мемы":
get_random_wall_picture(-186540911)
Ошибок нет, бот просто не реагирует на сообщение "мемы"