kamigo 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/line_controller.rb +10 -0
- data/lib/generators/rails/templates/controller.rb +12 -0
- data/lib/kamigo/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5aeebc445618f0e6876fe5a715c2305f846b7b4541cd895ec656bb521b43c62
|
4
|
+
data.tar.gz: 1f2758b8d6aa75615e4258427d1c35a949a56eb081c1343e98b8db617d457adf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0bd93072641e23c196afaee3ee95f6fecdd68d5245c18a26f0af12cd723de3285d110826af8655e89c41f9687f3f46471b8d71ea1e664cbd40cfa4248c51629e
|
7
|
+
data.tar.gz: ad64be4605f69cb436adb0a494a5dc8dbc23bfbe2a5042783b0f6c81b0bfe290a4a7ad200825ecfe645343f857b74dca96aa91628ea9fecfea3113a07d8c07e7
|
@@ -17,6 +17,7 @@ class LineController < ApplicationController
|
|
17
17
|
reply_token = event['replyToken']
|
18
18
|
event
|
19
19
|
http_method, path, request_params = language_understanding(event.message['text'])
|
20
|
+
inject_event(event, to: request_params)
|
20
21
|
output = reserve_route(path, http_method: http_method, request_params: request_params, format: :line)
|
21
22
|
response = client.reply_message(reply_token, JSON.parse(output))
|
22
23
|
puts response.body
|
@@ -59,4 +60,13 @@ class LineController < ApplicationController
|
|
59
60
|
signature = request.env['HTTP_X_LINE_SIGNATURE']
|
60
61
|
client.validate_signature(body, signature)
|
61
62
|
end
|
63
|
+
|
64
|
+
def inject_event(event, to: {})
|
65
|
+
event_hash = JSON.parse(event.to_json, symbolize_names: true)[:src]
|
66
|
+
to[:event] = event_hash
|
67
|
+
to[:platform_type] = 'line'
|
68
|
+
to[:source_type] = event_hash.dig(:source, :type)
|
69
|
+
to[:source_group_id] = event_hash.dig(:source, :groupId) || event_hash.dig(:source, :roomId) || event_hash.dig(:source, :userId)
|
70
|
+
to[:source_user_id] = event_hash.dig(:source, :userId) || event_hash.dig(:source, :groupId) || event_hash.dig(:source, :roomId)
|
71
|
+
end
|
62
72
|
end
|
@@ -4,6 +4,7 @@ require_dependency "<%= namespaced_file_path %>/application_controller"
|
|
4
4
|
<% end -%>
|
5
5
|
<% module_namespacing do -%>
|
6
6
|
class <%= controller_class_name %>Controller < ApplicationController
|
7
|
+
before_action :debug_info
|
7
8
|
before_action :set_<%= singular_table_name %>, only: [:show, :edit, :update, :destroy]
|
8
9
|
|
9
10
|
# GET <%= route_url %>
|
@@ -88,5 +89,16 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
88
89
|
params.require(<%= ":#{singular_table_name}" %>).permit(<%= permitted_params %>)
|
89
90
|
<%- end -%>
|
90
91
|
end
|
92
|
+
|
93
|
+
def debug_info
|
94
|
+
puts ""
|
95
|
+
puts "=== kamigo debug info start ==="
|
96
|
+
puts "platform_type: #{params[:platform_type]}"
|
97
|
+
puts "source_type: #{params[:source_type]}"
|
98
|
+
puts "source_group_id: #{params[:source_group_id]}"
|
99
|
+
puts "source_user_id: #{params[:source_user_id]}"
|
100
|
+
puts "=== kamigo debug info end ==="
|
101
|
+
puts ""
|
102
|
+
end
|
91
103
|
end
|
92
104
|
<% end -%>
|
data/lib/kamigo/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kamigo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- etrex
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.11.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: 0.11.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: kamiflex
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|