Skip to content

Commit

Permalink
removed the inline functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
alash3al committed Mar 4, 2018
1 parent 5f6757e commit d4818d0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 20 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Features
====
- Portable & Tiny
- Embedded a tiny `Expression Engine` to support simple scripting
- Supports the following tags `meta, text, label, p, line, inline, span, embed, resource, media, div, menu, nav, dialog, form, template`
- Supports the following tags `meta, text, label, p, line, span, embed, resource, media, div, menu, nav, dialog, form, template`
- Supports custom replies from custom templates
- Automatically paginate long `Menus` to be compatible with messenger `max-items-limit`

Expand Down Expand Up @@ -57,7 +57,7 @@ Demo
<a href="#collect" reset="true">Collect Data</a>
</menu>

<menu id="welcome" inline="true">
<menu id="welcome">
<a href="#about">Click Here 1</a>
<a href="#about">Click Here 2</a>
</menu>
Expand Down
25 changes: 12 additions & 13 deletions messenger_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,15 @@ func (m *MessengerSession) SendInput(input *Input) error {
return nil
}
if input.Type == "options" {
return m.SendInlineButtons(input.Title, input.Options)
// callToActions := []messenger.StructuredMessageButton{}
// for _, btn := range input.Options {
// cta := messenger.StructuredMessageButton{}
// cta.Title = btn.Title
// cta.Type = "postback"
// cta.Payload = btn.Href
// callToActions = append(callToActions, cta)
// }
// return m.response.ButtonTemplate(input.Title, &callToActions, messenger.MessagingType("RESPONSE"))
callToActions := []messenger.StructuredMessageButton{}
for _, btn := range input.Options {
cta := messenger.StructuredMessageButton{}
cta.Title = btn.Title
cta.Type = "postback"
cta.Payload = btn.Href
callToActions = append(callToActions, cta)
}
return m.response.ButtonTemplate(input.Title, &callToActions, messenger.MessagingType("RESPONSE"))
}
return nil
}
Expand All @@ -103,9 +102,9 @@ func (m *MessengerSession) SendBasicMenu(menu *Menu) error {
if menu == nil {
return nil
}
if menu.Inline {
return m.SendInlineButtons(menu.Title, menu.Buttons)
}
// if menu.Inline {
// return m.SendInlineButtons(menu.Title, menu.Buttons)
// }
callToActions := []messenger.StructuredMessageButton{}
for _, btn := range menu.Buttons {
cta := messenger.StructuredMessageButton{}
Expand Down
10 changes: 5 additions & 5 deletions parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@ func NewBotFromReader(r io.Reader) (*Bot, error) {
// paginate the menu/navs buttons
// messanger maximum navigation links are 3 - 4, we will make them 3 by maximum.
doc.Find("menu,nav").Each(func(_ int, m *goquery.Selection) {
m.SetAttr("inline", m.AttrOr("inline", "false"))
if m.AttrOr("inline", "false") == "true" {
return
}
if m.AttrOr("id", "") == bot.Configs["main-menu"] {
return
}
p, cnt := m, 1
more := bot.Configs["pager-more"]
if more == "" {
more = "More"
}
m.Find("a,button").Each(func(i int, b *goquery.Selection) {
if (i > 0) && (i%2 == 0) && m.Find("a,button").Length() > 3 {
newId := fmt.Sprintf("%s-%d", m.AttrOr("id", ""), cnt)
p.AppendHtml(fmt.Sprintf("<a href='#%s'>%s</a>", newId, "More"))
p.AppendHtml(fmt.Sprintf("<a href='#%s'>%s</a>", newId, more))
p.AfterHtml(fmt.Sprintf("<menu id='%s' title='%s'></menu>", newId, m.AttrOr("title", "")))
p = bot.Document.Find("#" + newId)
cnt++
Expand Down

0 comments on commit d4818d0

Please sign in to comment.