| | 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): |
| | |
| | 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)) |
| |
|