kamigo 0.26.0 → 0.28.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +24 -0
- data/lib/generators/rails/kamigo/templates/edit.liff.erb +1 -1
- data/lib/generators/rails/kamigo/templates/new.liff.erb +1 -1
- data/lib/generators/templates/kamigo.rb +2 -14
- data/lib/kamigo/event_processors/rails_router_processor.rb +6 -2
- data/lib/kamigo/version.rb +1 -1
- data/lib/kamigo.rb +4 -4
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 183742309b2ea81e02c1fc03e035de18a95d12816415faa08191432f0ce4775f
|
4
|
+
data.tar.gz: c8523ce01ed074009a82d44f3e86c9c188a46fb7240dae833eedc2e8a63f9a26
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c23e1abd2a0432ef3a723abcc041402ddd46f39049872f34f024bf2bcc6f8a8d9888541b05d8d3cc8d3728b288d54407bc6bff8e819bf9ec296258eccb6caaa
|
7
|
+
data.tar.gz: 7da6014ce051f0047983098b2191aa5938962a0628751e700c2003223afd449325c6ce73e70c546fbd32f6a3fcba2f94469d34859f6b322492635eb5abc55e98
|
data/README.md
CHANGED
@@ -83,6 +83,25 @@ window.addEventListener("liff_submit", function(event){
|
|
83
83
|
});
|
84
84
|
```
|
85
85
|
|
86
|
+
若使用 Importmap(Rails 7),請使用 kamigo 0.27.0 以上的版本,並且在 `app/javascript/application.js` 當中
|
87
|
+
|
88
|
+
加入以下程式碼:
|
89
|
+
|
90
|
+
```
|
91
|
+
/* kamiliff default behavior */
|
92
|
+
window.addEventListener("liff_ready", function(event){
|
93
|
+
register_kamiliff_submit();
|
94
|
+
});
|
95
|
+
|
96
|
+
window.addEventListener("liff_submit", function(event){
|
97
|
+
var json = JSON.stringify(event.detail.data);
|
98
|
+
var url = event.detail.url;
|
99
|
+
var method = event.detail.method;
|
100
|
+
var request_text = method + " " + url + "\n" + json;
|
101
|
+
liff_send_text_message(request_text);
|
102
|
+
});
|
103
|
+
```
|
104
|
+
|
86
105
|
這會影響 LINE Bot 在 LIFF 送出表單時的行為。
|
87
106
|
|
88
107
|
# 設定聊天機器人 Webhook URL
|
@@ -98,6 +117,9 @@ https://你的網域/line
|
|
98
117
|
請在專案根目錄下新增一個 `.env` 檔並且填入以下內容:
|
99
118
|
|
100
119
|
```
|
120
|
+
LINE_LOGIN_CHANNEL_ID=這裡填入你的 LINE_LOGIN_CHANNEL_ID
|
121
|
+
LINE_LOGIN_CHANNEL_SECRET=這裡填入你的 LINE_LOGIN_CHANNEL_SECRET
|
122
|
+
|
101
123
|
LINE_CHANNEL_SECRET=這裡填入你的 LINE_CHANNEL_SECRET
|
102
124
|
LINE_CHANNEL_TOKEN=這裡填入你的 LINE_CHANNEL_ACCESS_TOKEN
|
103
125
|
LIFF_COMPACT=這裡填入你的 COMPACT_LIFF_URL
|
@@ -105,6 +127,8 @@ LIFF_TALL=這裡填入你的 TALL_LIFF_URL
|
|
105
127
|
LIFF_FULL=這裡填入你的 FULL_LIFF_URL
|
106
128
|
```
|
107
129
|
|
130
|
+
- `LINE_LOGIN_CHANNEL_ID` 可以在 LINE LOGIN 後台的 Basic settings 分頁中找到。
|
131
|
+
- `LINE_LOGIN_CHANNEL_SECRET` 可以在 LINE LOGIN 後台的 Basic settings 分頁中找到。
|
108
132
|
- `LINE_CHANNEL_SECRET` 可以在 Messaging API 後台的 Basic settings 分頁中找到。
|
109
133
|
- `LINE_CHANNEL_ACCESS_TOKEN` 可以在 Messaging API 後台的 Messaging API 分頁中找到。
|
110
134
|
- `COMPACT_LIFF_URL`、`TALL_LIFF_URL` 和 `FULL_LIFF_URL` 需要到 LINE 後台的 LIFF 分頁新增後,即可獲得一組 LIFF URL。
|
@@ -1,2 +1,2 @@
|
|
1
1
|
<%% content_for :title, "Edit <%= singular_table_name.titleize %>" %>
|
2
|
-
<%%= render "<%= route_url %>/form
|
2
|
+
<%%= render partial: "<%= route_url %>/form", formats: [:html], locals: {<%= singular_table_name %>: @<%= singular_table_name %>} %>
|
@@ -1,2 +1,2 @@
|
|
1
1
|
<%% content_for :title, "New <%= singular_table_name.titleize %>" %>
|
2
|
-
<%%= render "<%= route_url %>/form
|
2
|
+
<%%= render partial: "<%= route_url %>/form", formats: [:html], locals: {<%= singular_table_name %>: @<%= singular_table_name %>} %>
|
@@ -12,18 +12,6 @@ Kamigo.setup do |config|
|
|
12
12
|
# When line_default_message is nil, then Kamigo don't reply message.
|
13
13
|
# config.line_default_message = nil
|
14
14
|
|
15
|
-
#
|
16
|
-
# config.
|
17
|
-
# config.line_login_channel_secret = ENV["LINE_LOGIN_CHANNEL_SECRET"]
|
18
|
-
# config.line_login_redirect_uri = ENV["LINE_LOGIN_REDIRECT_URI"]
|
19
|
-
|
20
|
-
# Integrate with liff
|
21
|
-
# config.liff_url_compact = ENV["LIFF_COMPACT"]
|
22
|
-
# config.liff_url_tall = ENV["LIFF_TALL"]
|
23
|
-
# config.liff_url_full = ENV["LIFF_FULL"]
|
24
|
-
|
25
|
-
# Integrate with line messaging api
|
26
|
-
# config.line_message_api_channel_id = ENV["LINE_CHANNEL_ID"]
|
27
|
-
# config.line_message_api_channel_secret = ENV["LINE_CHANNEL_SECRET"]
|
28
|
-
# config.line_message_api_channel_token = ENV["LINE_CHANNEL_TOKEN"]
|
15
|
+
# When Kamigo receive a request, then Kamigo will process the request with the following processors.
|
16
|
+
# config.line_event_processors = [Kamigo::EventProcessors::RailsRouterProcessor.new]
|
29
17
|
end
|
@@ -10,13 +10,15 @@ module Kamigo
|
|
10
10
|
def process(event)
|
11
11
|
http_method, path, request_params = kamiform_context(event)
|
12
12
|
http_method, path, request_params = language_understanding(event.message) if http_method.nil?
|
13
|
-
|
13
|
+
return nil if http_method.nil? || path.nil?
|
14
|
+
|
15
|
+
encoded_path = URI::Parser.new.escape(path)
|
14
16
|
request_params = event.platform_params.merge(request_params)
|
15
17
|
output = reserve_route(encoded_path, http_method: http_method, request_params: request_params, format: :line)
|
16
18
|
return output if output.present?
|
17
19
|
|
18
20
|
return nil if Kamigo.default_path.nil?
|
19
|
-
reserve_route(URI.
|
21
|
+
reserve_route(URI::Parser.new.escape(Kamigo.default_path), http_method: Kamigo.default_http_method, request_params: request_params, format: :line)
|
20
22
|
end
|
21
23
|
|
22
24
|
private
|
@@ -61,6 +63,8 @@ module Kamigo
|
|
61
63
|
request_params[:authenticity_token] = @form_authenticity_token
|
62
64
|
http_method = request_params["_method"]&.upcase || http_method || "GET"
|
63
65
|
[http_method, path, request_params]
|
66
|
+
rescue
|
67
|
+
[nil, nil, nil]
|
64
68
|
end
|
65
69
|
|
66
70
|
def parse_json(string)
|
data/lib/kamigo/version.rb
CHANGED
data/lib/kamigo.rb
CHANGED
@@ -29,17 +29,17 @@ module Kamigo
|
|
29
29
|
# env
|
30
30
|
mattr_writer :line_messaging_api_channel_id
|
31
31
|
mattr_writer :line_messaging_api_channel_secret
|
32
|
-
mattr_writer :
|
32
|
+
mattr_writer :line_messaging_api_channel_token
|
33
33
|
|
34
|
-
def self.
|
34
|
+
def self.line_messaging_api_channel_id
|
35
35
|
@@line_message_api_channel_id = ENV["LINE_CHANNEL_ID"]
|
36
36
|
end
|
37
37
|
|
38
|
-
def self.
|
38
|
+
def self.line_messaging_api_channel_secret
|
39
39
|
@@line_message_api_channel_secret = ENV["LINE_CHANNEL_SECRET"]
|
40
40
|
end
|
41
41
|
|
42
|
-
def self.
|
42
|
+
def self.line_messaging_api_channel_token
|
43
43
|
@@line_message_api_channel_token = ENV["LINE_CHANNEL_TOKEN"]
|
44
44
|
end
|
45
45
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kamigo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.28.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- etrex
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -30,20 +30,20 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0.
|
33
|
+
version: '0.36'
|
34
34
|
- - ">="
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version: 0.
|
36
|
+
version: 0.36.0
|
37
37
|
type: :runtime
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
41
|
- - "~>"
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: '0.
|
43
|
+
version: '0.36'
|
44
44
|
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 0.
|
46
|
+
version: 0.36.0
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: kamiflex
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|