Beispiel #1
0
def test_keyboard_serialize():
    k = ReplyKeyboard(
        [[LocationKeyboardButton('foo')]],
        resize_keyboard=True,
        one_time_keyboard=True,
        selective=True,
    )

    assert run(k.serialize(None)) == {
        'keyboard': [[{
            'text': 'foo',
            'request_location': True,
        }]],
        'resize_keyboard': True,
        'one_time_keyboard': True,
        'selective': True,
    }
Beispiel #2
0
def test_patch_register():
    register = {}

    k = ReplyKeyboard([[KeyboardButton(
        text='Foo',
        choice='foo',
    )]])

    run(k.patch_register(register, None))

    assert register == {
        'choices': {
            'foo': {
                'intent': None,
                'text': 'Foo',
            }
        }
    }
Beispiel #3
0
    async def handle(self):
        name = await self.request.user.get_friendly_name()

        self.send(
            lyr.Text(t("WELCOME", name=name)),
            ReplyKeyboard(
                keyboard=[
                    [KeyboardButton(t.START)],
                ]
            )
        )
Beispiel #4
0
    async def handle(self, context):
        analyzer = FrameXAnalyzer(**context["frame_analyzer"])

        self.send(
            lyr.Markdown(t(
                "IMAGE",
                frame=analyzer.actual_frame,
                url=analyzer.actual_frame_url
            )),
            lyr.Markdown(t.QUESTION),
            ReplyKeyboard(
                keyboard=[
                    [KeyboardButton(t.YES), KeyboardButton(t.NO)],
                ]
            )
        )
Beispiel #5
0
    async def handle(self, context):
        if "frame_analyzer" in context:
            del context["frame_analyzer"]
        analyzer = FrameXAnalyzer()

        self.send(
            lyr.Markdown(t(
                "IMAGE",
                frame=analyzer.actual_frame,
                url=analyzer.actual_frame_url
            )),
            lyr.Markdown(t.QUESTION),
            ReplyKeyboard(
                keyboard=[
                    [KeyboardButton(t.YES), KeyboardButton(t.NO)],
                ]
            )
        )
        context["frame_analyzer"] = analyzer.instance_data