Answer the question
In order to leave comments, you need to log in
The bot is running but not responding. What to do?
import vk_api
from vk_api.longpoll import VkLongPoll, VkEventType
from toks import main_token
vk_session = vk_api.VkApi(token = main_token )
session_api = vk_session.get_api()
longpoll = vk_api.longpoll.VkLongPoll(vk_session)
def sender(id, text):
vk_session .method('message.send', {"user_id" : id, 'message' : text, 'random id' : 0})
for event in longpoll.listen():
if event.type == VkEventType.MESSAGE_NEW:
if event.to_me:
msg = event.text.lower()
id = event.user_id
if msg == "Hello":
sender(id, 'Hello to you too')
if msg == "Fedya sucker":
sender(id, ' Himself such')
The code works, there are no errors, but the bot does not read or respond to messages
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question