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), )
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)], ] ) )
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} )] ]), )
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
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(), ])
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} )] ]), )