kamigo 0.24.0 → 0.27.0
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/README.md +26 -2
- data/app/controllers/line_controller.rb +1 -1
- 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 +3 -0
- data/lib/kamigo/event_processors/rails_router_processor.rb +2 -2
- data/lib/kamigo/version.rb +1 -1
- data/lib/kamigo.rb +26 -0
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a113303a0a5d45d56f938861944573df97e98ad6fd2ef1dc53a8a48d188aeade
|
4
|
+
data.tar.gz: 4bbe10ff5c3f8b91d82999cc83f52f415d6fca35c061c300b01b73d4f5c0b87a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fae826a9496cc069bd60e2ce4120b1378e951655870b7b7042251028fe0571c0b238cf0502a5c4e24a575397e20ec311efbc2cac87bde299f2f00cfa68046bd9
|
7
|
+
data.tar.gz: 9e00a82ffe3d2365d26edb6810cf26b45f8381ba99aa31c5c4e30af630ee7b94f255fc5fb3700e4eb4c7347f4b83049b8f328c6763cb08934ea256db04813cb8
|
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。
|
@@ -137,11 +161,11 @@ Kamigo 預設使用基本的語意理解模型,會將使用者輸入視為在
|
|
137
161
|
|
138
162
|
# 使用 kamigo 製作的聊天機器人
|
139
163
|
- [kamigo demo](https://github.com/etrex/kamigo_demo)
|
140
|
-
<p><img width="100" height="100" src="/
|
164
|
+
<p><img width="100" height="100" src="/docs/images/kamigo_demo_qrcode.png"></p>
|
141
165
|
- [健身紀錄機器人: Muscle-Man](https://github.com/louis70109/muscle_man)
|
142
166
|
<p><img width="100" height="100" src="https://camo.githubusercontent.com/b8c51b15b20b159d356245277d079c04482acc01/68747470733a2f2f692e696d6775722e636f6d2f7534547675676e2e706e67"></p>
|
143
167
|
- 守護寵物機器人
|
144
|
-
<p><img width="100" height="100" src="/
|
168
|
+
<p><img width="100" height="100" src="/docs/images/pet_loved_qrcode.png"></p>
|
145
169
|
|
146
170
|
# 計畫
|
147
171
|
- 提供多種語意理解模型串接
|
@@ -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 %>} %>
|
@@ -11,4 +11,7 @@ Kamigo.setup do |config|
|
|
11
11
|
|
12
12
|
# When line_default_message is nil, then Kamigo don't reply message.
|
13
13
|
# config.line_default_message = nil
|
14
|
+
|
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]
|
14
17
|
end
|
@@ -10,13 +10,13 @@ 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
|
-
encoded_path = URI.
|
13
|
+
encoded_path = URI::Parser.new.escape(path)
|
14
14
|
request_params = event.platform_params.merge(request_params)
|
15
15
|
output = reserve_route(encoded_path, http_method: http_method, request_params: request_params, format: :line)
|
16
16
|
return output if output.present?
|
17
17
|
|
18
18
|
return nil if Kamigo.default_path.nil?
|
19
|
-
reserve_route(URI.
|
19
|
+
reserve_route(URI::Parser.new.escape(Kamigo.default_path), http_method: Kamigo.default_http_method, request_params: request_params, format: :line)
|
20
20
|
end
|
21
21
|
|
22
22
|
private
|
data/lib/kamigo/version.rb
CHANGED
data/lib/kamigo.rb
CHANGED
@@ -26,6 +26,32 @@ module Kamigo
|
|
26
26
|
mattr_accessor :line_event_processors
|
27
27
|
@@line_event_processors = [EventProcessors::RailsRouterProcessor.new]
|
28
28
|
|
29
|
+
# env
|
30
|
+
mattr_writer :line_messaging_api_channel_id
|
31
|
+
mattr_writer :line_messaging_api_channel_secret
|
32
|
+
mattr_writer :line_messaging_api_channel_token
|
33
|
+
|
34
|
+
def self.line_messaging_api_channel_id
|
35
|
+
@@line_message_api_channel_id = ENV["LINE_CHANNEL_ID"]
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.line_messaging_api_channel_secret
|
39
|
+
@@line_message_api_channel_secret = ENV["LINE_CHANNEL_SECRET"]
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.line_messaging_api_channel_token
|
43
|
+
@@line_message_api_channel_token = ENV["LINE_CHANNEL_TOKEN"]
|
44
|
+
end
|
45
|
+
|
46
|
+
class << self
|
47
|
+
delegate :line_login_channel_id, :line_login_channel_id=, to: :Kamiliff
|
48
|
+
delegate :line_login_channel_secret, :line_login_channel_secret=, to: :Kamiliff
|
49
|
+
delegate :line_login_redirect_uri, :line_login_redirect_uri=, to: :Kamiliff
|
50
|
+
delegate :liff_url_compact, :liff_url_compact=, to: :Kamiliff
|
51
|
+
delegate :liff_url_tall, :liff_url_tall=, to: :Kamiliff
|
52
|
+
delegate :liff_url_full, :liff_url_full=, to: :Kamiliff
|
53
|
+
end
|
54
|
+
|
29
55
|
def self.setup
|
30
56
|
yield self
|
31
57
|
end
|
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.27.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: 2022-06-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -30,40 +30,40 @@ 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
|
50
50
|
requirements:
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '0.
|
53
|
+
version: '0.17'
|
54
54
|
- - ">="
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version: 0.
|
56
|
+
version: 0.17.0
|
57
57
|
type: :runtime
|
58
58
|
prerelease: false
|
59
59
|
version_requirements: !ruby/object:Gem::Requirement
|
60
60
|
requirements:
|
61
61
|
- - "~>"
|
62
62
|
- !ruby/object:Gem::Version
|
63
|
-
version: '0.
|
63
|
+
version: '0.17'
|
64
64
|
- - ">="
|
65
65
|
- !ruby/object:Gem::Version
|
66
|
-
version: 0.
|
66
|
+
version: 0.17.0
|
67
67
|
- !ruby/object:Gem::Dependency
|
68
68
|
name: line-bot-api
|
69
69
|
requirement: !ruby/object:Gem::Requirement
|
@@ -147,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
147
147
|
- !ruby/object:Gem::Version
|
148
148
|
version: '0'
|
149
149
|
requirements: []
|
150
|
-
rubygems_version: 3.1.
|
150
|
+
rubygems_version: 3.1.6
|
151
151
|
signing_key:
|
152
152
|
specification_version: 4
|
153
153
|
summary: a chatbot framework based on rails
|