integram icon indicating copy to clipboard operation
integram copied to clipboard

keyboardButton

Open larrydalaw opened this issue 7 years ago • 3 comments

Been stuck for 2 days, couldnt figure out a way to create a keyboardmarkup after user input /start, pls help thanks!

larrydalaw avatar Apr 09 '17 04:04 larrydalaw

Hi Larry. Do you mean Inline keyboard (in the message) or the one that appears instead of common keyboard?

requilence avatar Apr 09 '17 07:04 requilence

For the inline keyboard here is example. Make sure to add callbackFunc to the service configuration (inside the Actions)

func sendMessageWithInlineKeyboard(c *integram.Context) {
	kb := integram.InlineButtons{}
	kb.Append("callback_data1", "1 Button's text")
	kb.Append("callback_data2", "2 Button's text")
	optionalParam := "you can pass param to the callback func"
	
	// 2 is the number of columns
	c.NewMessage().
	SetInlineKeyboard(kb.Markup(2, "")).
	SetText("Message").
	SetCallbackAction(callbackFunc, optionalParam).Send()
}

func callbackFunc(c *integram.Context, param string) {
	c.AnswerCallbackQuery("Got the inline button callback with data='"+c.Callback.Data+"'. Passed param is "+param, false)
}

requilence avatar Apr 09 '17 07:04 requilence

Hello I wanted to make non-inline one , thx

On Sun, 9 Apr 2017 at 15:08, Roman Khafizianov [email protected] wrote:

Hi Larry. Do you mean Inline keyboard (in the message) or the one that appears instead of common keyboard?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Requilence/integram/issues/30#issuecomment-292768803, or mute the thread https://github.com/notifications/unsubscribe-auth/AVHjruE_C6G4tkmwd6repJ07zdfhSMcCks5ruIP7gaJpZM4M3696 .

larrydalaw avatar Apr 09 '17 08:04 larrydalaw