v1.6.0: max_bot fixes — feature keys, flush→commit, test-run, categories, broadcast page, proxy error handling, deploy scripts
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
from app.settings_cache import SettingsCache
|
||||
from app.conversation import get_or_create_user, get_template_rendered
|
||||
from app.fsm import BotState, FSM
|
||||
from app.keyboards.inline import build_main_menu_buttons
|
||||
|
||||
|
||||
async def handle_my_objects(bot, user_data: dict, db, max_api):
|
||||
max_user_id = user_data["user_id"]
|
||||
text = user_data.get("text", "").strip()
|
||||
|
||||
if FSM.get_state(max_user_id) != BotState.FEATURE_MY_OBJECTS:
|
||||
FSM.set_state(max_user_id, BotState.FEATURE_MY_OBJECTS)
|
||||
user = await get_or_create_user(db, max_user_id)
|
||||
await max_api.send_message(max_user_id,
|
||||
"🏢 **Мои объекты**\n\n"
|
||||
"Укажите название вашей компании для поиска объектов."
|
||||
)
|
||||
return
|
||||
|
||||
if not text:
|
||||
await max_api.send_message(max_user_id, "Укажите название компании.")
|
||||
return
|
||||
|
||||
from app.integrations.portal_db import get_objects_for_customer
|
||||
objects = await get_objects_for_customer(db, text)
|
||||
|
||||
if not objects:
|
||||
await max_api.send_message(max_user_id, "Объекты не найдены. Проверьте название компании.")
|
||||
else:
|
||||
lines = [f"🏢 **{obj.name}** — {obj.status}" for obj in objects[:10]]
|
||||
msg = "Ваши объекты:\n\n" + "\n".join(lines)
|
||||
if len(objects) > 10:
|
||||
msg += f"\n\n...и ещё {len(objects) - 10} объектов"
|
||||
await max_api.send_message(max_user_id, msg, format="markdown")
|
||||
|
||||
FSM.transition(max_user_id, "done")
|
||||
buttons = build_main_menu_buttons()
|
||||
menu_text = await get_template_rendered(db, "main_menu")
|
||||
await max_api.send_message_with_keyboard(max_user_id, menu_text, buttons)
|
||||
Reference in New Issue
Block a user