Answer the question
In order to leave comments, you need to log in
How to fix an error when sending a photo by a bot to a VK conversation?
from vk_api.bot_longpoll import VkBotLongPoll, VkBotEventType
import vk_api
from datetime import datetime
import random
import time
import get_pictures
vk = vk_api.VkApi(token="e05174035053c8e6453c401de8c3f6857bef076fcdd92bb323c2a3108cb01aae5389ace527cd328825cf1")
vk._auth_token()
vk.get_api()
longpoll = VkBotLongPoll(vk, 186108970)
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.method("messages.send", {"peer_id": event.object.peer_id, "message": "Ку","random_id": 0})
if event.object.text.lower() == "мемы":
attachment = get_pictures.get('photo' + str(186540911) + '_' + str([457239017]))
vk.method("messages.send", {"peer_id": event.object.peer_id, "message": "Держи", "random_id": 0, "attachment": attachment})
Answer the question
In order to leave comments, you need to log in
The error message says it all:
It's about this line:
We need to pass two more parameters: id
groups andvk
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question