N
N
nintendolyub2020-05-28 00:18:07
Python
nintendolyub, 2020-05-28 00:18:07

What is the problem with python bot?

It seems to compile but doesn't work.

from vk_api.bot_longpoll import VkBotLongPoll, VkBotEventType
import vk_api

vk = vk_api.VkApi(token="токен")

vk._auth_token()

vk.get_api()

longpoll = VkBotLongPoll(vk, 186308067)

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, "привет": event.object.text,
                                                "random_id": 0})
            elif event.object.peer_id == event.object.from_id:
                if event.object.text.lower() == "привет":
                    vk.method("messages.send", {"user_id": event.object.from_id, "привет": event.object.text,
                                                "random_id": 0})

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question