L
L
Lin2132019-09-16 12:11:44
Python
Lin213, 2019-09-16 12:11:44

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})

---------------------------------------------------- Traceback
error
(most recent call last):
File "C:/Users/1/PycharmProjects/BOT/BOT.py", line 23, in
attachment = get_pictures.get('photo' + str(186540911) + '_' + str([457239017 ]))
TypeError: get() missing 2 required positional arguments: 'id_group' and 'vk'

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Sokolov, 2019-09-16
@Lin213

The error message says it all:
It's about this line:
We need to pass two more parameters: idgroups andvk

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question