node-red-contrib-line-messaging-api 0.3.1 → 0.3.3
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.
- package/README.md +8 -9
- package/nodes/limit/limit.html +1 -1
- package/nodes/loading/loading.html +72 -0
- package/nodes/loading/loading.js +62 -0
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -4,14 +4,6 @@ LINE Messagin APIのNode-REDのノードです。
|
|
|
4
4
|
|
|
5
5
|
LINE Messagin APIを利用できるNode-REDのノードです。
|
|
6
6
|
|
|
7
|
-
以下のAPIを利用できます。
|
|
8
|
-
|
|
9
|
-
- LINE Messaging API
|
|
10
|
-
- Webhook & Reply Message
|
|
11
|
-
- Push Message
|
|
12
|
-
- BloadCast Message
|
|
13
|
-
- LINE Notify
|
|
14
|
-
|
|
15
7
|
## インストール
|
|
16
8
|
|
|
17
9
|
```
|
|
@@ -22,7 +14,7 @@ or
|
|
|
22
14
|
|
|
23
15
|
AdminタブからInstall
|
|
24
16
|
|
|
25
|
-
##
|
|
17
|
+
## 利用できるAPIと利用イメージ
|
|
26
18
|
|
|
27
19
|
### Webhook & Reply Message
|
|
28
20
|
|
|
@@ -77,6 +69,13 @@ return msg;
|
|
|
77
69
|
|
|
78
70
|
> 
|
|
79
71
|
|
|
72
|
+
### Loading
|
|
73
|
+
|
|
74
|
+
ローディングを表示させます。
|
|
75
|
+
|
|
76
|
+
> 
|
|
77
|
+
> https://developers.line.biz/ja/reference/messaging-api/#display-a-loading-indicator
|
|
78
|
+
|
|
80
79
|
### LINE Notify (2024/12/22追記: API自体が終了するため廃止予定です。)
|
|
81
80
|
|
|
82
81
|
> 
|
package/nodes/limit/limit.html
CHANGED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
RED.nodes.registerType('Loading',{
|
|
3
|
+
category: 'LINE',
|
|
4
|
+
color: '#01B301',
|
|
5
|
+
defaults: {
|
|
6
|
+
name: {value:""},
|
|
7
|
+
loadingSeconds: {value: 20}
|
|
8
|
+
},
|
|
9
|
+
credentials: {
|
|
10
|
+
channelAccessToken: { type: "password", required: true },
|
|
11
|
+
targetId:{type:"password", required:true}
|
|
12
|
+
},
|
|
13
|
+
inputs:1,
|
|
14
|
+
outputs:1,
|
|
15
|
+
icon: "timer.png",
|
|
16
|
+
align: "right",
|
|
17
|
+
label: function() {
|
|
18
|
+
return this.name||"Loading";
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<script type="text/x-red" data-template-name="Loading">
|
|
24
|
+
<div class="form-row">
|
|
25
|
+
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
|
|
26
|
+
<input type="text" id="node-input-name" placeholder="Name">
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
<div class="form-row">
|
|
30
|
+
<label for="node-input-channelAccessToken">
|
|
31
|
+
<i class="icon-tag"></i>
|
|
32
|
+
Channel Access Token
|
|
33
|
+
</label>
|
|
34
|
+
<input type="password" id="node-input-channelAccessToken" placeholder="LINE Channel AccessToken">
|
|
35
|
+
</div>
|
|
36
|
+
|
|
37
|
+
<div class="form-row">
|
|
38
|
+
<label for="node-input-targetId"><i class="icon-tag"></i> User Id</label>
|
|
39
|
+
<input type="text" id="node-input-targetId" placeholder="User Id">
|
|
40
|
+
</div>
|
|
41
|
+
|
|
42
|
+
<div class="form-row">
|
|
43
|
+
<label for="node-input-loadingSeconds">
|
|
44
|
+
<i class="icon-timer"></i> Loading Seconds
|
|
45
|
+
</label>
|
|
46
|
+
<select id="node-input-loadingSeconds">
|
|
47
|
+
<option value="5">5</option>
|
|
48
|
+
<option value="10">10</option>
|
|
49
|
+
<option value="15">15</option>
|
|
50
|
+
<option value="20" selected>20</option>
|
|
51
|
+
<option value="25">25</option>
|
|
52
|
+
<option value="30">30</option>
|
|
53
|
+
<option value="35">35</option>
|
|
54
|
+
<option value="40">40</option>
|
|
55
|
+
<option value="45">45</option>
|
|
56
|
+
<option value="50">50</option>
|
|
57
|
+
<option value="55">55</option>
|
|
58
|
+
<option value="60">60</option>
|
|
59
|
+
</select>
|
|
60
|
+
</div>
|
|
61
|
+
|
|
62
|
+
<p>
|
|
63
|
+
このノードは、指定した秒数だけローディングアニメーションを表示させます。<br>
|
|
64
|
+
現状(2024年12月に記載)、グループには対応してなく<br>
|
|
65
|
+
UからはじまるユーザーIDのみ(個別チャット)です。
|
|
66
|
+
詳細は<a href="https://developers.line.biz/ja/reference/messaging-api/#display-a-loading-indicator" target="_blank">公式ドキュメント</a>を参照下さい。
|
|
67
|
+
</p>
|
|
68
|
+
</script>
|
|
69
|
+
|
|
70
|
+
<script type="text/x-red" data-help-name="Loading">
|
|
71
|
+
<p>当月の送信メッセージのリミットを教えてくれます。</p>
|
|
72
|
+
</script>
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
module.exports = (RED) => {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const line = require('@line/bot-sdk');
|
|
5
|
+
|
|
6
|
+
const main = function(config){
|
|
7
|
+
const node = this;
|
|
8
|
+
RED.nodes.createNode(node, config);
|
|
9
|
+
|
|
10
|
+
let lineconfig;
|
|
11
|
+
try {
|
|
12
|
+
lineconfig = require('../../env');
|
|
13
|
+
} catch (error) {
|
|
14
|
+
lineconfig = {
|
|
15
|
+
// channelSecret: node.credentials.channelSecret,
|
|
16
|
+
channelAccessToken: node.credentials.channelAccessToken
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
if(lineconfig.channelAccessToken === undefined || lineconfig.channelAccessToken === '') {
|
|
20
|
+
console.error('token not found');
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const client = new line.messagingApi.MessagingApiClient(lineconfig);
|
|
24
|
+
// const client = new line.Client(lineconfig);
|
|
25
|
+
|
|
26
|
+
node.on('input', async (msg, send, done) => {
|
|
27
|
+
|
|
28
|
+
//chat
|
|
29
|
+
const chatId = msg.targetId || node.credentials.targetId;
|
|
30
|
+
const loadingSeconds = msg.loadingSeconds || config.loadingSeconds;
|
|
31
|
+
// console.log(chatId,loadingSeconds);
|
|
32
|
+
|
|
33
|
+
try {
|
|
34
|
+
const res = await client.showLoadingAnimation({
|
|
35
|
+
chatId: chatId, //現状user idのみ
|
|
36
|
+
loadingSeconds: loadingSeconds,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// レスポンスが {}(空のJSONオブジェクト)なら成功らしい
|
|
40
|
+
if (res && Object.keys(res).length === 0) {
|
|
41
|
+
node.log('ローディングが成功しました: {} が返却されました');
|
|
42
|
+
} else {
|
|
43
|
+
node.warn('ローディング処理失敗:', res);
|
|
44
|
+
}
|
|
45
|
+
send(msg);
|
|
46
|
+
} catch (error) {
|
|
47
|
+
console.error(error.body);
|
|
48
|
+
node.error(error.body, msg.payload);
|
|
49
|
+
send(msg);
|
|
50
|
+
done(error);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
RED.nodes.registerType("Loading", main, {
|
|
57
|
+
credentials: {
|
|
58
|
+
channelAccessToken: {type:"password"},
|
|
59
|
+
targetId: {type:"password"},
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-red-contrib-line-messaging-api",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "Node-REDでLINE Botが作れます。",
|
|
5
5
|
"main": "line.js",
|
|
6
6
|
"repository": {
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"PushMessage_New": "./nodes/_new/push/push.js",
|
|
19
19
|
"BloadcastMessage": "./nodes/bloadcast/bloadcast.js",
|
|
20
20
|
"Limit": "./nodes/limit/limit.js",
|
|
21
|
+
"Loading": "./nodes/loading/loading.js",
|
|
21
22
|
"ReplyMessage": "./nodes/reply/reply.js",
|
|
22
23
|
"PushMessage": "./nodes/push/push.js",
|
|
23
24
|
"Notify_New": "./nodes/_new/notify/notify.js",
|