bot 0.0.20 → 0.0.22

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2b17a8f3cc4ff3bcd45c05655534fe4fb8301bbe
4
- data.tar.gz: 321e09a334c942ae6e2bdb777761be14e77288a2
3
+ metadata.gz: 6a9a1b48aa5afbacfcf34d04cdba5cd9472b3dfd
4
+ data.tar.gz: 3b9e84f1a57e851760a608c68bd282d4c1434472
5
5
  SHA512:
6
- metadata.gz: b6498653737b7b220f9c520838f1b92f7e10d30ea5bb1ee581db4274b865977f16351003105bd1ce284808f77f06a322cf7889b3a509f59301ffe8d21adfda25
7
- data.tar.gz: c3a4c9290cd091c419ebd9bb0347590556eb048e05d6f292a8796b1f849ec6e2997794a60648e01bf8f39f2c11b8594c4e511a82be69da3583932f1904555f20
6
+ metadata.gz: 5a0facc9f48ec114c1431cfa83d10cb7dfa7c063e63617f69b3c5b1495e0a3d16b571f4cc3a399145ecf17cd13570465e85839fb94ee73d4b3a72e225d20ee77
7
+ data.tar.gz: ffbbccac03ce03f0be9ff2c682b54667aadc3192e82543d00c0c299c54a5c5128d6d5e0e1e44e61e06d8d8bcd4fffdf80e16e6ab99720db0335f9036c9ff280d
@@ -3,7 +3,7 @@ module Bot
3
3
  class Base
4
4
  attr_reader :config
5
5
 
6
- def initialize(config=nil)
6
+ def initialize(config={})
7
7
  @config = config
8
8
  end
9
9
 
@@ -41,8 +41,10 @@ module Bot
41
41
  'to' => message['from'],
42
42
  'body' => message_text,
43
43
  'typeTime' => 0,
44
- 'chatId' => message['chatId']
45
44
  }
45
+
46
+ text_response['chatId'] = message['chatId'] if message['chatId']
47
+
46
48
  case suggested_responses
47
49
  when Array
48
50
  text_response['keyboards'] = [{
@@ -1,3 +1,3 @@
1
1
  module Bot
2
- VERSION = "0.0.20"
2
+ VERSION = "0.0.22"
3
3
  end
@@ -8,6 +8,10 @@ module Bot
8
8
  "application_responder.rb",
9
9
  "app/bot/application_responder.rb"
10
10
  )
11
+ copy_file(
12
+ "default_responder.rb",
13
+ "app/bot/responders/default.rb"
14
+ )
11
15
  copy_file(
12
16
  "application_handler.rb",
13
17
  "app/bot/application_handler.rb"
@@ -1,5 +1,5 @@
1
1
  class ApplicationHandler < Bot::Handler
2
- use Responders::ApplicationResponder
2
+ use Responders::Default
3
3
 
4
4
  # def user_for(message)
5
5
  # User.find_or_initialize_by(username: message["from"])
@@ -0,0 +1,13 @@
1
+ module Responders
2
+ class Default < ApplicationResponder
3
+ #
4
+ # def can_handle?
5
+ # true
6
+ # end
7
+ #
8
+ # def handle
9
+ # text_response('Hello!')
10
+ # end
11
+ #
12
+ end
13
+ end
@@ -1,4 +1,33 @@
1
- # desc "Explaining what the task does"
2
- # task :bot_builder do
3
- # # Task goes here
4
- # end
1
+ require 'net/http'
2
+
3
+ namespace :bot do
4
+ namespace :kik do
5
+
6
+ desc "Update a bot config"
7
+ task :configure => :environment do
8
+ uri = URI.parse("https://api.kik.com/v1/config")
9
+
10
+ request = Net::HTTP::Post.new(uri.request_uri, initheader = { "Content-Type" => "application/json" })
11
+ request.basic_auth Bot.configuration.adapter.config[:bot_user], Bot.configuration.adapter.config[:bot_token]
12
+ request.body = {
13
+ webhook: "#{ENV['CALLBACK_URL']}",
14
+ features: {
15
+ manuallySendReadReceipts: false,
16
+ receiveReadReceipts: false,
17
+ receiveDeliveryReceipts: false,
18
+ receiveIsTyping: false
19
+ }
20
+ }.to_json
21
+
22
+ http = Net::HTTP.new(uri.host, uri.port)
23
+ http.use_ssl = (uri.scheme == "https")
24
+ response = http.request(request)
25
+
26
+ if response.code == "200"
27
+ puts "Configured okay!"
28
+ else
29
+ puts "Error: #{response.body}"
30
+ end
31
+ end
32
+ end
33
+ end
@@ -2562,3 +2562,46 @@ Completed 200 OK in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
2562
2562
  BotTest: test_truth
2563
2563
  -------------------
2564
2564
   (0.0ms) rollback transaction
2565
+ ActiveRecord::SchemaMigration Load (0.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
2566
+  (1.0ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
2567
+  (0.1ms) select sqlite_version(*)
2568
+  (0.8ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
2569
+  (0.1ms) SELECT version FROM "schema_migrations"
2570
+  (0.7ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
2571
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
2572
+  (0.1ms) begin transaction
2573
+ -------------------
2574
+ BotTest: test_truth
2575
+ -------------------
2576
+  (0.0ms) rollback transaction
2577
+  (0.1ms) begin transaction
2578
+ -----------------------------------------
2579
+ NavigationTest: test_notify_special_types
2580
+ -----------------------------------------
2581
+ Started POST "/bot/notify" for 127.0.0.1 at 2016-04-07 14:29:37 -0400
2582
+ Processing by Bot::BotController#notify as HTML
2583
+ Parameters: {"messages"=>[{"body"=>"Hello", "readReceiptRequested"=>"true", "from"=>"bnmrrs", "timestamp"=>"1452785908454", "type"=>"scan-data", "id"=>"2af0d873-d157-4627-b863-8be11b0dfd86"}], "bot"=>ApplicationHandler}
2584
+ Completed 200 OK in 1ms (Views: 0.3ms | ActiveRecord: 0.0ms)
2585
+  (0.1ms) rollback transaction
2586
+  (0.1ms) begin transaction
2587
+ ---------------------------------------
2588
+ NavigationTest: test_notify_multi_types
2589
+ ---------------------------------------
2590
+ Started POST "/bot/notify" for 127.0.0.1 at 2016-04-07 14:29:37 -0400
2591
+ Processing by Bot::BotController#notify as HTML
2592
+ Parameters: {"messages"=>[{"body"=>"multi", "readReceiptRequested"=>"true", "from"=>"bnmrrs", "timestamp"=>"1452785908454", "type"=>"scan-data", "id"=>"2af0d873-d157-4627-b863-8be11b0dfd86"}], "bot"=>ApplicationHandler}
2593
+ Completed 200 OK in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
2594
+  (0.1ms) rollback transaction
2595
+  (0.0ms) begin transaction
2596
+ ---------------------------
2597
+ NavigationTest: test_notify
2598
+ ---------------------------
2599
+ Started POST "/bot/notify" for 127.0.0.1 at 2016-04-07 14:29:37 -0400
2600
+ Processing by Bot::BotController#notify as HTML
2601
+ Parameters: {"bot"=>ApplicationHandler}
2602
+ Completed 200 OK in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
2603
+ Started POST "/bot/notify" for 127.0.0.1 at 2016-04-07 14:29:37 -0400
2604
+ Processing by Bot::BotController#notify as HTML
2605
+ Parameters: {"messages"=>[{"body"=>"Hello", "readReceiptRequested"=>"true", "from"=>"bnmrrs", "timestamp"=>"1452785908454", "type"=>"text", "id"=>"2af0d873-d157-4627-b863-8be11b0dfd86"}], "bot"=>ApplicationHandler}
2606
+ Completed 200 OK in 0ms (Views: 0.0ms | ActiveRecord: 0.0ms)
2607
+  (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.20
4
+ version: 0.0.22
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-04-06 00:00:00.000000000 Z
11
+ date: 2016-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: rest-client
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 1.8.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 1.8.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -108,6 +108,7 @@ files:
108
108
  - lib/generators/bot/install/install_generator.rb
109
109
  - lib/generators/bot/install/templates/application_handler.rb
110
110
  - lib/generators/bot/install/templates/application_responder.rb
111
+ - lib/generators/bot/install/templates/default_responder.rb
111
112
  - lib/generators/bot/install/templates/initializer.rb
112
113
  - lib/generators/bot/responder/responder_generator.rb
113
114
  - lib/generators/rspec/install_generator.rb