async def start(self):
self.application = AsyncRunApplication(Application.builder().token(self.api_key).build())
self.user_states = {}
self.application.add_handler(CommandHandler("start", self.handle_bot_start))
self.application.add_handler(
CallbackQueryHandler(self.handle_menu_actions, pattern="^provide_prompt$|^edit_prompt$"))
self.application.add_handler(CallbackQueryHandler(self.handle_reveal_contact, pattern="^reveal_contact_"))
self.application.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, self.store_message))
self.application.add_handler(MessageHandler(filters.ATTACHMENT, self.store_document))
self.application.add_handler(CallbackQueryHandler(self.handle_continue, pattern="^continue_"))
self.application.add_handler(CallbackQueryHandler(self.handle_reasoning, pattern="^reasoning_"))
self.application.add_handler(CommandHandler("stop_searching", self.handle_stop_searching))
await self.application.bot.set_my_commands([
("/provide_prompt", "Создать еще одно описание"),
("/active_prompt", "Посмотреть текущий запрос"),
("/start", "Запустить бота"),
("/stop_searching","Прекратить поиск")
])
self.application.add_handler(CommandHandler("provide_prompt", self.handle_provide_prompt))
self.application.add_handler(CommandHandler("active_prompt", self.show_active_prompt))
await get_context()["sqlite_ready"]
self.start_event.set()
await asyncio.gather(
self.application.run_polling(allowed_updates=Update.ALL_TYPES, stop_signals=None),
self.poll_db(),
self.check_active_prompts(),
self.listen_to_events()
)