bot 0.0.42 → 0.0.43

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ed6c59c83d14c69aa807260b2ba8eb2619b1aa1b
4
- data.tar.gz: 466973cc8cba1858c98ce691ee38b91609b28521
3
+ metadata.gz: adf1928c71e4656d5f707f961b19046f86943938
4
+ data.tar.gz: 9f5cce89a6dfa56e5decf834e376fb4a1719087a
5
5
  SHA512:
6
- metadata.gz: 320debce02c1194ae1ff072a581d0b315c7b92b3420caacb2d30f89d25ce1c7e8e994d5bed64bd3c4b2c6112f99b927e2edacf6c7653819d2a6579bf07a1265f
7
- data.tar.gz: d9092f01535e0cc4549e113445a313199d5dec257625ba05778435d96eaa5c4023d9364145853854b0c9e1bd7267587e4370980ca1e5bf588b6ede77c519055b
6
+ metadata.gz: 1eb4fb9d161fce264825176a4a2a830055fad3b75328977cf9cc3309e33b7624a8b655c2b296fd4eafe5e86145b13029f92ea5cb4630ddbe6093b79f844fb279
7
+ data.tar.gz: 67a7c2bc42f97e161c3de22026fe34b9b0d805811c9f696a5cf229ad549e2b28e1e57cf7a39fd29c649b474a81badc9354bfe4e9de9d227a3c7ebe295e66d67a
@@ -2,11 +2,11 @@ require 'redis'
2
2
 
3
3
  module Bot
4
4
  class Context
5
- attr_accessor :redis_client, :user
5
+ attr_accessor :redis_client, :id
6
6
 
7
- def initialize(user, redis_client)
7
+ def initialize(id, redis_client)
8
8
  @redis_client = redis_client
9
- @user = user
9
+ @id = id
10
10
  end
11
11
 
12
12
  def method_missing(m, *args, &block)
@@ -38,7 +38,7 @@ module Bot
38
38
  end
39
39
 
40
40
  def context_key
41
- "bot:context:#{user.id}"
41
+ "bot:context:#{id}"
42
42
  end
43
43
  end
44
44
  end
@@ -15,11 +15,12 @@ module Bot
15
15
  end
16
16
 
17
17
  def execute_chain(message, responses, user)
18
- context = Bot::Context.new(user, Bot.configuration.redis)
19
18
  analytics = Bot::Analytics.new(user.username, Bot.configuration.mixpanel)
19
+ user_context = Bot::Context.new(user.id, Bot.configuration.redis)
20
+ chat_context = Bot::Context.new(message["chatId"].to_i, Bot.configuration.redis)
20
21
 
21
22
  responder_chain.responders.each do |responder|
22
- responder = responder.new(message, user, responses, self, context, analytics)
23
+ responder = responder.new(message, user, responses, self, analytics, user_context, chat_context)
23
24
  if responder.can_respond_to_type?(message['type']) && responder.can_handle?
24
25
  responses << responder.handle
25
26
  break
@@ -5,7 +5,7 @@ module Bot
5
5
 
6
6
  class_attribute :respond_to_types
7
7
 
8
- attr_reader :message, :user, :responses, :handler, :context, :analytics
8
+ attr_reader :message, :user, :responses, :handler, :analytics, :user_context, :chat_context
9
9
 
10
10
  def self.respond_to(*types)
11
11
  new_types = (respond_to_types || []).dup
@@ -13,13 +13,14 @@ module Bot
13
13
  self.respond_to_types = new_types.freeze
14
14
  end
15
15
 
16
- def initialize(message, user, responses, handler, context, analytics)
16
+ def initialize(message, user, responses, handler, analytics, user_context, chat_context)
17
17
  @message = message
18
18
  @user = user
19
19
  @responses = responses
20
20
  @handler = handler
21
- @context = context
22
21
  @analytics = analytics
22
+ @user_context = user_context
23
+ @chat_context = chat_context
23
24
  end
24
25
 
25
26
  def can_respond_to_type?(type)
@@ -1,3 +1,3 @@
1
1
  module Bot
2
- VERSION = "0.0.42"
2
+ VERSION = "0.0.43"
3
3
  end
@@ -3594,3 +3594,46 @@ Completed 500 Internal Server Error in 1ms (ActiveRecord: 0.0ms)
3594
3594
  BotTest: test_truth
3595
3595
  -------------------
3596
3596
   (0.0ms) rollback transaction
3597
+ ActiveRecord::SchemaMigration Load (0.4ms) SELECT "schema_migrations".* FROM "schema_migrations"
3598
+  (1.6ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
3599
+  (0.5ms) select sqlite_version(*)
3600
+  (0.9ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
3601
+  (0.1ms) SELECT version FROM "schema_migrations"
3602
+  (0.9ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
3603
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
3604
+  (0.1ms) begin transaction
3605
+ -------------------
3606
+ BotTest: test_truth
3607
+ -------------------
3608
+  (0.1ms) rollback transaction
3609
+  (0.0ms) begin transaction
3610
+ ---------------------------------------
3611
+ NavigationTest: test_notify_multi_types
3612
+ ---------------------------------------
3613
+ Started POST "/bot/notify" for 127.0.0.1 at 2016-05-05 10:54:01 -0400
3614
+ Processing by Bot::BotController#notify as HTML
3615
+ Parameters: {"messages"=>[{"body"=>"multi", "readReceiptRequested"=>"true", "from"=>"bnmrrs", "timestamp"=>"1452785908454", "type"=>"scan-data", "id"=>"2af0d873-d157-4627-b863-8be11b0dfd86"}], "bot"=>ApplicationHandler}
3616
+ Completed 500 Internal Server Error in 2ms (ActiveRecord: 0.0ms)
3617
+  (0.1ms) rollback transaction
3618
+  (0.1ms) begin transaction
3619
+ -----------------------------------------
3620
+ NavigationTest: test_notify_special_types
3621
+ -----------------------------------------
3622
+ Started POST "/bot/notify" for 127.0.0.1 at 2016-05-05 10:54:01 -0400
3623
+ Processing by Bot::BotController#notify as HTML
3624
+ Parameters: {"messages"=>[{"body"=>"Hello", "readReceiptRequested"=>"true", "from"=>"bnmrrs", "timestamp"=>"1452785908454", "type"=>"scan-data", "id"=>"2af0d873-d157-4627-b863-8be11b0dfd86"}], "bot"=>ApplicationHandler}
3625
+ Completed 500 Internal Server Error in 2ms (ActiveRecord: 0.0ms)
3626
+  (0.1ms) rollback transaction
3627
+  (0.1ms) begin transaction
3628
+ ---------------------------
3629
+ NavigationTest: test_notify
3630
+ ---------------------------
3631
+ Started POST "/bot/notify" for 127.0.0.1 at 2016-05-05 10:54:01 -0400
3632
+ Processing by Bot::BotController#notify as HTML
3633
+ Parameters: {"bot"=>ApplicationHandler}
3634
+ Completed 200 OK in 0ms (Views: 0.2ms | ActiveRecord: 0.0ms)
3635
+ Started POST "/bot/notify" for 127.0.0.1 at 2016-05-05 10:54:01 -0400
3636
+ Processing by Bot::BotController#notify as HTML
3637
+ Parameters: {"messages"=>[{"body"=>"Hello", "readReceiptRequested"=>"true", "from"=>"bnmrrs", "timestamp"=>"1452785908454", "type"=>"text", "id"=>"2af0d873-d157-4627-b863-8be11b0dfd86"}], "bot"=>ApplicationHandler}
3638
+ Completed 500 Internal Server Error in 1ms (ActiveRecord: 0.0ms)
3639
+  (0.1ms) rollback transaction
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.42
4
+ version: 0.0.43
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Morris
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-04 00:00:00.000000000 Z
11
+ date: 2016-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails