#!/usr/bin/env python
from vk_api.bot_longpoll import VkBotLongPoll, VkBotEventType
import vk_api
from datetime import datetime
import random
import time
import get_pictures
import vk
token = "тут мой токен"
vk_session = vk_api.VkApi(token=token)
vk = vk_session.get_api()
longpoll = VkBotLongPoll(vk_session, 186108970)
def get_random_wall_picture(group_id):
max_num = vk.photos.get(owner_id=-186540911, 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)
return vk.messages.send(peer_id=event.object.peer_id, message='Держи', attachment=attachment, random_id=0)
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(-186108970)
-----------------ошибка--------------
Traceback (most recent call last):
File "C:/Users/1/PycharmProjects/BOT/BOT.py", line 32, in
get_random_wall_picture(-186108970)
File "C:/Users/1/PycharmProjects/BOT/BOT.py", line 17, in get_random_wall_picture
max_num = vk.photos.get(owner_id=-186540911, album_id='wall', count=0, access_token=token)['count']
File "C:\Users\1\PycharmProjects\BOT\venv\lib\site-packages\vk_api\vk_api.py", line 682, in __call__
return self._vk.method(self._method, kwargs)
File "C:\Users\1\PycharmProjects\BOT\venv\lib\site-packages\vk_api\vk_api.py", line 641, in method
raise error
vk_api.exceptions.ApiError: [27] Group authorization failed: method is unavailable with group auth.