B4J Question jtelegrambot -how make keyboard

Discussion in 'B4J Questions' started by behnam_tr, Jul 26, 2019.

  1. behnam_tr

    behnam_tr Member

    hi

    i want to to make keyboard with jtelegrambot
    i want to have three button in one row
    how can i do it

    Code:
    Dim ib As KeyboardButtonBuilder
            ib.Initialize
            
            
    Dim mark As ReplyKeyboardMarkup
            mark.initialize(ib.newRow.newButton(
    "test2").newRow.newButton("test3").newRow.build,True,False,False)
            
    Dim buttons As Message = jtb.sendMessage(jtb.byId(from.Id),"please select......","MARKDOWN",False,False,message.MessageId,mark)
            glmap.Put(buttons.MessageId,buttons)
     
  2. DonManfred

    DonManfred Expert Licensed User

    why you are adding a new row after each button?
    Code:
    Dim ibld As InlineKeyboardButtonBuilder
            
    Dim mark As InlineKeyboardMarkup
            mark.initialize(ibld.Initialize.newRow.newButton(
    "1").withCallbackData("BTN1").newButton("2").withCallbackData("BTN2").newButton("3").withCallbackData("BTN3").newRow.newButton("Google").withUrl("https://www.google.com").newRow.build)
            
    Dim buttons As Message = jtb.sendMessage(jtb.byId(from.Id),"Click the Button!","MARKDOWN",False,False,message.MessageId,mark)
     
  3. behnam_tr

    behnam_tr Member

    i want to make keyboard menu not inline keyboard
    in "ReplyKeyboardMarkup" after add "newbutton" dosen't newbutton method
    i should add newrow then can use newbutton again
    i want to have 2or3 button in one row

    plz check attached image
    thanks
     

    Attached Files:

  4. DonManfred

    DonManfred Expert Licensed User

    when you add a button you then need to set data which is send to the bot when the user presses the button.
    after you set the data you can add another button.
    i´m not sure that i understand correctly.

    Can you post a Picture of what exactly you want to archieve? Maybe a link to the Telegram-Documentationpage of the Feature you want.
     
    Last edited: Aug 3, 2019
  5. behnam_tr

    behnam_tr Member

    telegram keyboard sample


    Untitled22222.png
     
  6. behnam_tr

    behnam_tr Member


    "KeyboardButtonBuilder" dont have setcallbackdata
    setcallback only is in the inlinekeyboardbuilder

    sorry for my bad english!
     
  7. DonManfred

    DonManfred Expert Licensed User

    v0.18 now has a changed ReplyKeyboardMarkup.
    It now has a Initialisation for the Buttonsrows... You first init and say how many rows and columns you want to have.
    then you set all the buttons one by one
    and then you use the Keyboard for the answer.

    Code something like

    Code:
    else If message.Text = "/replykeyboard" Then
                
    Log("ReplyKeyboard requested")
                
    Dim kmark As ReplyKeyboardMarkup
                kmark.initkeyboard(
    1,3)
                kmark.SetButton(
    0,0,"BTN0-0")
                kmark.SetButton(
    0,1,"BTN0-1")
                kmark.SetButton(
    0,2,"BTN0-2")
                kmark.SetButton(
    1,0,"BTN1-0")
                kmark.SetButton(
    1,1,"BTN1-1")
                kmark.SetButton(
    1,2,"BTN1-2")
                
                kmark.initialize(kmark.GetKeyboard,
    True,True,True)
                
    Dim buttons As Message = jtb.sendMessage(jtb.byId(from.Id),"Yo man","MARKDOWN",False,False,message.MessageId,kmark)
    it results in

    [​IMG]

    After i press one of the buttons

    [​IMG]

    Isit this what you are searching?
     
    behnam_tr likes this.
  8. behnam_tr

    behnam_tr Member

    thanks
    exactly i want this
    you are a bigman !
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice