File size: 1,153 Bytes
799fa63
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import time
import logging
import asyncio
from aiogram import Bot, Dispatcher, types
from aiogram.utils import executor
from env import TOKEN
from test_copy import process_text

bot = Bot(TOKEN)
dp = Dispatcher(bot=bot)

@dp.message_handler(commands=['start'])
async def start_handler(message: types.Message):
    user_id = message.from_user.id
    user_name = message.from_user.first_name
    logging.info(f'{user_id} {time.asctime()}')

    await message.reply(f"Hi, {user_name} !!!!!\nвведите текст:")

@dp.message_handler(state=None)
async def message_handler(message: types.Message):
    processed_text = process_text(message.text)
    await message.reply(f"Вот исправленный текст\n\n{processed_text}")

async def on_startup(dp):
    await bot.send_message(chat_id='your_chat_id', text='Bot has been started')

async def on_shutdown(dp):
    # Perform cleanup (if any) here
    pass

if __name__ == '__main__':
    loop = asyncio.get_event_loop()
    loop.run_until_complete(on_startup(dp))
    try:
        executor.start_polling(dp, skip_updates=True)
    finally:
        loop.run_until_complete(on_shutdown(dp))