bot 0.0.35 → 0.0.37
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/bot/bot_controller.rb +14 -4
- data/lib/bot/adapters/base.rb +4 -0
- data/lib/bot/adapters/kik.rb +6 -0
- data/lib/bot/adapters/test.rb +4 -0
- data/lib/bot/version.rb +1 -1
- data/lib/generators/bot/install/templates/default_responder.rb +1 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/test.log +86 -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: 381717efe3e79e2c030de08782b30420e077109e
|
4
|
+
data.tar.gz: 582e298ffd95f57c30c3ab07a47f6f1b434c6adf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd976cc2e6a04693edb376c4a1350e7fc83cf937706eb8dd3d529070c8373c752fb1685cd26ab9bcd1ad6c6484c2203d117294a86b9aa9be40fdd9efaad95084
|
7
|
+
data.tar.gz: 19048aa8a5339e05144f5296e3cc767eb54bdd3b96444572b81ed0b0c27b6e67f4040ce42ce3fa4b86d9fca890a54e5e5bbd217c90b475720ed16286f77c0eeb
|
@@ -1,20 +1,30 @@
|
|
1
1
|
class Bot::BotController < ActionController::Base
|
2
|
+
before_action :verify_signature
|
3
|
+
|
2
4
|
def notify
|
3
5
|
@responses = bot_handler.handle(messages).compact
|
4
|
-
|
5
|
-
adapter.send_messages(@responses, params[:bot_username]) if @responses.present?
|
6
|
-
|
6
|
+
adapter.send_messages(@responses, bot_username) if @responses.present?
|
7
7
|
render json: []
|
8
8
|
end
|
9
9
|
|
10
10
|
private
|
11
11
|
|
12
|
+
def verify_signature
|
13
|
+
unless adapter.verify_signature(request.headers["HTTP_X_KIK_SIGNATURE"], request.raw_post, bot_username)
|
14
|
+
head :forbidden
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
12
18
|
def messages
|
13
19
|
Array.wrap(params[:messages]).map do |m|
|
14
|
-
m.merge(to:
|
20
|
+
m.merge(to: bot_username)
|
15
21
|
end
|
16
22
|
end
|
17
23
|
|
24
|
+
def bot_username
|
25
|
+
request.headers["HTTP_X_KIK_USERNAME"]
|
26
|
+
end
|
27
|
+
|
18
28
|
def adapter
|
19
29
|
Bot.configuration.adapter
|
20
30
|
end
|
data/lib/bot/adapters/base.rb
CHANGED
data/lib/bot/adapters/kik.rb
CHANGED
@@ -33,6 +33,12 @@ module Bot
|
|
33
33
|
profile['profilePicUrl'] || ''
|
34
34
|
end
|
35
35
|
|
36
|
+
def verify_signature(signature, body, from)
|
37
|
+
digest = OpenSSL::Digest.new('sha1')
|
38
|
+
key = config(from)[:bot_token]
|
39
|
+
signature == OpenSSL::HMAC.hexdigest(digest, key, body).upcase
|
40
|
+
end
|
41
|
+
|
36
42
|
protected
|
37
43
|
|
38
44
|
def get_profile(username, from)
|
data/lib/bot/adapters/test.rb
CHANGED
data/lib/bot/version.rb
CHANGED
data/test/dummy/db/test.sqlite3
CHANGED
Binary file
|
data/test/dummy/log/test.log
CHANGED
@@ -3248,5 +3248,91 @@ NavigationTest: test_notify_special_types
|
|
3248
3248
|
Started POST "/bot/notify" for 127.0.0.1 at 2016-04-28 20:49:39 -0400
|
3249
3249
|
Processing by Bot::BotController#notify as HTML
|
3250
3250
|
Parameters: {"messages"=>[{"body"=>"Hello", "readReceiptRequested"=>"true", "from"=>"bnmrrs", "timestamp"=>"1452785908454", "type"=>"scan-data", "id"=>"2af0d873-d157-4627-b863-8be11b0dfd86"}], "bot"=>ApplicationHandler}
|
3251
|
+
Completed 200 OK in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
|
3252
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
3253
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.5ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
3254
|
+
[1m[36m (1.8ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL) [0m
|
3255
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
3256
|
+
[1m[36m (0.9ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
3257
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
3258
|
+
[1m[36m (0.9ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
3259
|
+
[1m[35mActiveRecord::SchemaMigration Load (0.1ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
3260
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
3261
|
+
-------------------
|
3262
|
+
BotTest: test_truth
|
3263
|
+
-------------------
|
3264
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
3265
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
3266
|
+
-----------------------------------------
|
3267
|
+
NavigationTest: test_notify_special_types
|
3268
|
+
-----------------------------------------
|
3269
|
+
Started POST "/bot/notify" for 127.0.0.1 at 2016-04-30 17:50:49 -0400
|
3270
|
+
Processing by Bot::BotController#notify as HTML
|
3271
|
+
Parameters: {"messages"=>[{"body"=>"Hello", "readReceiptRequested"=>"true", "from"=>"bnmrrs", "timestamp"=>"1452785908454", "type"=>"scan-data", "id"=>"2af0d873-d157-4627-b863-8be11b0dfd86"}], "bot"=>ApplicationHandler}
|
3272
|
+
Completed 200 OK in 1ms (Views: 0.2ms | ActiveRecord: 0.0ms)
|
3273
|
+
[1m[35m (0.2ms)[0m rollback transaction
|
3274
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
3275
|
+
---------------------------
|
3276
|
+
NavigationTest: test_notify
|
3277
|
+
---------------------------
|
3278
|
+
Started POST "/bot/notify" for 127.0.0.1 at 2016-04-30 17:50:49 -0400
|
3279
|
+
Processing by Bot::BotController#notify as HTML
|
3280
|
+
Parameters: {"bot"=>ApplicationHandler}
|
3281
|
+
Completed 200 OK in 0ms (Views: 0.2ms | ActiveRecord: 0.0ms)
|
3282
|
+
Started POST "/bot/notify" for 127.0.0.1 at 2016-04-30 17:50:49 -0400
|
3283
|
+
Processing by Bot::BotController#notify as HTML
|
3284
|
+
Parameters: {"messages"=>[{"body"=>"Hello", "readReceiptRequested"=>"true", "from"=>"bnmrrs", "timestamp"=>"1452785908454", "type"=>"text", "id"=>"2af0d873-d157-4627-b863-8be11b0dfd86"}], "bot"=>ApplicationHandler}
|
3285
|
+
Completed 200 OK in 1ms (Views: 0.3ms | ActiveRecord: 0.0ms)
|
3286
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
3287
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
3288
|
+
---------------------------------------
|
3289
|
+
NavigationTest: test_notify_multi_types
|
3290
|
+
---------------------------------------
|
3291
|
+
Started POST "/bot/notify" for 127.0.0.1 at 2016-04-30 17:50:49 -0400
|
3292
|
+
Processing by Bot::BotController#notify as HTML
|
3293
|
+
Parameters: {"messages"=>[{"body"=>"multi", "readReceiptRequested"=>"true", "from"=>"bnmrrs", "timestamp"=>"1452785908454", "type"=>"scan-data", "id"=>"2af0d873-d157-4627-b863-8be11b0dfd86"}], "bot"=>ApplicationHandler}
|
3294
|
+
Completed 200 OK in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
|
3295
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
3296
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.6ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
3297
|
+
[1m[36m (0.9ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL) [0m
|
3298
|
+
[1m[35m (0.4ms)[0m select sqlite_version(*)
|
3299
|
+
[1m[36m (0.8ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
3300
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
3301
|
+
[1m[36m (0.7ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
3302
|
+
[1m[35mActiveRecord::SchemaMigration Load (0.1ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
3303
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
3304
|
+
-------------------
|
3305
|
+
BotTest: test_truth
|
3306
|
+
-------------------
|
3307
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
3308
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
3309
|
+
---------------------------------------
|
3310
|
+
NavigationTest: test_notify_multi_types
|
3311
|
+
---------------------------------------
|
3312
|
+
Started POST "/bot/notify" for 127.0.0.1 at 2016-05-02 10:47:43 -0400
|
3313
|
+
Processing by Bot::BotController#notify as HTML
|
3314
|
+
Parameters: {"messages"=>[{"body"=>"multi", "readReceiptRequested"=>"true", "from"=>"bnmrrs", "timestamp"=>"1452785908454", "type"=>"scan-data", "id"=>"2af0d873-d157-4627-b863-8be11b0dfd86"}], "bot"=>ApplicationHandler}
|
3315
|
+
Completed 200 OK in 1ms (Views: 0.3ms | ActiveRecord: 0.0ms)
|
3316
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
3317
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
3318
|
+
-----------------------------------------
|
3319
|
+
NavigationTest: test_notify_special_types
|
3320
|
+
-----------------------------------------
|
3321
|
+
Started POST "/bot/notify" for 127.0.0.1 at 2016-05-02 10:47:43 -0400
|
3322
|
+
Processing by Bot::BotController#notify as HTML
|
3323
|
+
Parameters: {"messages"=>[{"body"=>"Hello", "readReceiptRequested"=>"true", "from"=>"bnmrrs", "timestamp"=>"1452785908454", "type"=>"scan-data", "id"=>"2af0d873-d157-4627-b863-8be11b0dfd86"}], "bot"=>ApplicationHandler}
|
3324
|
+
Completed 200 OK in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
|
3325
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
3326
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
3327
|
+
---------------------------
|
3328
|
+
NavigationTest: test_notify
|
3329
|
+
---------------------------
|
3330
|
+
Started POST "/bot/notify" for 127.0.0.1 at 2016-05-02 10:47:44 -0400
|
3331
|
+
Processing by Bot::BotController#notify as HTML
|
3332
|
+
Parameters: {"bot"=>ApplicationHandler}
|
3333
|
+
Completed 200 OK in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
|
3334
|
+
Started POST "/bot/notify" for 127.0.0.1 at 2016-05-02 10:47:44 -0400
|
3335
|
+
Processing by Bot::BotController#notify as HTML
|
3336
|
+
Parameters: {"messages"=>[{"body"=>"Hello", "readReceiptRequested"=>"true", "from"=>"bnmrrs", "timestamp"=>"1452785908454", "type"=>"text", "id"=>"2af0d873-d157-4627-b863-8be11b0dfd86"}], "bot"=>ApplicationHandler}
|
3251
3337
|
Completed 200 OK in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
|
3252
3338
|
[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.37
|
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-
|
11
|
+
date: 2016-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|