bobot 3.7.2 → 3.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/bobot/commander.rb +1 -1
- data/lib/bobot/events/common.rb +4 -0
- data/lib/bobot/page.rb +25 -6
- data/lib/bobot/version.rb +1 -1
- data/spec/bobot/event/common_spec.rb +22 -0
- data/spec/dummy/log/test.log +66 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5eaced1ce6579453fb0e8341b7da0f887447a513
|
4
|
+
data.tar.gz: 1e3a895d8f890a485d1c78a77e24371e710cf41c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6a5ecc9fc240af3114bc8817c5f9eeae07a3f7197ae31a16cf2e84cce5db53e6453939d6f99e1ad82c65c152e1ad2fd665a5ea8603c67e5b89632670f0fd986
|
7
|
+
data.tar.gz: c6b241d738a8dec4ca9b19c45834bd03ad9894004fbddf265609cd19f2ce3323c331bf35b50acefc2931f88328709290736e411b662a3a31df32c5fb8b03e774
|
data/lib/bobot/commander.rb
CHANGED
data/lib/bobot/events/common.rb
CHANGED
@@ -49,6 +49,10 @@ module Bobot
|
|
49
49
|
page.send_text(text: text, to: sender["id"])
|
50
50
|
end
|
51
51
|
|
52
|
+
def reply_with_youtube_video(url:)
|
53
|
+
page.send_youtube_video(url: url, to: sender["id"])
|
54
|
+
end
|
55
|
+
|
52
56
|
def reply_with_attachment(url:, type:)
|
53
57
|
page.send_attachment(url: url, type: type, to: sender["id"])
|
54
58
|
end
|
data/lib/bobot/page.rb
CHANGED
@@ -90,6 +90,25 @@ module Bobot
|
|
90
90
|
)
|
91
91
|
end
|
92
92
|
|
93
|
+
def send_youtube_video(url:, to: nil)
|
94
|
+
raise Bobot::FieldFormat.new('url is required') unless url.present?
|
95
|
+
raise Bobot::FieldFormat.new('url is not valid', url) unless url =~ %r{^(?:https?:\/\/)?(?:www\.)?youtu(?:\.be|be\.com)\/(?:watch\?v=)?([\w-]{10,})}
|
96
|
+
send(
|
97
|
+
payload_message: {
|
98
|
+
attachment: {
|
99
|
+
type: "template",
|
100
|
+
payload: {
|
101
|
+
template_type: "open_graph",
|
102
|
+
elements: [
|
103
|
+
{ url: url },
|
104
|
+
],
|
105
|
+
},
|
106
|
+
},
|
107
|
+
},
|
108
|
+
to: to,
|
109
|
+
)
|
110
|
+
end
|
111
|
+
|
93
112
|
def send_image(url:, to: nil)
|
94
113
|
send_attachment(url: url, type: 'image', to: to)
|
95
114
|
end
|
@@ -220,9 +239,9 @@ module Bobot
|
|
220
239
|
greeting_texts << { locale: 'default', text: greeting_text } if greeting_text.present?
|
221
240
|
end
|
222
241
|
if greeting_texts.present?
|
223
|
-
greeting_texts.each do |
|
224
|
-
if
|
225
|
-
raise Bobot::FieldFormat.new(
|
242
|
+
greeting_texts.each do |row|
|
243
|
+
if row[:text].present? && row[:text].size > 160
|
244
|
+
raise Bobot::FieldFormat.new("greeting text for locale #{row[:locale]} is limited to 160.", "#{row[:text]} (#{row[:text].size} chars)")
|
226
245
|
end
|
227
246
|
end
|
228
247
|
Bobot::Profile.set(
|
@@ -320,9 +339,9 @@ module Bobot
|
|
320
339
|
end
|
321
340
|
end
|
322
341
|
if persistent_menus.present?
|
323
|
-
persistent_menus.each do |
|
324
|
-
if
|
325
|
-
raise Bobot::FieldFormat.new(
|
342
|
+
persistent_menus.each do |row|
|
343
|
+
if row[:title].present? && row[:title].size > 30
|
344
|
+
raise Bobot::FieldFormat.new("persistent menu text for locale #{row[:locale]} is limited to 30.", "#{row[:title]} (#{row[:title].size} chars)")
|
326
345
|
end
|
327
346
|
end
|
328
347
|
Bobot::Profile.set(
|
data/lib/bobot/version.rb
CHANGED
@@ -110,6 +110,28 @@ RSpec.describe Bobot::Dummy do
|
|
110
110
|
end
|
111
111
|
end
|
112
112
|
|
113
|
+
describe '.reply_with_youtube_video' do
|
114
|
+
it 'replies to the sender' do
|
115
|
+
expect(subject.page).to receive(:deliver).with(
|
116
|
+
payload_template: {
|
117
|
+
message: {
|
118
|
+
attachment: {
|
119
|
+
type: 'template',
|
120
|
+
payload: {
|
121
|
+
template_type: "open_graph",
|
122
|
+
elements: [
|
123
|
+
{ url: "https://www.youtube.com/watch?v=kJQP7kiw5Fk" }
|
124
|
+
],
|
125
|
+
},
|
126
|
+
},
|
127
|
+
},
|
128
|
+
},
|
129
|
+
to: payload['recipient']['id'],
|
130
|
+
)
|
131
|
+
subject.reply_with_youtube_video(url: 'https://www.youtube.com/watch?v=kJQP7kiw5Fk')
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
113
135
|
describe '.reply_with_image' do
|
114
136
|
it 'replies to the sender' do
|
115
137
|
expect(subject.page).to receive(:deliver).with(
|
data/spec/dummy/log/test.log
CHANGED
@@ -33,3 +33,69 @@ ETHON: Libcurl initialized
|
|
33
33
|
ETHON: Libcurl initialized
|
34
34
|
ETHON: Libcurl initialized
|
35
35
|
[ActiveJob] Enqueued Bobot::CommanderJob (Job ID: 3128058b-c515-488d-9987-a121b91bfaab) to Test(default) with arguments: {"sender"=>{"id"=>"2"}, "recipient"=>{"id"=>"3"}, "timestamp"=>1457764197627, "message"=>{"mid"=>"mid.1457764197618:41d102a3e1ae206a38", "seq"=>73, "text"=>"Hello, bot!"}}
|
36
|
+
ETHON: Libcurl initialized
|
37
|
+
[DELETE] >> https://graph.facebook.com/v2.11/me/messenger_profile
|
38
|
+
[DELETE] << {"result"=>"Successfully deleted Get Started button"}
|
39
|
+
[DELETE] >> https://graph.facebook.com/v2.11/me/messenger_profile
|
40
|
+
[DELETE] << {"error"=>{"message"=>"Invalid OAuth access token.", "type"=>"OAuthException", "code"=>190, "fbtrace_id"=>"Hlssg2aiVlN"}}
|
41
|
+
[POST] >> https://graph.facebook.com/v2.11/me/messenger_profile
|
42
|
+
[POST] << {"result"=>"Successfully added Get Started button"}
|
43
|
+
[POST] >> https://graph.facebook.com/v2.11/me/messenger_profile
|
44
|
+
[POST] << {"error"=>{"message"=>"Invalid OAuth access token.", "type"=>"OAuthException", "code"=>190, "fbtrace_id"=>"Hlssg2aiVlN"}}
|
45
|
+
[GET] >> https://graph.facebook.com/v2.11/5660527900
|
46
|
+
[GET] << {"error"=>{"message"=>"Invalid OAuth access token.", "type"=>"OAuthException", "code"=>190, "fbtrace_id"=>"Hlssg2aiVlN"}}
|
47
|
+
[GET] >> https://graph.facebook.com/v2.11/6083248100
|
48
|
+
[GET] << {"first_name"=>"Foo", "last_name"=>"Bar"}
|
49
|
+
[POST] >> https://graph.facebook.com/v2.11/page-id/subscribed_apps
|
50
|
+
[POST] << {"error"=>{"message"=>"Invalid OAuth access token.", "type"=>"OAuthException", "code"=>190, "fbtrace_id"=>"Hlssg2aiVlN"}}
|
51
|
+
[POST] >> https://graph.facebook.com/v2.11/page-id/subscribed_apps
|
52
|
+
[POST] << {"success"=>true}
|
53
|
+
[DELETE] >> https://graph.facebook.com/v2.11/page-id/subscribed_apps
|
54
|
+
[DELETE] << {"error"=>{"message"=>"Invalid OAuth access token.", "type"=>"OAuthException", "code"=>190, "fbtrace_id"=>"Hlssg2aiVlN"}}
|
55
|
+
[DELETE] >> https://graph.facebook.com/v2.11/page-id/subscribed_apps
|
56
|
+
[DELETE] << {"success"=>true}
|
57
|
+
[ActiveJob] Enqueued Bobot::CommanderJob (Job ID: 6331ca30-bd85-4ed5-8c5b-34d754cbe52d) to Test(default) with arguments: {"sender"=>{"id"=>"2"}, "recipient"=>{"id"=>"3"}, "timestamp"=>1457764197627, "message"=>{"mid"=>"mid.1457764197618:41d102a3e1ae206a38", "seq"=>73, "text"=>"Hello, bot!"}}
|
58
|
+
ETHON: Libcurl initialized
|
59
|
+
[GET] >> https://graph.facebook.com/v2.11/4127242400
|
60
|
+
[GET] << {"error"=>{"message"=>"Invalid OAuth access token.", "type"=>"OAuthException", "code"=>190, "fbtrace_id"=>"Hlssg2aiVlN"}}
|
61
|
+
[GET] >> https://graph.facebook.com/v2.11/9467813000
|
62
|
+
[GET] << {"first_name"=>"Foo", "last_name"=>"Bar"}
|
63
|
+
[ActiveJob] Enqueued Bobot::CommanderJob (Job ID: 84904cdf-4e70-49f1-b453-0575f8045b8b) to Test(default) with arguments: {"sender"=>{"id"=>"2"}, "recipient"=>{"id"=>"3"}, "timestamp"=>1457764197627, "message"=>{"mid"=>"mid.1457764197618:41d102a3e1ae206a38", "seq"=>73, "text"=>"Hello, bot!"}}
|
64
|
+
[POST] >> https://graph.facebook.com/v2.11/me/messenger_profile
|
65
|
+
[POST] << {"error"=>{"message"=>"Invalid OAuth access token.", "type"=>"OAuthException", "code"=>190, "fbtrace_id"=>"Hlssg2aiVlN"}}
|
66
|
+
[POST] >> https://graph.facebook.com/v2.11/me/messenger_profile
|
67
|
+
[POST] << {"result"=>"Successfully added Get Started button"}
|
68
|
+
[DELETE] >> https://graph.facebook.com/v2.11/me/messenger_profile
|
69
|
+
[DELETE] << {"result"=>"Successfully deleted Get Started button"}
|
70
|
+
[DELETE] >> https://graph.facebook.com/v2.11/me/messenger_profile
|
71
|
+
[DELETE] << {"error"=>{"message"=>"Invalid OAuth access token.", "type"=>"OAuthException", "code"=>190, "fbtrace_id"=>"Hlssg2aiVlN"}}
|
72
|
+
[DELETE] >> https://graph.facebook.com/v2.11/page-id/subscribed_apps
|
73
|
+
[DELETE] << {"error"=>{"message"=>"Invalid OAuth access token.", "type"=>"OAuthException", "code"=>190, "fbtrace_id"=>"Hlssg2aiVlN"}}
|
74
|
+
[DELETE] >> https://graph.facebook.com/v2.11/page-id/subscribed_apps
|
75
|
+
[DELETE] << {"success"=>true}
|
76
|
+
[POST] >> https://graph.facebook.com/v2.11/page-id/subscribed_apps
|
77
|
+
[POST] << {"error"=>{"message"=>"Invalid OAuth access token.", "type"=>"OAuthException", "code"=>190, "fbtrace_id"=>"Hlssg2aiVlN"}}
|
78
|
+
[POST] >> https://graph.facebook.com/v2.11/page-id/subscribed_apps
|
79
|
+
[POST] << {"success"=>true}
|
80
|
+
[ActiveJob] Enqueued Bobot::CommanderJob (Job ID: 0f2b73f2-ad6f-4987-8124-551b6e754a45) to Test(default) with arguments: {"sender"=>{"id"=>"2"}, "recipient"=>{"id"=>"3"}, "timestamp"=>1457764197627, "message"=>{"mid"=>"mid.1457764197618:41d102a3e1ae206a38", "seq"=>73, "text"=>"Hello, bot!"}}
|
81
|
+
ETHON: Libcurl initialized
|
82
|
+
[DELETE] >> https://graph.facebook.com/v2.11/page-id/subscribed_apps
|
83
|
+
[DELETE] << {"error"=>{"message"=>"Invalid OAuth access token.", "type"=>"OAuthException", "code"=>190, "fbtrace_id"=>"Hlssg2aiVlN"}}
|
84
|
+
[DELETE] >> https://graph.facebook.com/v2.11/page-id/subscribed_apps
|
85
|
+
[DELETE] << {"success"=>true}
|
86
|
+
[POST] >> https://graph.facebook.com/v2.11/page-id/subscribed_apps
|
87
|
+
[POST] << {"error"=>{"message"=>"Invalid OAuth access token.", "type"=>"OAuthException", "code"=>190, "fbtrace_id"=>"Hlssg2aiVlN"}}
|
88
|
+
[POST] >> https://graph.facebook.com/v2.11/page-id/subscribed_apps
|
89
|
+
[POST] << {"success"=>true}
|
90
|
+
[DELETE] >> https://graph.facebook.com/v2.11/me/messenger_profile
|
91
|
+
[DELETE] << {"result"=>"Successfully deleted Get Started button"}
|
92
|
+
[DELETE] >> https://graph.facebook.com/v2.11/me/messenger_profile
|
93
|
+
[DELETE] << {"error"=>{"message"=>"Invalid OAuth access token.", "type"=>"OAuthException", "code"=>190, "fbtrace_id"=>"Hlssg2aiVlN"}}
|
94
|
+
[POST] >> https://graph.facebook.com/v2.11/me/messenger_profile
|
95
|
+
[POST] << {"error"=>{"message"=>"Invalid OAuth access token.", "type"=>"OAuthException", "code"=>190, "fbtrace_id"=>"Hlssg2aiVlN"}}
|
96
|
+
[POST] >> https://graph.facebook.com/v2.11/me/messenger_profile
|
97
|
+
[POST] << {"result"=>"Successfully added Get Started button"}
|
98
|
+
[GET] >> https://graph.facebook.com/v2.11/9389461400
|
99
|
+
[GET] << {"first_name"=>"Foo", "last_name"=>"Bar"}
|
100
|
+
[GET] >> https://graph.facebook.com/v2.11/7482355400
|
101
|
+
[GET] << {"error"=>{"message"=>"Invalid OAuth access token.", "type"=>"OAuthException", "code"=>190, "fbtrace_id"=>"Hlssg2aiVlN"}}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bobot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.7.
|
4
|
+
version: 3.7.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Navid EMAD
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-02-
|
11
|
+
date: 2018-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|