A
A
artemk1ter2020-04-27 20:04:18
Python
artemk1ter, 2020-04-27 20:04:18

When running the script, Python writes: vk.messages.send( ^ IndentationError: expected an indented block - what's the problem?

When running the script, python writes an error:
5ea7103bcb116571581586.png
Please tell me what the problem is and how to solve it,
Here is the code:

# -*- coding: utf-8 -*-
import vk_api
from vk_api.bot_longpoll import VkBotLongPoll, VkBotEventType
from vk_api.utils import get_random_id

def main():
    """ Пример использования bots longpoll
        https://vk.com/dev/bots_longpoll
    """

    vk_session = vk_api.VkApi(token='383991cae3ff53f6742c0952ec8273a4a71b2ea72a9a76df9e683013b752b8f8aa29145ca5a59bf8bafb0')

    longpoll = VkBotLongPoll(vk_session, '176849803')
    vk = vk_session.get_api()
    for event in longpoll.listen():
            if event.obj.text == '/test':

            vk.messages.send(
                user_id=event.obj.from_id,

                random_id=get_random_id(),
                message=("Ответ на команду")
            )
            print('ok')

Thank you very much in advance.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Karbivnichy, 2020-04-27
@artemk1ter

If you translate through Google translate, it will turn out - "expected a block with an indent".
For such questions you need to tear off your hands, and go to the bathhouse! I wonder how many such questions moderators delete per day?

I
Igor, 2020-04-27
@loonny

Zero out the token you just lit, otherwise if someone uses it, YOU will be responsible.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question