K
K
Killerqu002019-01-16 21:59:09
Python
Killerqu00, 2019-01-16 21:59:09

Why doesn't the appeal from conversations to the community work?

I have this code:

import vk_api
import time
import sys
import requests
import json
import random as rnd
import vk
from vk_api.longpoll import VkLongPoll, VkEventType
token = 'token'
vk_session = vk_api.VkApi(token=token)
longpoll = VkLongPoll(vk_session)
vk = vk_session.get_api()
def sendmsg(confa, msg):
    vk.messages.send(chat_id=confa, message=msg, random_id=0)
while True:
    for event in longpoll.listen():
        if event.type == VkEventType.MESSAGE_NEW and event.text:
            lastmsg = event.text
            print(lastmsg)
            if (lastmsg=='/hellothere'):
                print(event.user_id)
                sendmsg(1, 'Test')

As a result, when I write in a PM to the community, he answers in a conversation. But I can't get the bot to receive messages from the conversation itself. Moreover, I do not receive them from Longpoll, since I have to display all the events that are a message on the screen (via print). At the same time, I write a message to the conversation, but it is not displayed on the screen.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Killerqu00, 2019-01-20
@Killerqu00

The solution was found, for this I just wrote my methods through the Requests library.

S
sudo rm -rf /, 2019-01-17
@MaxLevs

Off . The documentation says that in order to receive any messages from conversations (by default, only those in which there is an appeal to the bot are taken), you need to give the bot the rights "Access to all correspondence" or "Administrator" in the bot settings and make sure that the API version is not lower than 5.80
5c3fb3b03ff27738195466.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question