V
V
ValeraShprot2020-04-27 17:38:59
Python
ValeraShprot, 2020-04-27 17:38:59

How to remove an error in the VK log?

import vk_api.vk_api
import random
import requests
import re
from vk_api.bot_longpoll import VkBotLongPoll, VkBotEventType

# Настройки
group_id = id 
admins = [1, 2, 3] 
mytoken = ""

vk = vk_api.VkApi(token = mytoken)
vkapi = vk.get_api()
lp = VkBotLongPoll(vk, group_id, wait = 5)

for event in lp.listen():
  if event.type == VkBotEventType.MESSAGE_NEW:
    username = event.object.from_id
    help = vk.method("users.get", {"user_ids": username})
    fullname = help[0]['first_name'] +  ' ' + help[0]['last_name']
    msg = event.object.text
    print("Пользователь: " + fullname + "\nСообщение: " + msg)

This is the log code, they are working, but when a bot (group) writes to a VK conversation, it gives an error - wrong id. How to remove this error so that the message of bots (groups) is also written to the console?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Timur Pokrovsky, 2020-04-27
@ValeraShprot

https://vk.com/dev/groups.getById

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question