Exemplo n.º 1
0
    async def confused(self) -> None:
        """
        This is called when the user sends a message that triggers no
        transitions.
        """

        self.send(
            lyr.Markdown(t.HELP),
            lyr.Markdown(t.START_CMD),
            lyr.Markdown(t.SEARCH_CMD),
        )
Exemplo n.º 2
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)],
                ]
            )
        )
Exemplo n.º 3
0
    async def handle(self, context) -> None:
        
        bisector = FrameXBisector(settings.VIDEO_NAME)
        limit_left = 0
        limit_right = bisector.count
        current_frame = int((limit_left + limit_right) / 2)
        context.update({
            'current_frame': current_frame,
            'limit_left': limit_left,
            'limit_right': limit_right
        })

        image_url = urljoin(settings.BASE_VIDEO_API_URL,
                    f'video/{quote(settings.VIDEO_NAME)}/frame/{quote(f"{current_frame}")}/')
        self.send(
            lyr.Markdown(t('DID_ROCKET_LAUNCH', frame_number=current_frame, image_url=image_url)),
            tgr.InlineKeyboard([
                [tgr.InlineKeyboardCallbackButton(
                    text='Yes',
                    payload={'decreaseFrame': True}
                )],
                [tgr.InlineKeyboardCallbackButton(
                    text='No',
                    payload={'decreaseFrame': False}
                )]
            ]),
        )
Exemplo n.º 4
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
Exemplo n.º 5
0
def test_markdown():
    pattern = ('^Markdown+ '
               '(InlineKeyboard|ReplyKeyboard|ReplyKeyboardRemove)? '
               'Reply?$'
               '|^Markdown InlineKeyboard? Reply? Update$')

    ce = ClassExp(pattern)

    assert repr(ce._compiled_expression) == \
        "re.compile('^(?:Markdown,)+((?:InlineKeyboard,)|(?:ReplyKeyboard,)|" \
        "(?:ReplyKeyboardRemove,))?(?:Reply,)?$" \
        "|^(?:Markdown,)(?:InlineKeyboard,)?(?:Reply,)?(?:Update,)$')"

    assert ce.match([
        lyr.Markdown(''),
        tgr.InlineKeyboard([]),
        tgr.Reply(),
        tgr.Update(),
    ])
Exemplo n.º 6
0
 async def handle(self, context) -> None:
     # Update the frame
     current_frame = int((context.get('limit_left') + context.get('limit_right')) / 2)
     context['current_frame'] = current_frame
     
     image_url = urljoin(settings.BASE_VIDEO_API_URL,
                 f'video/{quote(settings.VIDEO_NAME)}/frame/{quote(f"{current_frame}")}/')
     
     self.send(
         lyr.Markdown(t('DID_ROCKET_LAUNCH', frame_number=current_frame, image_url=image_url)),
         tgr.InlineKeyboard([
             [tgr.InlineKeyboardCallbackButton(
                 text='Yes',
                 payload={'decreaseFrame': True}
             )],
             [tgr.InlineKeyboardCallbackButton(
                 text='No',
                 payload={'decreaseFrame': False}
             )]
         ]),
     )