bobot 1.0.53 → 2.1.0

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.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +18 -8
  3. data/app/controllers/bobot/webhook_controller.rb +54 -30
  4. data/config/routes.rb +1 -2
  5. data/lib/bobot.rb +15 -1
  6. data/lib/bobot/commander.rb +9 -8
  7. data/lib/bobot/configuration.rb +149 -186
  8. data/lib/bobot/engine.rb +0 -4
  9. data/lib/bobot/events/common.rb +4 -4
  10. data/lib/bobot/events/delivery.rb +0 -1
  11. data/lib/bobot/events/message.rb +4 -0
  12. data/lib/bobot/events/message_echo.rb +3 -2
  13. data/lib/bobot/events/message_request.rb +9 -0
  14. data/lib/bobot/graph_facebook.rb +4 -4
  15. data/lib/bobot/profile.rb +2 -6
  16. data/lib/bobot/version.rb +3 -3
  17. data/lib/generators/bobot/templates/app/bobot/workflow.rb +9 -11
  18. data/lib/generators/bobot/templates/config/bobot.yml +41 -32
  19. data/lib/generators/bobot/templates/config/initializers/bobot.rb +25 -9
  20. data/lib/generators/bobot/templates/config/locales/bobot.en.yml +29 -28
  21. data/lib/generators/bobot/templates/config/locales/bobot.fr.yml +28 -27
  22. data/lib/generators/bobot/utils.rb +0 -9
  23. data/spec/bobot/bobot_spec.rb +18 -12
  24. data/spec/bobot/event/common_spec.rb +3 -1
  25. data/spec/bobot/event/message_spec.rb +7 -0
  26. data/spec/bobot/profile_spec.rb +3 -1
  27. data/spec/bobot/subscription_spec.rb +4 -2
  28. data/spec/bobot/user_spec.rb +4 -2
  29. data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
  30. data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
  31. data/spec/dummy/app/mailers/application_mailer.rb +4 -0
  32. data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
  33. data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
  34. data/spec/dummy/bin/setup +0 -8
  35. data/spec/dummy/bin/update +0 -3
  36. data/spec/dummy/config/application.rb +3 -2
  37. data/spec/dummy/config/cable.yml +10 -0
  38. data/spec/dummy/config/environments/development.rb +5 -3
  39. data/spec/dummy/config/environments/production.rb +5 -3
  40. data/spec/dummy/config/environments/test.rb +6 -2
  41. data/spec/dummy/config/initializers/application_controller_renderer.rb +6 -4
  42. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -5
  43. data/spec/dummy/config/routes.rb +1 -1
  44. data/spec/dummy/config/secrets.yml +2 -2
  45. data/spec/dummy/log/development.log +0 -0
  46. data/spec/dummy/log/test.log +2 -0
  47. data/spec/dummy/tmp/generator/app/bobot/workflow.rb +15 -0
  48. data/spec/dummy/tmp/generator/config/bobot.yml +48 -0
  49. data/spec/dummy/tmp/generator/config/initializers/bobot.rb +46 -0
  50. data/spec/dummy/tmp/generator/config/locales/bobot.en.yml +31 -0
  51. data/spec/dummy/tmp/generator/config/locales/bobot.fr.yml +30 -0
  52. data/spec/dummy/tmp/generator/config/routes.rb +0 -0
  53. data/spec/rails_helper.rb +8 -10
  54. metadata +43 -34
  55. data/app/mailers/bobot/application_mailer.rb +0 -6
  56. data/app/models/bobot/application_record.rb +0 -5
  57. data/lib/generators/bobot/templates/app/bobot/message.rb +0 -3
  58. data/lib/generators/bobot/templates/app/bobot/postback.rb +0 -22
  59. data/spec/dummy/app/bobot/workflow.rb +0 -17
  60. data/spec/dummy/app/models/application_record.rb +0 -3
  61. data/spec/dummy/config/bobot.yml +0 -27
  62. data/spec/dummy/config/database.yml +0 -19
  63. data/spec/dummy/config/initializers/bobot.rb +0 -30
  64. data/spec/dummy/config/locales/bobot.en.yml +0 -28
  65. data/spec/dummy/config/locales/bobot.fr.yml +0 -27
  66. data/spec/dummy/db/schema.rb +0 -15
@@ -25,21 +25,14 @@ ActiveJob::Base.queue_adapter = :test
25
25
  #
26
26
  # Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
27
27
 
28
- # Checks for pending migration and applies them before tests are run.
29
- # If you are not using ActiveRecord, you can remove this line.
30
- ActiveRecord::Migration.maintain_test_schema!
31
-
32
- # ActiveRecord::Schema.verbose = false
33
- load 'dummy/db/schema.rb' # db agnostic
34
-
35
28
  RSpec.configure do |config|
36
29
  # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
37
- config.fixture_path = "#{::Rails.root}/spec/fixtures"
30
+ # config.fixture_path = "#{::Rails.root}/spec/fixtures"
38
31
 
39
32
  # If you're not using ActiveRecord, or you'd prefer not to run each of your
40
33
  # examples within a transaction, remove the following line or assign false
41
34
  # instead of true.
42
- config.use_transactional_fixtures = true
35
+ config.use_transactional_fixtures = false
43
36
 
44
37
  # RSpec Rails can automatically mix in different behaviours to your tests
45
38
  # based on their file location, for example enabling you to call `get` and
@@ -63,5 +56,10 @@ RSpec.configure do |config|
63
56
 
64
57
  config.include RSpec::Matchers
65
58
  config.include Bobot::Engine.routes.url_helpers
66
- config.before { |_| Bobot.reset! }
59
+ config.before do |_|
60
+ Bobot.config = Bobot::Configuration.new
61
+ Bobot.configure do |c|
62
+ c.pages = []
63
+ end
64
+ end
67
65
  end
metadata CHANGED
@@ -1,49 +1,49 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bobot
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.53
4
+ version: 2.1.0
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-02 00:00:00.000000000 Z
11
+ date: 2017-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rails
14
+ name: i18n
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '5'
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: '6'
19
+ version: '0'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
24
  - - ">="
28
25
  - !ruby/object:Gem::Version
29
- version: '5'
30
- - - "<"
31
- - !ruby/object:Gem::Version
32
- version: '6'
26
+ version: '0'
33
27
  - !ruby/object:Gem::Dependency
34
- name: i18n
28
+ name: rails
35
29
  requirement: !ruby/object:Gem::Requirement
36
30
  requirements:
37
31
  - - ">="
38
32
  - !ruby/object:Gem::Version
39
- version: '0'
33
+ version: '5'
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: '6'
40
37
  type: :runtime
41
38
  prerelease: false
42
39
  version_requirements: !ruby/object:Gem::Requirement
43
40
  requirements:
44
41
  - - ">="
45
42
  - !ruby/object:Gem::Version
46
- version: '0'
43
+ version: '5'
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '6'
47
47
  description: Bobot is a Ruby wrapped framework to build easily a Facebook Messenger
48
48
  Bot.
49
49
  email:
@@ -62,8 +62,6 @@ files:
62
62
  - app/jobs/bobot/application_job.rb
63
63
  - app/jobs/bobot/commander_job.rb
64
64
  - app/jobs/bobot/deliver_job.rb
65
- - app/mailers/bobot/application_mailer.rb
66
- - app/models/bobot/application_record.rb
67
65
  - config/locales/bobot.en.yml
68
66
  - config/routes.rb
69
67
  - lib/bobot.rb
@@ -78,6 +76,7 @@ files:
78
76
  - lib/bobot/events/delivery.rb
79
77
  - lib/bobot/events/message.rb
80
78
  - lib/bobot/events/message_echo.rb
79
+ - lib/bobot/events/message_request.rb
81
80
  - lib/bobot/events/optin.rb
82
81
  - lib/bobot/events/postback.rb
83
82
  - lib/bobot/events/read.rb
@@ -89,8 +88,6 @@ files:
89
88
  - lib/bobot/user.rb
90
89
  - lib/bobot/version.rb
91
90
  - lib/generators/bobot/install_generator.rb
92
- - lib/generators/bobot/templates/app/bobot/message.rb
93
- - lib/generators/bobot/templates/app/bobot/postback.rb
94
91
  - lib/generators/bobot/templates/app/bobot/workflow.rb
95
92
  - lib/generators/bobot/templates/config/bobot.yml
96
93
  - lib/generators/bobot/templates/config/initializers/bobot.rb
@@ -120,10 +117,13 @@ files:
120
117
  - spec/dummy/app/assets/config/manifest.js
121
118
  - spec/dummy/app/assets/javascripts/application.js
122
119
  - spec/dummy/app/assets/stylesheets/application.css
123
- - spec/dummy/app/bobot/workflow.rb
120
+ - spec/dummy/app/channels/application_cable/channel.rb
121
+ - spec/dummy/app/channels/application_cable/connection.rb
124
122
  - spec/dummy/app/controllers/application_controller.rb
125
123
  - spec/dummy/app/jobs/application_job.rb
126
- - spec/dummy/app/models/application_record.rb
124
+ - spec/dummy/app/mailers/application_mailer.rb
125
+ - spec/dummy/app/views/layouts/mailer.html.erb
126
+ - spec/dummy/app/views/layouts/mailer.text.erb
127
127
  - spec/dummy/bin/bundle
128
128
  - spec/dummy/bin/rails
129
129
  - spec/dummy/bin/rake
@@ -131,29 +131,32 @@ files:
131
131
  - spec/dummy/bin/update
132
132
  - spec/dummy/config.ru
133
133
  - spec/dummy/config/application.rb
134
- - spec/dummy/config/bobot.yml
135
134
  - spec/dummy/config/boot.rb
136
- - spec/dummy/config/database.yml
135
+ - spec/dummy/config/cable.yml
137
136
  - spec/dummy/config/environment.rb
138
137
  - spec/dummy/config/environments/development.rb
139
138
  - spec/dummy/config/environments/production.rb
140
139
  - spec/dummy/config/environments/test.rb
141
140
  - spec/dummy/config/initializers/application_controller_renderer.rb
142
141
  - spec/dummy/config/initializers/backtrace_silencers.rb
143
- - spec/dummy/config/initializers/bobot.rb
144
142
  - spec/dummy/config/initializers/cors.rb
145
143
  - spec/dummy/config/initializers/filter_parameter_logging.rb
146
144
  - spec/dummy/config/initializers/inflections.rb
147
145
  - spec/dummy/config/initializers/mime_types.rb
148
146
  - spec/dummy/config/initializers/wrap_parameters.rb
149
- - spec/dummy/config/locales/bobot.en.yml
150
- - spec/dummy/config/locales/bobot.fr.yml
151
147
  - spec/dummy/config/locales/en.yml
152
148
  - spec/dummy/config/puma.rb
153
149
  - spec/dummy/config/routes.rb
154
150
  - spec/dummy/config/secrets.yml
155
151
  - spec/dummy/config/spring.rb
156
- - spec/dummy/db/schema.rb
152
+ - spec/dummy/log/development.log
153
+ - spec/dummy/log/test.log
154
+ - spec/dummy/tmp/generator/app/bobot/workflow.rb
155
+ - spec/dummy/tmp/generator/config/bobot.yml
156
+ - spec/dummy/tmp/generator/config/initializers/bobot.rb
157
+ - spec/dummy/tmp/generator/config/locales/bobot.en.yml
158
+ - spec/dummy/tmp/generator/config/locales/bobot.fr.yml
159
+ - spec/dummy/tmp/generator/config/routes.rb
157
160
  - spec/examples.txt
158
161
  - spec/helpers/graph_api_helpers.rb
159
162
  - spec/jobs/bobot/commander_job_spec.rb
@@ -207,41 +210,47 @@ test_files:
207
210
  - spec/dummy/app/assets/config/manifest.js
208
211
  - spec/dummy/app/assets/javascripts/application.js
209
212
  - spec/dummy/app/assets/stylesheets/application.css
210
- - spec/dummy/app/bobot/workflow.rb
213
+ - spec/dummy/app/channels/application_cable/channel.rb
214
+ - spec/dummy/app/channels/application_cable/connection.rb
211
215
  - spec/dummy/app/controllers/application_controller.rb
212
216
  - spec/dummy/app/jobs/application_job.rb
213
- - spec/dummy/app/models/application_record.rb
217
+ - spec/dummy/app/mailers/application_mailer.rb
218
+ - spec/dummy/app/views/layouts/mailer.html.erb
219
+ - spec/dummy/app/views/layouts/mailer.text.erb
214
220
  - spec/dummy/bin/bundle
215
221
  - spec/dummy/bin/rails
216
222
  - spec/dummy/bin/rake
217
223
  - spec/dummy/bin/setup
218
224
  - spec/dummy/bin/update
219
225
  - spec/dummy/config/application.rb
220
- - spec/dummy/config/bobot.yml
221
226
  - spec/dummy/config/boot.rb
222
- - spec/dummy/config/database.yml
227
+ - spec/dummy/config/cable.yml
223
228
  - spec/dummy/config/environment.rb
224
229
  - spec/dummy/config/environments/development.rb
225
230
  - spec/dummy/config/environments/production.rb
226
231
  - spec/dummy/config/environments/test.rb
227
232
  - spec/dummy/config/initializers/application_controller_renderer.rb
228
233
  - spec/dummy/config/initializers/backtrace_silencers.rb
229
- - spec/dummy/config/initializers/bobot.rb
230
234
  - spec/dummy/config/initializers/cors.rb
231
235
  - spec/dummy/config/initializers/filter_parameter_logging.rb
232
236
  - spec/dummy/config/initializers/inflections.rb
233
237
  - spec/dummy/config/initializers/mime_types.rb
234
238
  - spec/dummy/config/initializers/wrap_parameters.rb
235
- - spec/dummy/config/locales/bobot.en.yml
236
- - spec/dummy/config/locales/bobot.fr.yml
237
239
  - spec/dummy/config/locales/en.yml
238
240
  - spec/dummy/config/puma.rb
239
241
  - spec/dummy/config/routes.rb
240
242
  - spec/dummy/config/secrets.yml
241
243
  - spec/dummy/config/spring.rb
242
244
  - spec/dummy/config.ru
243
- - spec/dummy/db/schema.rb
245
+ - spec/dummy/log/development.log
246
+ - spec/dummy/log/test.log
244
247
  - spec/dummy/Rakefile
248
+ - spec/dummy/tmp/generator/app/bobot/workflow.rb
249
+ - spec/dummy/tmp/generator/config/bobot.yml
250
+ - spec/dummy/tmp/generator/config/initializers/bobot.rb
251
+ - spec/dummy/tmp/generator/config/locales/bobot.en.yml
252
+ - spec/dummy/tmp/generator/config/locales/bobot.fr.yml
253
+ - spec/dummy/tmp/generator/config/routes.rb
245
254
  - spec/examples.txt
246
255
  - spec/helpers/graph_api_helpers.rb
247
256
  - spec/jobs/bobot/commander_job_spec.rb
@@ -1,6 +0,0 @@
1
- module Bobot
2
- class ApplicationMailer < ActionMailer::Base
3
- default from: 'from@example.com'
4
- layout 'mailer'
5
- end
6
- end
@@ -1,5 +0,0 @@
1
- module Bobot
2
- class ApplicationRecord < ActiveRecord::Base
3
- self.abstract_class = true
4
- end
5
- end
@@ -1,3 +0,0 @@
1
- class Message
2
- def perform(message); end
3
- end
@@ -1,22 +0,0 @@
1
- module Bobot
2
- class Postback
3
- def self.perform(event)
4
- payload = event.payload
5
- begin
6
- payload = ActiveSupport::JSON.decode(payload)
7
- step = payload["step"]
8
- params = payload["params"].hash
9
- rescue ::ActiveSupport::JSON.parse_error
10
- step = payload.to_sym
11
- params = nil
12
- end
13
-
14
- bot = Postback.new(event)
15
- if bot.respond_to?(step)
16
- bot.public_send(*([step, params].compact))
17
- else
18
- bot.unknown_payload
19
- end
20
- end
21
- end
22
- end
@@ -1,17 +0,0 @@
1
- Bobot::Commander.on :message do |message|
2
- message.reply_with_text(text: "Hello, human! My reply to your message: '#{message.text}'")
3
- end
4
-
5
- Bobot::Commander.on :postback do |postback|
6
- if postback.payload == 'WHAT_IS_A_CHATBOT'
7
- postback.reply_with_text(text: I18n.t('bobot.what_is_a_chatbot'))
8
- end
9
- end
10
-
11
- Bobot::Commander.on :optin do |optin|
12
- optin.reply_with_text(text: "Ah, human! Clicked on Send To Messenger your came from '#{ref}'")
13
- end
14
-
15
- Bobot::Commander.on :referral do |referral|
16
- referral.reply_with_text(text: "Great you came from #{referal.ref}")
17
- end
@@ -1,3 +0,0 @@
1
- class ApplicationRecord < ActiveRecord::Base
2
- self.abstract_class = true
3
- end
@@ -1,27 +0,0 @@
1
- shared:
2
- debug_log: true
3
- async: false
4
-
5
- development:
6
- app_id: ""
7
- app_secret: ""
8
- page_id: ""
9
- page_access_token: ""
10
- verify_token: ""
11
- domains: ""
12
-
13
- test:
14
- app_id: ""
15
- app_secret: ""
16
- page_id: ""
17
- page_access_token: ""
18
- verify_token: ""
19
- domains: ""
20
-
21
- production:
22
- app_id: <%= ENV["BOBOT_APP_ID"] %>
23
- app_secret: <%= ENV["BOBOT_APP_SECRET"] %>
24
- page_id: <%= ENV["BOBOT_PAGE_ID"] %>
25
- page_access_token: <%= ENV["BOBOT_PAGE_ACCESS_TOKEN"] %>
26
- verify_token: <%= ENV["BOBOT_VERIFY_TOKEN"] %>
27
- domains: <%= ENV["BOBOT_DOMAINS"] %>
@@ -1,19 +0,0 @@
1
- default: &default
2
- adapter: mysql2
3
- encoding: utf8mb4
4
- collation: utf8mb4_bin
5
- pool: 5
6
- username: root
7
- password:
8
-
9
- development:
10
- <<: *default
11
- database: bobot_development
12
-
13
- test:
14
- <<: *default
15
- database: bobot_test
16
-
17
- production:
18
- <<: *default
19
- database: bobot_production
@@ -1,30 +0,0 @@
1
- bobot_config_path = Rails.root.join("config", "bobot.yml")
2
- bobot_config = YAML.safe_load(ERB.new(File.read(bobot_config_path)).result)[Rails.env]
3
-
4
- if bobot_config.present?
5
- Bobot.configure do |config|
6
- config.app_id = bobot_config["app_id"]
7
- config.app_secret = bobot_config["app_secret"]
8
- config.page_access_token = bobot_config["page_access_token"]
9
- config.page_id = bobot_config["page_id"]
10
- config.verify_token = bobot_config["verify_token"]
11
- config.domains = bobot_config["domains"]
12
- config.debug_log = bobot_config["debug_log"]
13
- config.async = bobot_config["async"]
14
- end
15
- else
16
- warn "#{bobot_config_path} not configured yet in #{Rails.env} environment."
17
- end
18
-
19
- unless Rails.env.production?
20
- bot_files = Dir[Rails.root.join("app", "bobot", "**", "*.rb")]
21
- bot_reloader = ActiveSupport::FileUpdateChecker.new(bot_files) do
22
- bot_files.each { |file| require_dependency file }
23
- end
24
-
25
- ActiveSupport::Reloader.to_prepare do
26
- bot_reloader.execute_if_updated
27
- end
28
-
29
- bot_files.each { |file| require_dependency file }
30
- end
@@ -1,28 +0,0 @@
1
- en:
2
- bobot:
3
- config:
4
- facebook_locales:
5
- - "en_US"
6
- - "en_UD"
7
- - "en_GB"
8
- greeting_text: "Bobot is an intelligent robot."
9
- persistent_menu:
10
- composer_input_disabled: false
11
- call_to_actions:
12
- - title: "My Account"
13
- type: "nested"
14
- call_to_actions:
15
- - title: "What is a chatbot?"
16
- type: "postback"
17
- payload: "WHAT_IS_A_CHATBOT"
18
- - title: "History"
19
- type: "postback"
20
- payload: "HISTORY_PAYLOAD"
21
- - title: "Contact Info"
22
- type: "postback"
23
- payload: "CONTACT_INFO_PAYLOAD"
24
- - type: "web_url"
25
- title: "Get some help"
26
- url: "https://github.com/navidemad/bobot"
27
- webview_height_ratio: "full"
28
- what_is_a_chatbot: "A chatbot is a computer program which conducts a conversation via auditory or textual methods."
@@ -1,27 +0,0 @@
1
- fr:
2
- bobot:
3
- config:
4
- facebook_locales:
5
- - "fr_FR"
6
- - "fr_CA"
7
- greeting_text: 'Bobot est un robot intelligent.'
8
- persistent_menu:
9
- composer_input_disabled: false
10
- call_to_actions:
11
- - title: "Mon compte"
12
- type: "nested"
13
- call_to_actions:
14
- - title: "C'est quoi un chatbot ?"
15
- type: "postback"
16
- payload: "WHAT_IS_A_CHATBOT"
17
- - title: "Historique"
18
- type: "postback"
19
- payload: "HISTORY_PAYLOAD"
20
- - title: "Contact Info"
21
- type: "postback"
22
- payload: "CONTACT_INFO_PAYLOAD"
23
- - type: "web_url"
24
- title: "Obtenir de l'aide"
25
- url: "https://github.com/navidemad/bobot"
26
- webview_height_ratio: "full"
27
- what_is_a_chatbot: "Un chatbot est un programme qui tente de converser avec une personne durant quelques minutes ou plus en lui donnant l'impression de converser elle-même avec une personne."
@@ -1,15 +0,0 @@
1
- # This file is auto-generated from the current state of the database. Instead
2
- # of editing this file, please use the migrations feature of Active Record to
3
- # incrementally modify your database, and then regenerate this schema definition.
4
- #
5
- # Note that this schema.rb definition is the authoritative source for your
6
- # database schema. If you need to create the application database on another
7
- # system, you should be using db:schema:load, not running all the migrations
8
- # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9
- # you'll amass, the slower it'll run and the greater likelihood for issues).
10
- #
11
- # It's strongly recommended that you check this file into your version control system.
12
-
13
- ActiveRecord::Schema.define(version: 0) do
14
-
15
- end