A
A
andrey_levushkin2020-06-17 11:07:12
Python
andrey_levushkin, 2020-06-17 11:07:12

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)

I'm trying to check for unread messages in the VKontakte community for a subsequent response. Gives an error message:
Exception (find): '<' not supported between instances of 'NoneType' and 'int'

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2020-06-17
@SoreMix

Make the longpole version above in the group settings in VK or what do you have there?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question