Skip to content

Commit d4818d0

Browse files
committed
removed the inline functionality
1 parent 5f6757e commit d4818d0

File tree

3 files changed

+19
-20
lines changed

3 files changed

+19
-20
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Features
66
====
77
- Portable & Tiny
88
- Embedded a tiny `Expression Engine` to support simple scripting
9-
- Supports the following tags `meta, text, label, p, line, inline, span, embed, resource, media, div, menu, nav, dialog, form, template`
9+
- Supports the following tags `meta, text, label, p, line, span, embed, resource, media, div, menu, nav, dialog, form, template`
1010
- Supports custom replies from custom templates
1111
- Automatically paginate long `Menus` to be compatible with messenger `max-items-limit`
1212

@@ -57,7 +57,7 @@ Demo
5757
<a href="#collect" reset="true">Collect Data</a>
5858
</menu>
5959

60-
<menu id="welcome" inline="true">
60+
<menu id="welcome">
6161
<a href="#about">Click Here 1</a>
6262
<a href="#about">Click Here 2</a>
6363
</menu>

messenger_session.go

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,15 @@ func (m *MessengerSession) SendInput(input *Input) error {
8484
return nil
8585
}
8686
if input.Type == "options" {
87-
return m.SendInlineButtons(input.Title, input.Options)
88-
// callToActions := []messenger.StructuredMessageButton{}
89-
// for _, btn := range input.Options {
90-
// cta := messenger.StructuredMessageButton{}
91-
// cta.Title = btn.Title
92-
// cta.Type = "postback"
93-
// cta.Payload = btn.Href
94-
// callToActions = append(callToActions, cta)
95-
// }
96-
// return m.response.ButtonTemplate(input.Title, &callToActions, messenger.MessagingType("RESPONSE"))
87+
callToActions := []messenger.StructuredMessageButton{}
88+
for _, btn := range input.Options {
89+
cta := messenger.StructuredMessageButton{}
90+
cta.Title = btn.Title
91+
cta.Type = "postback"
92+
cta.Payload = btn.Href
93+
callToActions = append(callToActions, cta)
94+
}
95+
return m.response.ButtonTemplate(input.Title, &callToActions, messenger.MessagingType("RESPONSE"))
9796
}
9897
return nil
9998
}
@@ -103,9 +102,9 @@ func (m *MessengerSession) SendBasicMenu(menu *Menu) error {
103102
if menu == nil {
104103
return nil
105104
}
106-
if menu.Inline {
107-
return m.SendInlineButtons(menu.Title, menu.Buttons)
108-
}
105+
// if menu.Inline {
106+
// return m.SendInlineButtons(menu.Title, menu.Buttons)
107+
// }
109108
callToActions := []messenger.StructuredMessageButton{}
110109
for _, btn := range menu.Buttons {
111110
cta := messenger.StructuredMessageButton{}

parser.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,18 @@ func NewBotFromReader(r io.Reader) (*Bot, error) {
3838
// paginate the menu/navs buttons
3939
// messanger maximum navigation links are 3 - 4, we will make them 3 by maximum.
4040
doc.Find("menu,nav").Each(func(_ int, m *goquery.Selection) {
41-
m.SetAttr("inline", m.AttrOr("inline", "false"))
42-
if m.AttrOr("inline", "false") == "true" {
43-
return
44-
}
4541
if m.AttrOr("id", "") == bot.Configs["main-menu"] {
4642
return
4743
}
4844
p, cnt := m, 1
45+
more := bot.Configs["pager-more"]
46+
if more == "" {
47+
more = "More"
48+
}
4949
m.Find("a,button").Each(func(i int, b *goquery.Selection) {
5050
if (i > 0) && (i%2 == 0) && m.Find("a,button").Length() > 3 {
5151
newId := fmt.Sprintf("%s-%d", m.AttrOr("id", ""), cnt)
52-
p.AppendHtml(fmt.Sprintf("<a href='#%s'>%s</a>", newId, "More"))
52+
p.AppendHtml(fmt.Sprintf("<a href='#%s'>%s</a>", newId, more))
5353
p.AfterHtml(fmt.Sprintf("<menu id='%s' title='%s'></menu>", newId, m.AttrOr("title", "")))
5454
p = bot.Document.Find("#" + newId)
5555
cnt++

0 commit comments

Comments
 (0)