Answer the question
In order to leave comments, you need to log in
Why is the bot not responding to the message?
The bot receives the message, sees it, but does not respond to it.
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, id моей группы)
while True:
for event in longpoll.listen():
if event.type == VkBotEventType.MESSAGE_NEW:
if event.object.peer_id == event.object.from_id:
print('Сообщение получено 1')
if event.object.text.lower() == "Привет":
print('Сообщение получено 2')
vk.messages.send(peer_id=event.object.peer_id, message='Привет!', random_id=0)
if event.object.text.lower() == "Привет":
Answer the question
In order to leave comments, you need to log in
I'll be a wag, but most likely, the lower() function returns hello , not Hello .
Therefore your condition is always false.
Replace string "Привет"
with string "привет"
Well, learn how to debug your code, it's a good skill.
Print the contents of the value event.object.text.lower()
before the last condition is met.
To see what value is in this variable.print(event.object.text.lower())
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question