W
W
wenzeslaus2021-05-30 14:38:11
Python
wenzeslaus, 2021-05-30 14:38:11

How to send processes to VK in one message?

Hello, I want to make it so that I would be sent through the bot to VK, the name of all the processes that occur on my computer.
I made such a miracle Yudo, which in principle fulfills my requirements, but it sends 1 process - 1 message. Because of what, VK makes a restriction on messages and the bot crashes.

import vk_api, json, subprocess
from vk_api import VkUpload
from vk_api.longpoll import VkEventType, VkLongPoll
vk_session = vk_api.VkApi(token=mytoken)
vk = vk_session.get_api()
longpol = VkLongPoll(vk_session)
upload = VkUpload(vk_session)

def proc(user_id):
    cmd = 'WMIC PROCESS get Caption,Processid'
    proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
    for text in proc.stdout:
            vk_session.method('messages.send', {"user_id": user_id, "message": text, "random_id": 0})

I need him to send the name of all processes (in a column), in one message, and not individually each

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
HemulGM, 2021-05-30
@wenzeslaus

Well, first collect all the lines in one variable or list, and then send. What kind of "programmers" have gone ...
And VK makes a restriction on everything api, and not on messages. You cannot make more than 3 requests per second

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question