-
Notifications
You must be signed in to change notification settings - Fork 2
/
output_adders.go
83 lines (69 loc) · 1.56 KB
/
output_adders.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package neocortex
import "time"
func (out *Output) AddTextResponse(resp string) *Output {
if out.Responses == nil {
out.Responses = []Response{}
}
out.Responses = append(out.Responses, Response{
Type: Text,
Value: resp,
IsTyping: false,
})
return out
}
func (out *Output) AddOptionsResponse(title string, subtitle string, options ...Option) *Output {
if out.Responses == nil {
out.Responses = []Response{}
}
opts := make([]*Option, 0)
for _, o := range options {
opts = append(opts, &Option{
Text: o.Text,
IsPostBack: o.IsPostBack,
Action: o.Action,
})
}
out.Responses = append(out.Responses, Response{
Type: Options,
Value: OptionsResponse{
Title: title,
Description: subtitle,
Options: opts,
},
IsTyping: false,
})
return out
}
func (out *Output) AddListOfOptionsResponse(options []OptionsResponse) *Output {
if out.Responses == nil {
out.Responses = []Response{}
}
out.Responses = append(out.Responses, Response{
Type: Options,
Value: options,
IsTyping: false,
})
return out
}
func (out *Output) AddImageResponse(url string) *Output {
if out.Responses == nil {
out.Responses = []Response{}
}
out.Responses = append(out.Responses, Response{
Type: Image,
Value: url,
IsTyping: false,
})
return out
}
func (out *Output) AddPauseResponse(duration time.Duration) *Output {
if out.Responses == nil {
out.Responses = []Response{}
}
out.Responses = append(out.Responses, Response{
Type: Pause,
Value: duration,
IsTyping: false,
})
return out
}