Answer the question
In order to leave comments, you need to log in
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:
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')
Answer the question
In order to leave comments, you need to log in
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?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question