Answer the question
In order to leave comments, you need to log in
Why does an error occur when working with api VKontakte via longpoll?
import random
import json
import vk_api
import time
from flask import Flask, request, json
from mysql.connector import MySQLConnection, Error
from python_mysql_dbconfig import read_db_config
import re
from vk_api.bot_longpoll import VkBotLongPoll, VkBotEventType
vk = vk_api.VkApi(token="token")
vk._auth_token()
vk.get_api()
longpoll = VkBotLongPoll(vk, id_группы)
while True:
try:
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, "message": 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, "message": event.object.text,
"random_id": 0})
except Exception as e:
print("Exception (find):", e)
Exception (find): '<' 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