Example #1
0
async def get_data(dialog_manager: DialogManager, **kwargs):
    return {
        "name": "Tishka17",
        "age": 19,
        "now": datetime.now().time().strftime("%H:%M:%S"),
        "progress": dialog_manager.current_context().dialog_data.get("progress", 0),
        "progress2": dialog_manager.current_context().dialog_data.get("progress2", 0),
    }
Example #2
0
async def get_data(dialog_manager: DialogManager, **kwargs):
    return {
        "stack": dialog_manager.current_stack(),
        "context": dialog_manager.current_context(),
        "now": datetime.datetime.now(),
        "counter":
        dialog_manager.current_context().dialog_data.get("counter", 0),
        "fruits": [
            ("Apple", 1),
            ("Pear", 2),
            ("Orange", 3),
            ("Banana", 4),
        ]
    }
Example #3
0
async def set_city_geojson(c: types.CallbackQuery, button: kbd.Button, manager: DialogManager):
    manager.context.set_data("is_area_specified", False)
    city_select: kbd.Select = manager.dialog().find("city_select")
    city_name = city_select.get_checked(manager)
    geojson_path = get_city_gjs_path(city_name)
    manager.context.set_data("geojson", geojson_path)
    await manager.dialog().next(manager)
Example #4
0
async def area_image_handler(m: types.Message, dialog: Dialog, manager: DialogManager):
    city_select: kbd.Select = manager.dialog().find("city_select")
    city_name = city_select.get_checked(manager)

    if not m.photo:
        geojson_path = get_city_gjs_path(city_name)
        manager.context.set_data("geojson", geojson_path)
        await m.reply("There's no photo in your message.\nSkipping.")
        await dialog.next(manager)
        return

    area_img = BytesIO()
    await m.photo[-1].download(area_img, seek=True)

    try:
        geojson_path, selected_image_bytes = await run_blocking(area_to_geojson, city_name, area_img)
        manager.context.set_data("is_area_specified", True)
        await m.reply_photo(types.InputFile(selected_image_bytes), caption="Defined area")
    except ValueError as e:
        logger.exception(e)
        geojson_path = get_city_gjs_path(city_name)
        manager.context.set_data("is_area_specified", False)
        await m.reply("Can't define area, error occured. Using full map")

    manager.context.set_data("geojson", geojson_path)
    await dialog.next(manager)
Example #5
0
async def get_data(dialog_manager: DialogManager, **kwargs):
    age_select: Select = dialog_manager.dialog().find("w_age")
    age = age_select.get_checked(dialog_manager)
    return {
        "name": dialog_manager.context.data("name", ""),
        "age": age,
        "can_smoke": age in ("18-25", "25-40", "40+"),
    }
Example #6
0
async def get_text(dialog_manager: DialogManager, **kwargs):
    selected = await get_selected(dialog_manager)
    text = dialog_manager.current_intent().data
    return {
        "selected": selected["selected"],
        "text": text if text is not None else "Отправьте мне текст рассылки",
        "now": datetime.now().isoformat(),
    }
Example #7
0
async def start_bg(c: CallbackQuery, button: Button, manager: DialogManager):
    await manager.start(Bg.progress)
    asyncio.create_task(background(c, manager.bg()))
Example #8
0
async def fun(c: CallbackQuery, button: Button, manager: DialogManager):
    await c.message.answer("It is fun!")
    asyncio.create_task(background(c, manager.bg()))
Example #9
0
async def get_data2(dialog_manager: DialogManager, **kwargs):
    return {
        "text": dialog_manager.current_context().start_data,
        "now": datetime.now().isoformat(),
    }
Example #10
0
async def on_input(m: Message, dialog: Dialog, manager: DialogManager):
    manager.current_context().dialog_data["name"] = m.text
    await dialog.next(manager)  # rendering tool cannot detect this call
Example #11
0
async def on_click(c: CallbackQuery, button: Button, manager: DialogManager):
    counter = manager.current_context().dialog_data.get("counter", 0)
    manager.current_context().dialog_data["counter"] = counter + 1
Example #12
0
async def get_image(dialog_manager: DialogManager, **kwargs):
    image_id = dialog_manager.current_intent().data
    return {
        "image_id":
        image_id if image_id is not None else "Прикрепите фотографию"
    }
Example #13
0
async def get_bg_data(dialog_manager: DialogManager, **kwargs):
    return {
        "progress":
        dialog_manager.current_context().dialog_data.get("progress", 0)
    }
Example #14
0
async def on_input(m: Message, dialog: Dialog, manager: DialogManager):
    manager.current_context().dialog_data["name"] = m.text
    await dialog.next(manager)