Попытка запустить telethon+aiogram в одной программе

Вот у меня есть такой код

from aiogram import Bot, Dispatcher, types
from aiogram.utils import executor
from telethon import TelegramClient, sync, events
from telethon import events
import asyncio
import aioschedule
API_TOKEN = ''
api_id = 0
api_hash = ''
# Initialize bot and dispatcher
async def register_handler():
    print("lol")
async def init_bot() -> TelegramClient:
    client = TelegramClient(
                 session="main.session",
                 api_hash=api_hash,
                 api_id=api_id,
             )
    await client.start()

    client.add_event_handler(
        register_handler,
        events.NewMessage(incoming=True),
    )


    return client
loop = asyncio.get_event_loop()
print("lol")
bot = Bot(token=API_TOKEN)
dp = Dispatcher(bot)
def iniy():
    client = await init_bot()
    await client.connect()
    # the below code is non-blocking
    asyncio.create_task(client.run_until_disconnected())
iniy()
@dp.message_handler(commands=['start', 'help'])
async def send_welcome(message: types.Message):
    await message.reply("Hi!\nI'm EchoBot!\nPowered by aiogram.")
executor.start_polling(loop=loop,dispatcher=dp, skip_updates=False)

Тут я пытаюсь объединить бот и клиент телеграмм. Но на выходе получаю ошибку

    client = await init_bot()
             ^
SyntaxError: 'await' outside async function

Ответы (0 шт):