bot 0.0.38 → 0.0.39
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.rb +1 -0
- data/lib/bot/adapters/kik.rb +1 -0
- data/lib/bot/message.rb +9 -0
- data/lib/bot/messages/base.rb +52 -0
- data/lib/bot/messages/card.rb +25 -0
- data/lib/bot/messages/photo.rb +16 -0
- data/lib/bot/messages/text.rb +17 -0
- data/lib/bot/version.rb +1 -1
- data/lib/generators/bot/install/templates/application_handler.rb +3 -3
- data/test/dummy/log/test.log +43 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 951e4e152862eee4b853af458c49cee8f475b47b
|
4
|
+
data.tar.gz: 6bce5bdbfac1ff26fbff658ccd3c3d510a463786
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 162074b4e8b28f632f39c886c1cd38fcc7865fb2b0c7a505335535307ff780732086e9d867b55b4eede1ee373bcc7d68533cc4b30483add087f4e96a18e06494
|
7
|
+
data.tar.gz: 3fdc9cde3617f0dcc512aa6216381c982061bb326f1caf198e77dc6eeb4590c473dad0ac0837fbadbb9549d7338d4b7ab8b2553c27d6dcca05f35b526ba9401c
|
data/lib/bot.rb
CHANGED
data/lib/bot/adapters/kik.rb
CHANGED
data/lib/bot/message.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
module Bot
|
2
|
+
module Message
|
3
|
+
class Base
|
4
|
+
attr_accessor :message
|
5
|
+
|
6
|
+
def initialize(to, options=false)
|
7
|
+
raise NotImplementedError
|
8
|
+
end
|
9
|
+
|
10
|
+
def as_json(options=nil)
|
11
|
+
self.message.to_h
|
12
|
+
end
|
13
|
+
|
14
|
+
def method_missing(m, *args, &block)
|
15
|
+
if m =~ /.+=/
|
16
|
+
args.each do |arg|
|
17
|
+
self.message[m.to_s.gsub('=', '')] = arg
|
18
|
+
end
|
19
|
+
else
|
20
|
+
self.message[m.to_s]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
protected
|
25
|
+
def suggested_responses=(suggested_responses)
|
26
|
+
case suggested_responses
|
27
|
+
when Array
|
28
|
+
self.message['keyboards'] = [{
|
29
|
+
'type' => 'suggested',
|
30
|
+
'responses' => build_suggested_responses(suggested_responses)
|
31
|
+
}]
|
32
|
+
when Hash
|
33
|
+
self.message.merge!(suggested_responses)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def build_suggested_responses(suggested_responses)
|
38
|
+
suggested_responses.map do |response|
|
39
|
+
case response
|
40
|
+
when String
|
41
|
+
{
|
42
|
+
'type' => 'text',
|
43
|
+
'body' => response
|
44
|
+
}
|
45
|
+
when Hash
|
46
|
+
response
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Bot
|
2
|
+
module Message
|
3
|
+
class Card < Base
|
4
|
+
def initialize(to, url, text, suggested_responses=false, options={})
|
5
|
+
icon = options.delete("icon")
|
6
|
+
|
7
|
+
self.message = {
|
8
|
+
'type' => 'link',
|
9
|
+
'to' => to,
|
10
|
+
'url' => url,
|
11
|
+
'title' => "", # Displays over the image
|
12
|
+
'text' => text, # Displays under the image
|
13
|
+
'attribution' => {
|
14
|
+
'name' => text # Displays in bottom line
|
15
|
+
},
|
16
|
+
}.merge(options)
|
17
|
+
|
18
|
+
self.message['picUrl'] = icon if icon
|
19
|
+
self.message['attribution']['iconUrl'] = icon if icon
|
20
|
+
|
21
|
+
self.suggested_responses = suggested_responses
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Bot
|
2
|
+
module Message
|
3
|
+
class Photo < Base
|
4
|
+
def initialize(to, photo_url, suggested_responses=false, options={})
|
5
|
+
self.message = {
|
6
|
+
'type' => 'gallery',
|
7
|
+
'to' => to,
|
8
|
+
'picUrl' => photo_url,
|
9
|
+
'typeTime' => 0,
|
10
|
+
}.merge(options)
|
11
|
+
|
12
|
+
self.suggested_responses = suggested_responses
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Bot
|
2
|
+
module Message
|
3
|
+
class Text < Base
|
4
|
+
def initialize(to, body, suggested_responses=false, options={})
|
5
|
+
self.message = {
|
6
|
+
'type' => 'text',
|
7
|
+
'to' => to,
|
8
|
+
'body' => body,
|
9
|
+
'typeTime' => 0,
|
10
|
+
}.merge(options)
|
11
|
+
|
12
|
+
self.message['chatId'] = options['chatId'] if options['chatId']
|
13
|
+
self.suggested_responses = suggested_responses
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/bot/version.rb
CHANGED
data/test/dummy/log/test.log
CHANGED
@@ -3379,3 +3379,46 @@ Processing by Bot::BotController#notify as HTML
|
|
3379
3379
|
Parameters: {"messages"=>[{"body"=>"multi", "readReceiptRequested"=>"true", "from"=>"bnmrrs", "timestamp"=>"1452785908454", "type"=>"scan-data", "id"=>"2af0d873-d157-4627-b863-8be11b0dfd86"}], "bot"=>ApplicationHandler}
|
3380
3380
|
Completed 200 OK in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
|
3381
3381
|
[1m[35m (0.1ms)[0m rollback transaction
|
3382
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.5ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
3383
|
+
[1m[36m (1.0ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL) [0m
|
3384
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
3385
|
+
[1m[36m (0.8ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
3386
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
3387
|
+
[1m[36m (0.7ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
3388
|
+
[1m[35mActiveRecord::SchemaMigration Load (0.1ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
3389
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
3390
|
+
-------------------
|
3391
|
+
BotTest: test_truth
|
3392
|
+
-------------------
|
3393
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
3394
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
3395
|
+
---------------------------------------
|
3396
|
+
NavigationTest: test_notify_multi_types
|
3397
|
+
---------------------------------------
|
3398
|
+
Started POST "/bot/notify" for 127.0.0.1 at 2016-05-03 14:23:13 -0400
|
3399
|
+
Processing by Bot::BotController#notify as HTML
|
3400
|
+
Parameters: {"messages"=>[{"body"=>"multi", "readReceiptRequested"=>"true", "from"=>"bnmrrs", "timestamp"=>"1452785908454", "type"=>"scan-data", "id"=>"2af0d873-d157-4627-b863-8be11b0dfd86"}], "bot"=>ApplicationHandler}
|
3401
|
+
Completed 200 OK in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
|
3402
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
3403
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
3404
|
+
-----------------------------------------
|
3405
|
+
NavigationTest: test_notify_special_types
|
3406
|
+
-----------------------------------------
|
3407
|
+
Started POST "/bot/notify" for 127.0.0.1 at 2016-05-03 14:23:13 -0400
|
3408
|
+
Processing by Bot::BotController#notify as HTML
|
3409
|
+
Parameters: {"messages"=>[{"body"=>"Hello", "readReceiptRequested"=>"true", "from"=>"bnmrrs", "timestamp"=>"1452785908454", "type"=>"scan-data", "id"=>"2af0d873-d157-4627-b863-8be11b0dfd86"}], "bot"=>ApplicationHandler}
|
3410
|
+
Completed 200 OK in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
|
3411
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
3412
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
3413
|
+
---------------------------
|
3414
|
+
NavigationTest: test_notify
|
3415
|
+
---------------------------
|
3416
|
+
Started POST "/bot/notify" for 127.0.0.1 at 2016-05-03 14:23:13 -0400
|
3417
|
+
Processing by Bot::BotController#notify as HTML
|
3418
|
+
Parameters: {"bot"=>ApplicationHandler}
|
3419
|
+
Completed 200 OK in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
|
3420
|
+
Started POST "/bot/notify" for 127.0.0.1 at 2016-05-03 14:23:13 -0400
|
3421
|
+
Processing by Bot::BotController#notify as HTML
|
3422
|
+
Parameters: {"messages"=>[{"body"=>"Hello", "readReceiptRequested"=>"true", "from"=>"bnmrrs", "timestamp"=>"1452785908454", "type"=>"text", "id"=>"2af0d873-d157-4627-b863-8be11b0dfd86"}], "bot"=>ApplicationHandler}
|
3423
|
+
Completed 200 OK in 0ms (Views: 0.2ms | ActiveRecord: 0.0ms)
|
3424
|
+
[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.39
|
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-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -112,6 +112,11 @@ files:
|
|
112
112
|
- lib/bot/context.rb
|
113
113
|
- lib/bot/engine.rb
|
114
114
|
- lib/bot/handler.rb
|
115
|
+
- lib/bot/message.rb
|
116
|
+
- lib/bot/messages/base.rb
|
117
|
+
- lib/bot/messages/card.rb
|
118
|
+
- lib/bot/messages/photo.rb
|
119
|
+
- lib/bot/messages/text.rb
|
115
120
|
- lib/bot/responder.rb
|
116
121
|
- lib/bot/responder_chain.rb
|
117
122
|
- lib/bot/route_extensions.rb
|