Answer the question
In order to leave comments, you need to log in
Why is the phyton bot not responding to the conversation?
I coded a bot in python, it works great in PM, but for some reason it does not work in a conversation. Here is the code:
import vk_api
from vk_api import VkApi
import requests
import random
from vk_api.bot_longpoll import VkBotLongPoll, VkBotEventType
def write_msg(rand_int, user_id, message):
vk.method('messages.send', {'user_id': user_id,'message': message, 'random_id': rand_int})
token = ""
vk = VkApi(token=token)
longpoll = VkBotLongPoll(vk, "149920968")
print("[i] - Бот успешно запущен.")
while True:
for event in longpoll.listen():
if event.type == VkBotEventType.MESSAGE_NEW and event.to_me and event.text:
if event.text == 'бот':
randint = random.randint(100000000, 900000000)
chat_id = vk.method('messages.getConversations')
chat_id = chat_id['items']
print(chat_id)
write_msg(randint, event.chat_id, "Привет")
time.sleep(5)
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