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