Skip to content

Commit

Permalink
Add Keyboard
Browse files Browse the repository at this point in the history
  • Loading branch information
mileusna committed Jul 21, 2017
1 parent 3b640d2 commit e7832f0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
21 changes: 21 additions & 0 deletions keyboard.go
Original file line number Diff line number Diff line change
@@ -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,
}
}
7 changes: 7 additions & 0 deletions message.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type messageResponse struct {
type Message interface {
SetReceiver(r string)
SetFrom(from string)
SetKeyboard(k *Keyboard)
}

// TextMessage for Viber
Expand All @@ -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,
Expand Down Expand Up @@ -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
}

0 comments on commit e7832f0

Please sign in to comment.