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 +4 -4
- data/lib/bot/context.rb +4 -4
- data/lib/bot/handler.rb +3 -2
- data/lib/bot/responder.rb +4 -3
- data/lib/bot/version.rb +1 -1
- data/test/dummy/log/test.log +43 -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: adf1928c71e4656d5f707f961b19046f86943938
|
4
|
+
data.tar.gz: 9f5cce89a6dfa56e5decf834e376fb4a1719087a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1eb4fb9d161fce264825176a4a2a830055fad3b75328977cf9cc3309e33b7624a8b655c2b296fd4eafe5e86145b13029f92ea5cb4630ddbe6093b79f844fb279
|
7
|
+
data.tar.gz: 67a7c2bc42f97e161c3de22026fe34b9b0d805811c9f696a5cf229ad549e2b28e1e57cf7a39fd29c649b474a81badc9354bfe4e9de9d227a3c7ebe295e66d67a
|
data/lib/bot/context.rb
CHANGED
@@ -2,11 +2,11 @@ require 'redis'
|
|
2
2
|
|
3
3
|
module Bot
|
4
4
|
class Context
|
5
|
-
attr_accessor :redis_client, :
|
5
|
+
attr_accessor :redis_client, :id
|
6
6
|
|
7
|
-
def initialize(
|
7
|
+
def initialize(id, redis_client)
|
8
8
|
@redis_client = redis_client
|
9
|
-
@
|
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:#{
|
41
|
+
"bot:context:#{id}"
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
data/lib/bot/handler.rb
CHANGED
@@ -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,
|
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
|
data/lib/bot/responder.rb
CHANGED
@@ -5,7 +5,7 @@ module Bot
|
|
5
5
|
|
6
6
|
class_attribute :respond_to_types
|
7
7
|
|
8
|
-
attr_reader :message, :user, :responses, :handler, :
|
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,
|
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)
|
data/lib/bot/version.rb
CHANGED
data/test/dummy/log/test.log
CHANGED
@@ -3594,3 +3594,46 @@ Completed 500 Internal Server Error in 1ms (ActiveRecord: 0.0ms)
|
|
3594
3594
|
BotTest: test_truth
|
3595
3595
|
-------------------
|
3596
3596
|
[1m[35m (0.0ms)[0m rollback transaction
|
3597
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.4ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
3598
|
+
[1m[36m (1.6ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL) [0m
|
3599
|
+
[1m[35m (0.5ms)[0m select sqlite_version(*)
|
3600
|
+
[1m[36m (0.9ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
3601
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
3602
|
+
[1m[36m (0.9ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
3603
|
+
[1m[35mActiveRecord::SchemaMigration Load (0.1ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
3604
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
3605
|
+
-------------------
|
3606
|
+
BotTest: test_truth
|
3607
|
+
-------------------
|
3608
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
3609
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
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
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
3618
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
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
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
3627
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
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
|
+
[1m[35m (0.1ms)[0m 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.
|
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-
|
11
|
+
date: 2016-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|