async def send_ui(message: Message): header = Header(_type="toolbar", title="Title", options=Options(closeable=True)) checkbox1 = Checkbox(content_id="checkbox1", title="Mark option 1", default_state=True) checkbox2 = Checkbox(content_id="checkbox2", title="Mark option 2", default_state=False, validations_rules=[ ValidationRule(type="required", value="true", error="Поле не должно быть пустым") ]) checkbox3 = Checkbox(content_id="checkbox3", title="Mark option 3", default_state=True, options=Options(text_size=H1, text_color="#FFEF00")) submit = Submit(content_id="submit_id", title="Send", form_action=FormAction(action="submit_form")) form = Form(_id="check_box_form", header=header, content=[checkbox1, checkbox2, checkbox3, submit], options=Options(fullscreen=True)) await bot.send_form(message.chat.id, form=form)
async def send_ui(message: Message): header = Header( _type="toolbar", title="Title", options=Options( closeable=True ) ) switch1 = Switch( content_id="switch_id1", title="Вы согласны с условиями?", options=Options( indent_outer=Indent( left=30, right=30, top=30, bottom=30 ) ) ) switch2 = Switch( content_id="switch_id2", title="Вы точно согласны с условиями???", default_state=False ) form = Form(_id="text_form", header=header, content=[switch1, switch2], options=Options(fullscreen=True)) await bot.send_form(message.chat.id, form=form)
def make_form() -> Form: form_id = "radiogroup_form_id" header = Header(_type="title", title="Radiogroup component", options=Options(closeable=True)) radiogroup = Radiogroup(content_id="radiogroup", title="Radiogroup", options=Options(orientation=HORIZONTAL), default_value=Item(item_id="radio_1", title="Default value"), items=[ Item(item_id="radio_1", title="First"), Item(item_id="radio_2", title="Second") ], validations_rules=[ ValidationRule(type="required", value="true", error="Have to fill it!") ]) submit = Submit(content_id="submit_id", title="Send", form_action=FormAction(action="submit_form", data_template="{" + form_id + ".radiogroup_id}")) content = [radiogroup, submit] return Form(_id=form_id, header=header, content=content)
async def send_ui(message: Message): user_info = UserInfo(content_id="user_info_id", user_id=message.chat.id) header = Header(_type="toolbar", title="Title", options=Options(closeable=True)) form = Form(_id="text_form", header=header, content=user_info, options=Options(fullscreen=True)) await bot.send_form(message.chat.id, form=form)
def make_form() -> Form: form_id = "input_form_id" header = Header(_type="title", title="Input component", options=Options(closeable=True)) money_input = Input(content_id="input_money_id", title="Input Money", placeholder="Enter tenge here", options=Options(input_type=input_type.MONEY, currency=currency.KZT), validation_rules=[ ValidationRule(type="required", value="true", error="This field is required") ]) double_input = Input(content_id="input_double_id", title="Input Double", placeholder="Enter double value here", options=Options(input_type=input_type.DOUBLE), validation_rules=[ ValidationRule(type="required", value="true", error="This field is required") ]) number_input = Input(content_id="input_number_id", title="Input Number", placeholder="Enter decimal value here", options=Options(input_type=input_type.NUMBER), validation_rules=[ ValidationRule(type="required", value="true", error="This field is required") ]) text_input = Input(content_id="input_text_id", title="Input Text", placeholder="Enter text here", options=Options(input_type=input_type.TEXT), mask="[______]", validation_rules=[ ValidationRule(type="required", value="true", error="This field is required") ]) submit = Submit( content_id="submit_id", title="Send", form_action=FormAction( action="submit_form", data_template= "Money: {%s.input_money_id},\nDouble: {%s.input_double_id}, \n" % (form_id, form_id) + "Number: {%s.input_number_id},\nText: {%s.input_text_id}" % (form_id, form_id))) content = [money_input, double_input, number_input, text_input, submit] return Form(_id=form_id, header=header, content=content)
def make_form() -> Form: form_id = "bottom_bar_form_id" header = Header(_type="title", title="Bottom bar component", options=Options(closeable=True)) bottom_bar = BottomBar(content_id="bottom_bar_id", title="Bottom Bar", form_action=FormAction( action="submit_form", data_template="Message from bottom bar")) return Form(_id=form_id, header=header, content=[], bottom_bar=bottom_bar)
async def send_image_form(message: Message): file_metadata = FileMetadata(file_type="image", file_id="YOUR IMAGE ID", file_name="YOUR IMAGE NAME") image_options = Options(width=100, height=100) image = Image(content_id="pic", file_metadata=file_metadata, options=image_options) header = Header(_type="toolbar", title="Title") form = Form(_id="lol", header=header, content=image) await bot.send_form(message.chat.id, form=form)
async def send_ui(message: Message): item_info = ItemInfo(content_id="item_info_id", title="Item info title", subtitle="Subtitle for item info", options=Options(title_lines_count=2, subtitle_lines_count=3)) header = Header(_type="toolbar", title="Title", options=Options(closeable=True)) form = Form(_id="lol", header=header, content=item_info, options=Options(fullscreen=True)) await bot.send_form(message.chat.id, form=form)
async def send_ui(message: Message): header = Header(_type="toolbar", title="Title", options=Options(closeable=True)) text = LabeledText( content_id="testid", label="Some short title for label", title= "Label text. It has fixed decoration and formatting, cannot change it with options", options=Options(indent_inner=Indent(right=5, top=5, bottom=10))) form = Form(_id="lol", header=header, content=text, options=Options(fullscreen=True)) await bot.send_form(message.chat.id, form=form)
async def send_ui(message: Message): header = Header(_type="toolbar", title="Title", options=Options(closeable=True)) file = await bot.upload_file("images/cat.jpg") items = [] for i in range(3): items.append( Item(item_id="item" + str(i), file_metadata=FileMetadata( file_id=file.get(UPLOADED_FILES)[0]["fileId"], file_type="image", file_name=file.get(UPLOADED_FILES)[0]["fileName"]))) slider = Slider(content_id="slider", items=items) form = Form(_id="lol", header=header, content=slider) await bot.send_form(message.chat.id, form=form)
def make_form() -> Form: form_id = "text_area_form_id" header = Header(_type="title", title="Text area component", options=Options(closeable=True)) text_area = TextArea( content_id="text_area_id", title="Text Area", text="", placeholder="Enter your text here", validations_rules=[ValidationRule(type="required", value="true", error="You must fill this area")] ) submit = Submit( content_id="submit_id", title="Send", form_action=FormAction(action="submit_form", data_template="{"+form_id+".text_area_id}") ) content = [text_area, submit] return Form(_id=form_id, header=header, content=content)
async def send_ui(message: Message): header = Header( _type="toolbar", title="Title", options=Options( closeable=True ) ) image_picker = MediaPicker( content_id="image_picker1", title="Image media picker title", options=Options( media_type=PHOTO, height=20, width=80, max_count=1 ), validations_rules=[ValidationRule(type="required", value="1", error="Выберите хотя бы 1 файл")] ) video_picker = MediaPicker( content_id="video_picker1", title="Video media picker title", options=Options( should_open_editor=False, media_type=VIDEO, height=30, width=80, max_count=2 ), validations_rules=[ValidationRule(type="required", value="1", error="Выберите хотя бы 1 файл")] ) submit = Submit( content_id="submit_id", title="Send", form_action=FormAction( action="submit_form" ) ) form = Form( _id="media_picker_form", header=header, content=[image_picker, video_picker, submit], options=Options(fullscreen=True) ) await bot.send_form(message.chat.id, form=form)
async def send_ui(message: Message): # Header setting button_header = Header(_type="title", title="Button component", options=Options(closeable=True)) # Content setting button_content = Button(content_id="button_id", title="Custom button", button_type="default", options=Options(background_color="filled_dark"), form_action=FormAction(action="send_message", data_template="")) # Form setting form = Form(_id="form_id", header=button_header, content=button_content) # Form sending await bot.send_form(message.chat.id, form=form)
async def send_ui(message: Message): header = Header(_type="toolbar", title="Title", options=Options(closeable=True)) date_picker = DatePicker( content_id="date_id_1", title="Date title", selected_date="01-01-2019", options=Options(min_date="01-01-2018", max_date="01-01-2030"), validations_rules=[ ValidationRule(type="required", value="true", error="Это поле обязательно для заполнения") ]) submit = Submit(content_id="submit_id", title="Send", form_action=FormAction(action="submit_form")) form = Form(_id="date_picker_form", header=header, content=[date_picker, submit], options=Options(fullscreen=True)) await bot.send_form(message.chat.id, form=form)
async def send_submit_form(message: Message): form_options = Options( fullscreen=True ) header_options = Options( closeable=True ) header = Header( _type="toolbar", title="Title", options=header_options ) form_action = FormAction( action="send_private_data", data_template="phone" ) submit = Submit( content_id="lol", form_action=form_action, title="отправь мой номер" ) form = Form(_id="any id", header=header, content=submit, options=form_options) await bot.send_form(message.chat.id, form=form)
async def send_ui(message: Message): header = Header(_type="toolbar", title="Title", options=Options(closeable=True)) text1 = Text(content_id="testid", title="New test text for show before divider", options=Options(text_size=H1, text_style=BOLD, text_color="#000000", indent_inner=Indent(right=5, top=5, bottom=10))) text2 = Text(content_id="testid2", title="New test text for show after divider", options=Options(text_size=H3, text_color="#442B83", indent_inner=Indent(right=10, top=10, bottom=1))) divider = Divider(content_id="dividerid") form = Form(_id="text_form", header=header, content=[text1, divider, text2], options=Options(fullscreen=True)) await bot.send_form(message.chat.id, form=form)
async def send_ui(message: Message): header = Header(_type="toolbar", title="Simple Catalog", options=Options(closeable=True)) simple_catalog_items = [] for i in range(20): simple_catalog_items.append( Item(item_id=f"item_id_{i}", title=f"item_title_{i}", subtitle=f"item_subtitle_{i}")) simple_catalog = SimpleCatalog( content_id="simple_catalog_id", items=simple_catalog_items, options=Options(type="list", item_type="item_card", columns_count=2, show_divider=True, item_right_icon_resource="ic_right_arrow")) form = Form(_id="form_id", header=header, content=simple_catalog) await bot.send_form(message.chat.id, form=form)