-1

I am writing a code for a telegram bot on video, and very quickly, as there. I'm new to this, and I need to show this bot in 5 hours. Help, please, with occurrence of a problem.As I understand it, there are some problems in the spaces between the lines, I will be very grateful if you help me as soon as possible

from aiogram.dispatcher import FSMContext
from aiogram.dispatcher.filters.state import State, StatesGroup
from aiogram import types, Dispatcher
from create_bot import dp, bot
from aiogram.dispatcher.filters import Text
from data_base import sqlite_db
from keyboards import admin_kb

ID = None

class FSMAdmin(StatesGroup):
    photo = State()
    name = State()
    description = State()

#@dp.message_handler(commands=['moderator'], is_chat_admin=True)
async def make_changes_command(message: types.Message):
    global ID
    ID = message.from_user.id
    await bot.send_message(message.from_user.id, 'Слушаю тебя, барон')#, reply_markup=button_case_admin)
    await message.delete()


# @dp.message_handler(commands='Загрузить', state=None)
 async def cm_start(message : types.Message):
if message.from_user.id == ID:
       await FSMAdmin.photo.set()
       await message.reply('Загрузи фото')


#@dp.message_handler(content_types=['photo'], state=FSMAdmin.photo)
async def load_photo(message: types.Message, state: FSMContext):
if message.from_user.id == ID:
        async with state.proxy() as data:
            data['photo'] = message.photo[0].file_id
        await FSMAdmin.next()
        await message.reply("Теперь введи название")



#@dp.message_handler(state=FSMAdmin.name)
async def load_name(message: types.Message, state: FSMContext):
    if message.from_user.id == ID:
        async with state.proxy() as data:
            data['name'] = message.text
        await FSMAdmin.next()
        await message.reply("Введи описание")

async def load_description(message: types.Message, state: FSMContext):
    if message.from_user.id == ID:
        async with state.proxy() as data:
            data['description'] = message.text
    await FSMAdmin.next()
    await sqlite.db.sql_add_command(state)
    await state.finish()

def  register_handlers_admin(dp : Dispatcher):
    dp.register_message_handler(cm_start, commands=['Загрузить'], state=None)
    dp.register_message_handler(load_photo, content_types=['photo'], state=FSMAdmin.photo)
    dp.register_message_handler(load_name, state=FSMAdmin.name)
    dp.register_message_handler(load_description, state=FSMAdmin.description)
    dp.register_message_handler(make_changes_command, commands=['moderator'], is_chat_admin=True)

Tried to change spaces and indents

  • 1
    One of your async defs is indented – tdelaney Aug 19 '23 at 23:15
  • Does this answer your question? [IndentationError unindent does not match any outer indentation level](https://stackoverflow.com/questions/54854867/indentationerror-unindent-does-not-match-any-outer-indentation-level) – PatioFurnitureIsCool Aug 19 '23 at 23:15
  • To be honest, no. I don't know exactly how to indent for this to work. help me please – Тоша Кравченко Aug 19 '23 at 23:17
  • 1
    The `async def cm_start` line has an extra space in the front, and the `if` statement that follows should be indented 4 spaces. – Tim Roberts Aug 19 '23 at 23:30
  • Welcome to Stack Overflow! [We don't do urgent fixes here](//meta.stackoverflow.com/questions/326569/under-what-circumstances-may-i-add-urgent-or-other-similar-phrases-to-my-quest), but thankfully we already have a question that covers how to fix your code, and there are only a few spots that need fixing, as Tim pointed out. Please take the [tour] to learn how this site works. – wjandrea Aug 19 '23 at 23:34

0 Answers0