Skip to content

Commit 8644c2b

Browse files
committed
Add Traditional Chinese version of README
1 parent 7863105 commit 8644c2b

File tree

2 files changed

+188
-9
lines changed

2 files changed

+188
-9
lines changed

README-zh.md

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
# line-bot
2+
3+
[![hacs_badge](https://img.shields.io/badge/HACS-Custom-orange.svg?style=for-the-badge)](https://github.com/custom-components/hacs)
4+
5+
[English](README.md) | [繁體中文](README-zh.md)
6+
7+
Home Assistant 的 LINE bot 整合套件
8+
9+
_本專案修改自 [yun-s-oh/Homeassistant](https://github.com/yun-s-oh/Homeassistant)_
10+
11+
## ⚠ 注意
12+
13+
本套件僅適用於 LINE bot
14+
15+
若要整合 LIEN Notify 請改用上列 yun-s-oh 的套件
16+
17+
## 安裝
18+
19+
### 透過 HACS
20+
21+
建議使用 [HACS](https://hacs.xyz/) 安裝 `line-bot`,步驟如下:
22+
23+
HACS > Integrations > 右上三點選單鈕 > Custom repositories > URL: `osk2/line-bot` > Category: Integration
24+
25+
### 手動安裝
26+
27+
`custom_components/line_bot` 複製至 `custom_components`
28+
29+
## 設定方式
30+
31+
將下列設定複製至 `configuration.yaml`
32+
33+
```yaml
34+
notify:
35+
- name: line_bot
36+
platform: line_bot
37+
client_id: 'CLIENT_ID'
38+
access_token: 'CHANNEL_ACCESS_TOKEN'
39+
```
40+
41+
請閱讀 [額外資訊](#額外資訊) 一節以了解 `client_id` 及 `access_token` 的取得方式
42+
43+
### 透過介面建立設定檔
44+
45+
設定檔為 `client_id` 及 `access_token` 的組合
46+
47+
除了可透過上一章節的步驟建立通知服務外,也可透過介面來建立以簡化流程
48+
49+
1. 設定 > 整合 > 新增整合 > LINE Bot
50+
2. 輸入設定檔名稱(應不同於 configuration.yaml 中的名稱)、client_id 及 access_token
51+
52+
請閱讀 [更改設定檔](#更改設定檔) 一節以了解如何使用設定檔
53+
54+
## 使用方式
55+
56+
將 LINE 訊息物件傳入服務
57+
58+
```yaml
59+
service: notify.line_bot
60+
data:
61+
message: >-
62+
{"messages":[{"type": "text", "text": "Hello, world"}]
63+
```
64+
65+
若你懶得打字,沒關係,純文字也是支援的
66+
67+
```yaml
68+
service: notify.line_bot
69+
data:
70+
message: 'Hello, world'
71+
```
72+
73+
請閱讀 [額外資訊](#額外資訊) 一節以了解 LINE 訊息物件格式
74+
75+
### 更改設定檔
76+
77+
```yaml
78+
service: notify.line_bot
79+
data:
80+
message: >-
81+
{"messages":[{"type": "text", "text": "Hello, world"}]
82+
data:
83+
profile: cool_line_bot # 設定檔名稱
84+
```
85+
86+
## 額外資訊
87+
88+
### client_id
89+
90+
> `client_id` 是 LINE 的用戶 ID 或群組 ID
91+
92+
取得 `client_id` 的步驟不太容易,以下是我的方法
93+
94+
1. 建立 Firebase [Cloud Functions](https://console.firebase.google.com/)
95+
2. 將下列程式部署至 Cloud Functions
96+
97+
```js
98+
const functions = require('firebase-functions')
99+
100+
exports.helloWorld = functions.https.onRequest((request, response) => {
101+
const events = request.body.events
102+
const source = events.length > 0 ? events[0].source : null
103+
104+
if (source) {
105+
functions.logger.info(source.groupId || source.userId)
106+
}
107+
response.send('Hello from Firebase!')
108+
})
109+
```
110+
111+
3. 在 LINE Messaging API 設定中啟用 webhook
112+
![image](https://github.com/osk2/line-bot/blob/master/assets/messaging-api-webhook.png)
113+
4. 將 bot 帳號加入好友或邀請進群組,並跟 bot 對話
114+
5. 這時就可以在 Cloud Funtions 的 log 看見 `client_id`
115+
![image](https://github.com/osk2/line-bot/blob/master//assets/cloud-functions-log.png)
116+
6. 記得再次停用 webhook,否則 log 可能會被塞爆
117+
118+
### access_token
119+
120+
> `access_token` 可於 LINE Developer 網站取得
121+
122+
前往 `https://developers.line.biz/console/channel/<YOUR CHANNEL ID>/messaging-api`
123+
124+
可於 `Channel access token` 新增並取得 token
125+
![image](https://github.com/osk2/line-bot/blob/master//assets/line-access-token.png)
126+
127+
### LINE 訊息物件 (LINE Message Object)
128+
129+
此套件支援 [Messaging API reference](https://developers.line.biz/en/reference/messaging-api/#message-objects) 中列出的所有訊息類別
130+
131+
文字訊息範例:
132+
133+
```json
134+
{
135+
"messages": [
136+
{
137+
"type": "text",
138+
"text": "Hello, world"
139+
}
140+
]
141+
}
142+
```
143+
144+
Flex 訊息範例:
145+
146+
```json
147+
{
148+
"type": "flex",
149+
"altText": "this is a flex message",
150+
"contents": {
151+
"type": "bubble",
152+
"body": {
153+
"type": "box",
154+
"layout": "vertical",
155+
"contents": [
156+
{
157+
"type": "text",
158+
"text": "hello"
159+
},
160+
{
161+
"type": "text",
162+
"text": "world"
163+
}
164+
]
165+
}
166+
}
167+
}
168+
```
169+
170+
## 延伸閱讀
171+
172+
1. [Flex Message Simulator](https://developers.line.biz/flex-simulator/) 協助你快速打造 flex 訊息物件
173+
2. [#教學 打造你的智慧家庭吧! 把 LINE 提醒變得更有型](https://www.dcard.tw/f/smart_home/p/235787775) (特別感謝 [Jason Lee](https://www.dcard.tw/@jas0n.1ee.com) 👏)
174+
175+
## 版權
176+
177+
此專案依 MIT 授權釋出,請閱讀 [LICENSE](LICENSE) 以獲得詳細資訊

README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# line-bot [![hacs_badge](https://img.shields.io/badge/HACS-Custom-orange.svg?style=for-the-badge)](https://github.com/custom-components/hacs)
1+
# line-bot
2+
3+
[![hacs_badge](https://img.shields.io/badge/HACS-Custom-orange.svg?style=for-the-badge)](https://github.com/custom-components/hacs)
4+
5+
[繁體中文](README-zh.md) | [English](README.md)
26

37
LINE bot plugin for Home Assistant
48

@@ -10,8 +14,6 @@ This component is for LINE bot
1014

1115
If you plan to integrate LINE Notify, use yun-s-oh's component instead
1216

13-
## Usage
14-
1517
## Installation
1618

1719
### via HACS
@@ -24,7 +26,7 @@ HACS > Integrations > 3 dots menu (top right) > Custom repositories > URL: `osk2
2426

2527
Copy `custom_components/line_bot` to `custom_components`
2628

27-
### Configuration
29+
## Configuration
2830

2931
Add following entry in `configuration.yaml`
3032

@@ -38,9 +40,9 @@ notify:
3840
3941
See [Additional Information](#additional-information) for detail of retrieving `client_id` and `access_token`
4042

41-
#### Add more profile via UI
43+
### Add more profile via UI
4244

43-
A profile means a set of client_id and access_token.
45+
A profile means a set of `client_id` and `access_token`.
4446

4547
You can add more notify service by repeating above steps. You can also create profile via UI to simplify the process
4648

@@ -49,7 +51,7 @@ You can add more notify service by repeating above steps. You can also create pr
4951

5052
See [Change Profile](#change-profile) to learn how to use profile
5153

52-
### Usage
54+
## Usage
5355

5456
Passing LINE message object into service
5557

@@ -68,7 +70,7 @@ data:
6870
message: 'Hello, world'
6971
```
7072

71-
#### Change profile
73+
### Change profile
7274

7375
```yaml
7476
service: notify.line_bot
@@ -165,7 +167,7 @@ Flex message example
165167
}
166168
```
167169

168-
#### See Also
170+
## See Also
169171

170172
1. [Flex Message Simulator](https://developers.line.biz/flex-simulator/) to help you build flex message object
171173
2. [#教學 打造你的智慧家庭吧! 把 LINE 提醒變得更有型](https://www.dcard.tw/f/smart_home/p/235787775) (Thanks [Jason Lee](https://www.dcard.tw/@jas0n.1ee.com) 👏)

0 commit comments

Comments
 (0)