W
W
wenzeslaus2021-06-04 16:07:48
Python
wenzeslaus, 2021-06-04 16:07:48

Why is complaining about the attribute?

actually for the bot I want to make it so that when I wrote the kill command (any process), it cut down this process. I actually did this, but when I write the kill command (and some process), an error occurs
text = event.text
AttributeError: 'Event' object has no attribute 'text'
actually why does this happen and how could it be fixed?

#библиотека
import vk_api, os
from vk_api import VkUpload
from vk_api.longpoll import VkLongPoll

# ключ бота
token = "mytoken"
vk_session = vk_api.VkApi(token=token)
vk = vk_session.get_api()
longpol = VkLongPoll(vk_session)
upload = VkUpload(vk_session)


while True:
    for event in longpol.listen():
        text = event.text
        words = text.split(" ")

        if words[0] == "kill":
            os.system(f"taskkill /IM {words[1]} /F")

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeniy _, 2021-06-04
@wenzeslaus

VKLongPoll - Module for working with User Long Poll API.
You also need a bot.

longpoll = VkBotLongPoll(vk_session, 'group_id')
...
if event.type == VkBotEventType.MESSAGE_NEW:

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question