N
N
not_bad_blyat2020-05-23 18:46:34
Python
not_bad_blyat, 2020-05-23 18:46:34

In PM, vk_api answers no in the conversation, why is that?

Not responding to the conversation, here is the code:

import random

import vk_api
from vk_api.longpoll import VkLongPoll, VkEventType

from commander.commander import Commander


def write_msg(user_id, message):
    vk.method('messages.send', {'peer_id': user_id, 'message': message, 'random_id': random.randint(-2147483648, +2147483648)})


token = СЕКРЕТ

vk = vk_api.VkApi(token=token)

longpoll = VkLongPoll(vk)


commander = Commander()

print("Бот запущен")

for event in longpoll.listen():

    if event.type == VkEventType.MESSAGE_NEW:

        if event.to_me:

            request = event.text

            if request == "о семье":
                f = open('family.txt',mode = 'r',encoding = 'utf-8')
                write_msg(event.peer_id, f.read())
                f.close()
                print("log: succeful send")

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question