diff --git a/keyboard.go b/keyboard.go new file mode 100644 index 0000000..73cedc0 --- /dev/null +++ b/keyboard.go @@ -0,0 +1,21 @@ +package viber + +// Keyboard struct +type Keyboard struct { + DefaultHeight bool `json:"DefaultHeight"` + BgColor string `json:"BgColor"` + Buttons []Button `json:"Buttons"` +} + +// AddButton to keyboard +func (k *Keyboard) AddButton(b *Button) { + k.Buttons = append(k.Buttons, *b) +} + +// NewKeyboard struct with attribs init +func NewKeyboard(bgcolor string, defaultHeight bool) *Keyboard { + return &Keyboard{ + DefaultHeight: defaultHeight, + BgColor: bgcolor, + } +} diff --git a/message.go b/message.go index 25798f7..0a7eb33 100644 --- a/message.go +++ b/message.go @@ -26,6 +26,7 @@ type messageResponse struct { type Message interface { SetReceiver(r string) SetFrom(from string) + SetKeyboard(k *Keyboard) } // TextMessage for Viber @@ -37,6 +38,7 @@ type TextMessage struct { Type MessageType `json:"type"` TrackingData string `json:"tracking_data,omitempty"` Text string `json:"text"` + Keyboars *Keyboard `json:"keyboard,omitempty"` // "media": "http://www.images.com/img.jpg", // "thumbnail": "http://www.images.com/thumb.jpg" // "size": 10000, @@ -175,3 +177,8 @@ func (m *TextMessage) SetReceiver(r string) { func (m *TextMessage) SetFrom(from string) { m.From = from } + +// SetKeyboard for text message +func (m *TextMessage) SetKeyboard(k *Keyboard) { + m.Keyboars = k +}