Answer the question
In order to leave comments, you need to log in
Problem with long poll vk_api. What to do?
I tell my husband:
import vk_api
from vk_api.utils import get_random_id
from vk_api.bot_longpoll import VkBotLongPoll, VkBotEventType
import requests
vk_session = vk_api.VkApi(token="ауе")
vk = vk_session.get_api()
longpoll = VkBotLongPoll(vk_session, "186308067")
for event in longpoll.listen():
if event.type == VkBotEventType.MESSAGE_NEW:
if event.obj.text != '':
if event.from_user:
vk.messages.send(
user_id=event.obj.from_id,
random_id=get_random_id(),
message="bruh")
Traceback (most recent call last):
File "/home/Joshmau/vkbot.py", line 12, in <module>
for event in longpoll.listen(): #Проверка действий
File "/home/Joshmau/.local/lib/python3.7/site-packages/vk_api/bot_longpoll.py", line 274, in listen
for event in self.check():
File "/home/Joshmau/.local/lib/python3.7/site-packages/vk_api/bot_longpoll.py", line 253, in check
for raw_event in response['updates']
File "/home/Joshmau/.local/lib/python3.7/site-packages/vk_api/bot_longpoll.py", line 253, in <listcomp>
for raw_event in response['updates']
File "/home/Joshmau/.local/lib/python3.7/site-packages/vk_api/bot_longpoll.py", line 214, in _parse_event
return event_class(raw_event)
File "/home/Joshmau/.local/lib/python3.7/site-packages/vk_api/bot_longpoll.py", line 160, in __init__
if self.obj.peer_id < 0:
TypeError: '<' not supported between instances of 'NoneType' and 'int'
>>>
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