bobot 3.0.3 → 3.0.5
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/app/jobs/bobot/commander_job.rb +0 -1
- data/app/jobs/bobot/deliver_job.rb +0 -1
- data/lib/bobot.rb +0 -3
- data/lib/bobot/graph_facebook.rb +40 -49
- data/lib/bobot/version.rb +1 -1
- data/spec/bobot/profile_spec.rb +1 -2
- data/spec/bobot/subscription_spec.rb +1 -2
- data/spec/bobot/user_spec.rb +1 -2
- data/spec/dummy/log/development.log +2 -0
- data/spec/dummy/log/test.log +7 -0
- data/spec/dummy/tmp/generator/config/initializers/bobot.rb +6 -5
- data/spec/dummy/tmp/generator/config/locales/bobot.en.yml +8 -8
- data/spec/dummy/tmp/generator/config/locales/bobot.fr.yml +8 -8
- data/spec/rails_helper.rb +3 -0
- metadata +16 -4
- data/spec/dummy/tmp/generator/config/routes.rb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1604e92019fb451807c99f8a6ecaf3ba969a53a5
|
4
|
+
data.tar.gz: 62de9467eec07cdeb073421d9f7c212581d62348
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8733aef1551529ee91a8869e510676a36ae79e6b3c331317fbf34420dc273ab2fd385d744ebe919d04c6d2b69354a8625c1d5769777439f98b940076959d8de
|
7
|
+
data.tar.gz: b640a5c455189c74aca047303b907f37f1262b20f160a9e3de9308c8c67f9510852e97e17e43b05017a8bcfb8a8d344615cce3edad6db8dedca4f0cefbaa9b63
|
data/lib/bobot.rb
CHANGED
data/lib/bobot/graph_facebook.rb
CHANGED
@@ -1,25 +1,24 @@
|
|
1
|
+
require "Typhoeus"
|
2
|
+
require "uri"
|
3
|
+
|
1
4
|
module Bobot
|
2
5
|
module GraphFacebook
|
3
|
-
GRAPH_FB_URL = 'https://graph.facebook.com'.freeze
|
4
|
-
|
6
|
+
GRAPH_FB_URL = 'https://graph.facebook.com/v2.11/'.freeze
|
7
|
+
GRAPH_HEADERS = { Accept: "application/json", "Content-Type" => "application/json; charset=utf-8" }.freeze
|
5
8
|
|
6
9
|
module ClassMethods
|
7
10
|
def graph_get(path, query: {})
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
20
|
-
res = https.request(req)
|
21
|
-
json = ActiveSupport::JSON.decode(res.send(:body) || '{}')
|
22
|
-
Rails.logger.debug "[GET] >> #{uri.request_uri}"
|
11
|
+
url = "#{GRAPH_FB_URL}#{path}".freeze
|
12
|
+
req = Typhoeus::Request.new(
|
13
|
+
url,
|
14
|
+
method: :get,
|
15
|
+
params: URI.encode_www_form(query.reverse_merge(include_headers: false)),
|
16
|
+
headers: GRAPH_HEADERS,
|
17
|
+
ssl_verifypeer: false,
|
18
|
+
).run
|
19
|
+
response = req.run
|
20
|
+
json = ActiveSupport::JSON.decode(response.send(:body) || '{}')
|
21
|
+
Rails.logger.debug "[GET] >> #{url}"
|
23
22
|
Rails.logger.debug "[GET] << #{json}"
|
24
23
|
Bobot::ErrorParser.raise_errors_from(json)
|
25
24
|
json
|
@@ -27,22 +26,18 @@ module Bobot
|
|
27
26
|
module_function :graph_get
|
28
27
|
|
29
28
|
def graph_post(path, query: {}, body: {})
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
end
|
43
|
-
res = https.request(req)
|
44
|
-
json = ActiveSupport::JSON.decode(res.send(:body) || '{}')
|
45
|
-
Rails.logger.debug "[POST] >> #{uri.request_uri}"
|
29
|
+
url = "#{GRAPH_FB_URL}#{path}".freeze
|
30
|
+
req = Typhoeus::Request.new(
|
31
|
+
url,
|
32
|
+
method: :post,
|
33
|
+
params: URI.encode_www_form(query.reverse_merge(include_headers: false)),
|
34
|
+
body: ActiveSupport::JSON.encode(body),
|
35
|
+
headers: GRAPH_HEADERS,
|
36
|
+
ssl_verifypeer: false,
|
37
|
+
)
|
38
|
+
response = req.run
|
39
|
+
json = ActiveSupport::JSON.decode(response.send(:body) || '{}')
|
40
|
+
Rails.logger.debug "[POST] >> #{url}"
|
46
41
|
Rails.logger.debug "[POST] << #{json}"
|
47
42
|
Bobot::ErrorParser.raise_errors_from(json)
|
48
43
|
json
|
@@ -50,22 +45,18 @@ module Bobot
|
|
50
45
|
module_function :graph_post
|
51
46
|
|
52
47
|
def graph_delete(path, query: {}, body: {})
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
end
|
66
|
-
res = https.request(req)
|
67
|
-
json = ActiveSupport::JSON.decode(res.send(:body) || '{}')
|
68
|
-
Rails.logger.debug "[DELETE] >> #{uri.request_uri}"
|
48
|
+
url = "#{GRAPH_FB_URL}#{path}".freeze
|
49
|
+
req = Typhoeus::Request.new(
|
50
|
+
url,
|
51
|
+
method: :delete,
|
52
|
+
params: URI.encode_www_form(query.reverse_merge(include_headers: false)),
|
53
|
+
body: ActiveSupport::JSON.encode(body),
|
54
|
+
headers: GRAPH_HEADERS,
|
55
|
+
ssl_verifypeer: false,
|
56
|
+
)
|
57
|
+
response = req.run
|
58
|
+
json = ActiveSupport::JSON.decode(response.send(:body) || '{}')
|
59
|
+
Rails.logger.debug "[DELETE] >> #{url}"
|
69
60
|
Rails.logger.debug "[DELETE] << #{json}"
|
70
61
|
Bobot::ErrorParser.raise_errors_from(json)
|
71
62
|
json
|
data/lib/bobot/version.rb
CHANGED
data/spec/bobot/profile_spec.rb
CHANGED
data/spec/bobot/user_spec.rb
CHANGED
data/spec/dummy/log/test.log
CHANGED
@@ -26,3 +26,10 @@
|
|
26
26
|
[ActiveJob] Enqueued Bobot::CommanderJob (Job ID: e1b4f1e1-13d8-4243-948c-c2bbdab9f212) to Test(default) with arguments: {"sender"=>{"id"=>"2"}, "recipient"=>{"id"=>"3"}, "timestamp"=>1457764197627, "message"=>{"mid"=>"mid.1457764197618:41d102a3e1ae206a38", "seq"=>73, "text"=>"Hello, bot!"}}
|
27
27
|
[ActiveJob] Enqueued Bobot::CommanderJob (Job ID: 1c5e3b4b-4ae4-4213-bafb-4164a16a0a4c) to Test(default) with arguments: {"sender"=>{"id"=>"2"}, "recipient"=>{"id"=>"3"}, "timestamp"=>1457764197627, "message"=>{"mid"=>"mid.1457764197618:41d102a3e1ae206a38", "seq"=>73, "text"=>"Hello, bot!"}}
|
28
28
|
[ActiveJob] Enqueued Bobot::CommanderJob (Job ID: 56732598-6966-4ce2-b00c-0b7632f4a14b) to Test(default) with arguments: {"sender"=>{"id"=>"2"}, "recipient"=>{"id"=>"3"}, "timestamp"=>1457764197627, "message"=>{"mid"=>"mid.1457764197618:41d102a3e1ae206a38", "seq"=>73, "text"=>"Hello, bot!"}}
|
29
|
+
[ActiveJob] Enqueued Bobot::CommanderJob (Job ID: 7bdaa668-ea63-4a68-9576-95f2bc8197a9) to Test(default) with arguments: {"sender"=>{"id"=>"2"}, "recipient"=>{"id"=>"3"}, "timestamp"=>1457764197627, "message"=>{"mid"=>"mid.1457764197618:41d102a3e1ae206a38", "seq"=>73, "text"=>"Hello, bot!"}}
|
30
|
+
ETHON: Libcurl initialized
|
31
|
+
[ActiveJob] Enqueued Bobot::CommanderJob (Job ID: 6a6034d0-25d7-4aea-93f9-e56f3d212cda) to Test(default) with arguments: {"sender"=>{"id"=>"2"}, "recipient"=>{"id"=>"3"}, "timestamp"=>1457764197627, "message"=>{"mid"=>"mid.1457764197618:41d102a3e1ae206a38", "seq"=>73, "text"=>"Hello, bot!"}}
|
32
|
+
[ActiveJob] Enqueued Bobot::CommanderJob (Job ID: 30f17782-94b0-481e-a3f3-f667225b0ecc) to Test(default) with arguments: {"sender"=>{"id"=>"2"}, "recipient"=>{"id"=>"3"}, "timestamp"=>1457764197627, "message"=>{"mid"=>"mid.1457764197618:41d102a3e1ae206a38", "seq"=>73, "text"=>"Hello, bot!"}}
|
33
|
+
ETHON: Libcurl initialized
|
34
|
+
ETHON: Libcurl initialized
|
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!"}}
|
@@ -6,11 +6,12 @@ if bobot_config.present?
|
|
6
6
|
raise "Bobot: #{bobot_config_path} required an array key :pages (cf. https://github.com/navidemad/bobot)"
|
7
7
|
end
|
8
8
|
Bobot.configure do |config|
|
9
|
-
config.app_id
|
10
|
-
config.app_secret
|
11
|
-
config.verify_token
|
12
|
-
config.domains
|
13
|
-
config.async
|
9
|
+
config.app_id = bobot_config["app_id"]
|
10
|
+
config.app_secret = bobot_config["app_secret"]
|
11
|
+
config.verify_token = bobot_config["verify_token"]
|
12
|
+
config.domains = bobot_config["domains"]
|
13
|
+
config.async = bobot_config["async"]
|
14
|
+
config.commander_queue_name = bobot_config["commander_queue_name"]
|
14
15
|
bobot_config["pages"].each do |page|
|
15
16
|
config.pages << Bobot::Page.new(
|
16
17
|
slug: page["slug"],
|
@@ -10,17 +10,17 @@ en:
|
|
10
10
|
persistent_menu:
|
11
11
|
composer_input_disabled: false
|
12
12
|
call_to_actions:
|
13
|
-
-
|
14
|
-
|
13
|
+
- type: "nested"
|
14
|
+
title: "My Account"
|
15
15
|
call_to_actions:
|
16
|
-
-
|
17
|
-
|
16
|
+
- type: "postback"
|
17
|
+
title: "What is a chatbot?"
|
18
18
|
payload: "WHAT_IS_A_CHATBOT"
|
19
|
-
-
|
20
|
-
|
19
|
+
- type: "postback"
|
20
|
+
title: "History"
|
21
21
|
payload: "HISTORY_PAYLOAD"
|
22
|
-
-
|
23
|
-
|
22
|
+
- type: "postback"
|
23
|
+
title: "Contact Info"
|
24
24
|
payload: "CONTACT_INFO_PAYLOAD"
|
25
25
|
- type: "web_url"
|
26
26
|
title: "Get some help"
|
@@ -9,17 +9,17 @@ fr:
|
|
9
9
|
persistent_menu:
|
10
10
|
composer_input_disabled: false
|
11
11
|
call_to_actions:
|
12
|
-
-
|
13
|
-
|
12
|
+
- type: "nested"
|
13
|
+
title: "Mon compte"
|
14
14
|
call_to_actions:
|
15
|
-
-
|
16
|
-
|
15
|
+
- type: "postback"
|
16
|
+
title: "C'est quoi un chatbot ?"
|
17
17
|
payload: "WHAT_IS_A_CHATBOT"
|
18
|
-
-
|
19
|
-
|
18
|
+
- type: "postback"
|
19
|
+
title: "Historique"
|
20
20
|
payload: "HISTORY_PAYLOAD"
|
21
|
-
-
|
22
|
-
|
21
|
+
- type: "postback"
|
22
|
+
title: "Contact Info"
|
23
23
|
payload: "CONTACT_INFO_PAYLOAD"
|
24
24
|
- type: "web_url"
|
25
25
|
title: "Obtenir de l'aide"
|
data/spec/rails_helper.rb
CHANGED
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.0.
|
4
|
+
version: 3.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Navid EMAD
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|
@@ -44,6 +44,20 @@ dependencies:
|
|
44
44
|
- - "<"
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '6'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: typhoeus
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
47
61
|
description: Bobot is a Ruby wrapped framework to build easily a Facebook Messenger
|
48
62
|
Bot.
|
49
63
|
email:
|
@@ -157,7 +171,6 @@ files:
|
|
157
171
|
- spec/dummy/tmp/generator/config/initializers/bobot.rb
|
158
172
|
- spec/dummy/tmp/generator/config/locales/bobot.en.yml
|
159
173
|
- spec/dummy/tmp/generator/config/locales/bobot.fr.yml
|
160
|
-
- spec/dummy/tmp/generator/config/routes.rb
|
161
174
|
- spec/examples.txt
|
162
175
|
- spec/helpers/graph_api_helpers.rb
|
163
176
|
- spec/jobs/bobot/commander_job_spec.rb
|
@@ -251,7 +264,6 @@ test_files:
|
|
251
264
|
- spec/dummy/tmp/generator/config/initializers/bobot.rb
|
252
265
|
- spec/dummy/tmp/generator/config/locales/bobot.en.yml
|
253
266
|
- spec/dummy/tmp/generator/config/locales/bobot.fr.yml
|
254
|
-
- spec/dummy/tmp/generator/config/routes.rb
|
255
267
|
- spec/examples.txt
|
256
268
|
- spec/helpers/graph_api_helpers.rb
|
257
269
|
- spec/jobs/bobot/commander_job_spec.rb
|
File without changes
|