node-red-contrib-line-messaging-api 0.4.4 → 0.4.5
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/nodes/_new/push/push.html +5 -2
- package/nodes/_new/reply/reply.html +8 -6
- package/nodes/bloadcast/bloadcast.html +5 -13
- package/nodes/bloadcast/bloadcast.js +9 -9
- package/nodes/bloadcast/locales/ja/bloadcast.json +2 -3
- package/nodes/getBotInfo/getBotInfo.html +5 -4
- package/nodes/getBotInfo/getBotInfo.js +1 -1
- package/nodes/getProfile/getProfile.html +3 -2
- package/nodes/limit/limit.html +7 -8
- package/nodes/limit/limit.js +18 -7
- package/nodes/limit/locales/ja/limit.json +2 -2
- package/nodes/loading/loading.html +15 -8
- package/nodes/loading/loading.js +42 -7
- package/nodes/loading/locales/ja/loading.json +3 -2
- package/nodes/markAsRead/markAsRead.html +5 -2
- package/nodes/push/push.html +2 -1
- package/nodes/reply/reply.html +2 -1
- package/nodes/webhook/webhook.html +1 -0
- package/package.json +1 -1
- package/.claude/settings.local.json +0 -12
|
@@ -14,10 +14,13 @@
|
|
|
14
14
|
},
|
|
15
15
|
inputs: 1,
|
|
16
16
|
outputs: 1,
|
|
17
|
-
icon: "comment
|
|
17
|
+
icon: "font-awesome/fa-comment",
|
|
18
18
|
align: "right",
|
|
19
19
|
paletteLabel: 'Push',
|
|
20
|
-
label: ()
|
|
20
|
+
label: function () {
|
|
21
|
+
return this.name || 'Push Message';
|
|
22
|
+
},
|
|
23
|
+
paletteLabel: "Push"
|
|
21
24
|
});
|
|
22
25
|
</script>
|
|
23
26
|
|
|
@@ -13,12 +13,14 @@
|
|
|
13
13
|
},
|
|
14
14
|
inputs:1,
|
|
15
15
|
outputs:1,
|
|
16
|
-
|
|
16
|
+
outputLabels: ["sentMessages(object)"],
|
|
17
|
+
icon: "font-awesome/fa-reply",
|
|
17
18
|
align: "right",
|
|
18
19
|
paletteLabel: 'Reply',
|
|
19
20
|
label: function () {
|
|
20
|
-
return this.name || '
|
|
21
|
-
}
|
|
21
|
+
return this.name || 'Reply Message';
|
|
22
|
+
},
|
|
23
|
+
paletteLabel: "Reply"
|
|
22
24
|
});
|
|
23
25
|
</script>
|
|
24
26
|
|
|
@@ -37,17 +39,17 @@
|
|
|
37
39
|
</div>
|
|
38
40
|
|
|
39
41
|
<div class="form-row">
|
|
40
|
-
<label for="node-input-channelSecret"><i class="icon-tag"></i> <span data-i18n="lineConfig.label.channelSecret">Secret</span></label>
|
|
42
|
+
<label for="node-input-channelSecret"><i class="icon-tag"></i> <span data-i18n="lineConfig.label.channelSecret">( Secret )</span></label>
|
|
41
43
|
<input type="password" id="node-input-channelSecret" placeholder="ChannelSecret">
|
|
42
44
|
</div>
|
|
43
45
|
|
|
44
46
|
<div class="form-row">
|
|
45
|
-
<label for="node-input-channelAccessToken"><i class="icon-tag"></i> <span data-i18n="lineConfig.label.channelAccessToken">AccessToken</span></label>
|
|
47
|
+
<label for="node-input-channelAccessToken"><i class="icon-tag"></i> <span data-i18n="lineConfig.label.channelAccessToken">( AccessToken )</span></label>
|
|
46
48
|
<input type="password" id="node-input-channelAccessToken" placeholder="ChannelAccessToken">
|
|
47
49
|
</div>
|
|
48
50
|
|
|
49
51
|
<div class="form-row">
|
|
50
|
-
<label for="node-input-replyMessage"><i class="icon-tag"></i> <span data-i18n="reply.label.message">
|
|
52
|
+
<label for="node-input-replyMessage"><i class="icon-tag"></i> <span data-i18n="reply.label.message"> Reply Message</span></label>
|
|
51
53
|
<input type="text" id="node-input-replyMessage" placeholder="static text message here">
|
|
52
54
|
</div>
|
|
53
55
|
</script>
|
|
@@ -4,11 +4,7 @@
|
|
|
4
4
|
color: '#01B301',
|
|
5
5
|
defaults: {
|
|
6
6
|
name: {value:""},
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
credentials: {
|
|
10
|
-
channelSecret:{value:"", type: "password", required:true},
|
|
11
|
-
channelAccessToken:{value:"", type: "password", required:true}
|
|
7
|
+
lineConfig: {value: "", type:"lineConfig", required:true},
|
|
12
8
|
},
|
|
13
9
|
|
|
14
10
|
inputs: 1,
|
|
@@ -29,18 +25,14 @@
|
|
|
29
25
|
<input type="text" id="node-input-name" placeholder="Name">
|
|
30
26
|
</div>
|
|
31
27
|
|
|
28
|
+
<!-- LINE Config -->
|
|
32
29
|
<div class="form-row">
|
|
33
|
-
<label for="node-input-
|
|
34
|
-
<input type="
|
|
35
|
-
</div>
|
|
36
|
-
|
|
37
|
-
<div class="form-row">
|
|
38
|
-
<label for="node-input-channelAccessToken"><i class="icon-tag"></i> <span data-i18n="bloadcast.label.channelAccessToken">チャンネルアクセストークン</span></label>
|
|
39
|
-
<input type="password" id="node-input-channelAccessToken" placeholder="ChannelAccessToken">
|
|
30
|
+
<label for="node-input-lineConfig"><i class="icon-tag"></i> <span data-i18n="bloadcast.label.lineConfig">LINE Bot設定</span></label>
|
|
31
|
+
<input type="text" id="node-input-lineConfig">
|
|
40
32
|
</div>
|
|
41
33
|
|
|
42
34
|
</script>
|
|
43
35
|
|
|
44
36
|
<script type="text/x-red" data-help-name="BloadcastMessage">
|
|
45
37
|
<p>Broadcasts messages to all LINE Bot friends.</p>
|
|
46
|
-
</script>
|
|
38
|
+
</script>
|
|
@@ -7,11 +7,16 @@ module.exports = (RED) => {
|
|
|
7
7
|
const node = this;
|
|
8
8
|
RED.nodes.createNode(node, config);
|
|
9
9
|
|
|
10
|
-
let lineconfig;
|
|
10
|
+
let lineconfig = {};
|
|
11
11
|
try {
|
|
12
12
|
lineconfig = require('../../env');
|
|
13
13
|
} catch (error) {
|
|
14
|
-
|
|
14
|
+
node.lineConfig = RED.nodes.getNode(config.lineConfig); //共通のlineConfigを取得
|
|
15
|
+
|
|
16
|
+
lineconfig = {
|
|
17
|
+
channelSecret: node.lineConfig.credentials.LineChannelSecret,
|
|
18
|
+
channelAccessToken: node.lineConfig.credentials.LineChannelAccessToken
|
|
19
|
+
};
|
|
15
20
|
}
|
|
16
21
|
|
|
17
22
|
if(lineconfig.channelSecret === '' || lineconfig.channelAccessToken === '') {
|
|
@@ -43,10 +48,5 @@ module.exports = (RED) => {
|
|
|
43
48
|
});
|
|
44
49
|
}
|
|
45
50
|
|
|
46
|
-
RED.nodes.registerType("BloadcastMessage", main
|
|
47
|
-
|
|
48
|
-
channelSecret: {type:"password"},
|
|
49
|
-
channelAccessToken: {type:"password"},
|
|
50
|
-
},
|
|
51
|
-
});
|
|
52
|
-
}
|
|
51
|
+
RED.nodes.registerType("BloadcastMessage", main);
|
|
52
|
+
}
|
|
@@ -8,11 +8,12 @@
|
|
|
8
8
|
},
|
|
9
9
|
inputs: 1,
|
|
10
10
|
outputs: 1,
|
|
11
|
-
icon: "
|
|
11
|
+
icon: "font-awesome/fa-robot",
|
|
12
12
|
align: 'right',
|
|
13
13
|
label: function () {
|
|
14
|
-
return this.name || '
|
|
14
|
+
return this.name || 'Get Bot Info';
|
|
15
15
|
},
|
|
16
|
+
paletteLabel: 'Get BotInfo',
|
|
16
17
|
});
|
|
17
18
|
</script>
|
|
18
19
|
|
|
@@ -36,9 +37,9 @@
|
|
|
36
37
|
</div>
|
|
37
38
|
|
|
38
39
|
<!-- Bot情報取得ボタン -->
|
|
39
|
-
<div class="form-row">
|
|
40
|
+
<!-- <div class="form-row">
|
|
40
41
|
<button type="button" id="node-getbotinfo-fetch"><span data-i18n="getBotInfo.label.fetchBotInfo">Bot情報を取得</span></button>
|
|
41
|
-
</div>
|
|
42
|
+
</div> -->
|
|
42
43
|
|
|
43
44
|
</script>
|
|
44
45
|
|
|
@@ -8,11 +8,12 @@
|
|
|
8
8
|
},
|
|
9
9
|
inputs: 1,
|
|
10
10
|
outputs: 1,
|
|
11
|
-
icon: "
|
|
11
|
+
icon: "font-awesome/fa-user",
|
|
12
12
|
align: 'right',
|
|
13
13
|
label: function () {
|
|
14
|
-
return this.name || '
|
|
14
|
+
return this.name || 'Get Profile';
|
|
15
15
|
},
|
|
16
|
+
paletteLabel: 'Get Profile',
|
|
16
17
|
});
|
|
17
18
|
</script>
|
|
18
19
|
|
package/nodes/limit/limit.html
CHANGED
|
@@ -4,9 +4,7 @@
|
|
|
4
4
|
color: '#01B301',
|
|
5
5
|
defaults: {
|
|
6
6
|
name: {value:""},
|
|
7
|
-
|
|
8
|
-
credentials: {
|
|
9
|
-
AccessToken: { type: "password", required: true }
|
|
7
|
+
lineConfig: {value: "", type:"lineConfig", required:true},
|
|
10
8
|
},
|
|
11
9
|
inputs:1,
|
|
12
10
|
outputs:1,
|
|
@@ -25,15 +23,16 @@
|
|
|
25
23
|
<input type="text" id="node-input-name" placeholder="Name">
|
|
26
24
|
</div>
|
|
27
25
|
|
|
26
|
+
<!-- LINE Config -->
|
|
28
27
|
<div class="form-row">
|
|
29
|
-
<label for="node-input-
|
|
28
|
+
<label for="node-input-lineConfig">
|
|
30
29
|
<i class="icon-tag"></i>
|
|
31
|
-
<span data-i18n="limit.label.
|
|
32
|
-
</label>
|
|
33
|
-
<input type="
|
|
30
|
+
<span data-i18n="limit.label.lineConfig">LINE Bot設定</span>
|
|
31
|
+
</label>
|
|
32
|
+
<input type="text" id="node-input-lineConfig">
|
|
34
33
|
</div>
|
|
35
34
|
</script>
|
|
36
35
|
|
|
37
36
|
<script type="text/x-red" data-help-name="Limit">
|
|
38
37
|
<p>Returns the current month's message quota limits.</p>
|
|
39
|
-
</script>
|
|
38
|
+
</script>
|
package/nodes/limit/limit.js
CHANGED
|
@@ -4,7 +4,22 @@ module.exports = (RED) => {
|
|
|
4
4
|
const main = function(config){
|
|
5
5
|
const node = this;
|
|
6
6
|
RED.nodes.createNode(node, config);
|
|
7
|
-
|
|
7
|
+
let lineconfig = {};
|
|
8
|
+
try {
|
|
9
|
+
lineconfig = require('../../env');
|
|
10
|
+
} catch (error) {
|
|
11
|
+
node.lineConfig = RED.nodes.getNode(config.lineConfig); //共通のlineConfigを取得
|
|
12
|
+
|
|
13
|
+
lineconfig = {
|
|
14
|
+
channelSecret: node.lineConfig.credentials.LineChannelSecret,
|
|
15
|
+
channelAccessToken: node.lineConfig.credentials.LineChannelAccessToken
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
if(lineconfig.channelAccessToken === undefined || lineconfig.channelAccessToken === '') {
|
|
19
|
+
console.error('LINE token not found');
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const LINE_TOKEN = lineconfig.channelAccessToken;
|
|
8
23
|
|
|
9
24
|
node.on('input', async (msg, send, done) => {
|
|
10
25
|
const mes = msg.payload;
|
|
@@ -52,9 +67,5 @@ module.exports = (RED) => {
|
|
|
52
67
|
});
|
|
53
68
|
}
|
|
54
69
|
|
|
55
|
-
RED.nodes.registerType("Limit", main
|
|
56
|
-
|
|
57
|
-
AccessToken: {type:"password"}
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
}
|
|
70
|
+
RED.nodes.registerType("Limit", main);
|
|
71
|
+
}
|
|
@@ -4,13 +4,14 @@
|
|
|
4
4
|
color: '#01B301',
|
|
5
5
|
defaults: {
|
|
6
6
|
name: {value:""},
|
|
7
|
-
targetId: {value:"", required:true},
|
|
7
|
+
// targetId: {value:"", required:true},
|
|
8
8
|
lineConfig: {value: "", type:"lineConfig", required:true}, //共通のlineConfigを使う
|
|
9
|
-
loadingSeconds: {value: 20}
|
|
9
|
+
loadingSeconds: {value: 20},
|
|
10
|
+
waitForCompletion: {value: false}
|
|
10
11
|
},
|
|
11
12
|
inputs:1,
|
|
12
13
|
outputs:1,
|
|
13
|
-
icon: "
|
|
14
|
+
icon: "font-awesome/fa-spinner",
|
|
14
15
|
align: "right",
|
|
15
16
|
label: function() {
|
|
16
17
|
return this.name||"Loading";
|
|
@@ -33,10 +34,10 @@
|
|
|
33
34
|
</div>
|
|
34
35
|
|
|
35
36
|
<!-- chat ID / User ID -->
|
|
36
|
-
<div class="form-row">
|
|
37
|
+
<!-- <div class="form-row">
|
|
37
38
|
<label for="node-input-targetId"><i class="icon-tag"></i> <span data-i18n="loading.label.targetId">ユーザーID</span></label>
|
|
38
39
|
<input type="text" id="node-input-targetId" placeholder="User Id">
|
|
39
|
-
</div>
|
|
40
|
+
</div> -->
|
|
40
41
|
|
|
41
42
|
<div class="form-row">
|
|
42
43
|
<label for="node-input-loadingSeconds">
|
|
@@ -58,12 +59,18 @@
|
|
|
58
59
|
</select>
|
|
59
60
|
</div>
|
|
60
61
|
|
|
61
|
-
<
|
|
62
|
+
<div class="form-row">
|
|
63
|
+
<label> </label>
|
|
64
|
+
<input type="checkbox" id="node-input-waitForCompletion" style="width:auto; margin-right:6px;">
|
|
65
|
+
<span data-i18n="loading.label.waitForCompletion">完了まで待機する</span>
|
|
66
|
+
</div>
|
|
67
|
+
|
|
68
|
+
<!-- <p>
|
|
62
69
|
Displays a loading indicator for the specified duration. Currently supports individual chats only (user IDs starting with 'U').
|
|
63
70
|
See <a href="https://developers.line.biz/ja/reference/messaging-api/#display-a-loading-indicator" target="_blank">official documentation</a> for details.
|
|
64
|
-
</p>
|
|
71
|
+
</p> -->
|
|
65
72
|
</script>
|
|
66
73
|
|
|
67
74
|
<script type="text/html" data-help-name="Loading">
|
|
68
75
|
<p>Displays a loading indicator animation to LINE users.</p>
|
|
69
|
-
</script>
|
|
76
|
+
</script>
|
package/nodes/loading/loading.js
CHANGED
|
@@ -2,32 +2,64 @@ module.exports = (RED) => {
|
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
const line = require('@line/bot-sdk');
|
|
5
|
+
const { setTimeout: sleep } = require('node:timers/promises');
|
|
5
6
|
|
|
6
7
|
const main = function(config){
|
|
8
|
+
// const node = this;
|
|
9
|
+
// RED.nodes.createNode(node, config);
|
|
10
|
+
|
|
11
|
+
// let lineconfig;
|
|
12
|
+
// try {
|
|
13
|
+
// lineconfig = require('../../env');
|
|
14
|
+
// } catch (error) {
|
|
15
|
+
// lineconfig = {
|
|
16
|
+
// // channelSecret: node.credentials.channelSecret,
|
|
17
|
+
// channelAccessToken: node.credentials.channelAccessToken
|
|
18
|
+
// };
|
|
19
|
+
// }
|
|
20
|
+
// if(lineconfig.channelAccessToken === undefined || lineconfig.channelAccessToken === '') {
|
|
21
|
+
// console.error('token not found');
|
|
22
|
+
// return;
|
|
23
|
+
// }
|
|
24
|
+
// const client = new line.messagingApi.MessagingApiClient(lineconfig);
|
|
25
|
+
// // const client = new line.Client(lineconfig);
|
|
26
|
+
|
|
7
27
|
const node = this;
|
|
8
28
|
RED.nodes.createNode(node, config);
|
|
9
29
|
|
|
10
|
-
let lineconfig;
|
|
30
|
+
let lineconfig = {};
|
|
11
31
|
try {
|
|
12
32
|
lineconfig = require('../../env');
|
|
13
33
|
} catch (error) {
|
|
34
|
+
node.lineConfig = RED.nodes.getNode(config.lineConfig); //共通のlineConfigを取得
|
|
35
|
+
|
|
14
36
|
lineconfig = {
|
|
15
|
-
|
|
16
|
-
channelAccessToken: node.credentials.
|
|
37
|
+
channelSecret: node.lineConfig.credentials.LineChannelSecret,
|
|
38
|
+
channelAccessToken: node.lineConfig.credentials.LineChannelAccessToken
|
|
17
39
|
};
|
|
18
40
|
}
|
|
19
41
|
if(lineconfig.channelAccessToken === undefined || lineconfig.channelAccessToken === '') {
|
|
20
|
-
console.error('token not found');
|
|
42
|
+
console.error('LINE token not found');
|
|
21
43
|
return;
|
|
22
44
|
}
|
|
23
45
|
const client = new line.messagingApi.MessagingApiClient(lineconfig);
|
|
24
|
-
// const client = new line.Client(lineconfig);
|
|
25
46
|
|
|
26
47
|
node.on('input', async (msg, send, done) => {
|
|
27
48
|
|
|
28
49
|
//chat
|
|
29
|
-
const chatId = msg.
|
|
50
|
+
// const chatId = msg.line.event
|
|
51
|
+
let chatId = '';
|
|
52
|
+
if(msg.line?.event?.source?.userId !== undefined){
|
|
53
|
+
chatId = msg.line.event.source.userId;
|
|
54
|
+
}else if(msg.line?.event?.source?.groupId !== undefined){
|
|
55
|
+
chatId = msg.line.event.source.groupId;
|
|
56
|
+
}
|
|
57
|
+
console.log('chatId:', chatId);
|
|
58
|
+
// return;
|
|
30
59
|
const loadingSeconds = msg.loadingSeconds || config.loadingSeconds;
|
|
60
|
+
const waitForCompletion = (msg.waitForCompletion !== undefined)
|
|
61
|
+
? msg.waitForCompletion
|
|
62
|
+
: config.waitForCompletion;
|
|
31
63
|
// console.log(chatId,loadingSeconds);
|
|
32
64
|
|
|
33
65
|
try {
|
|
@@ -35,6 +67,9 @@ module.exports = (RED) => {
|
|
|
35
67
|
chatId: chatId, //現状user idのみ
|
|
36
68
|
loadingSeconds: loadingSeconds,
|
|
37
69
|
});
|
|
70
|
+
if (waitForCompletion) {
|
|
71
|
+
await sleep(loadingSeconds * 1000); // 指定秒数待機させる
|
|
72
|
+
}
|
|
38
73
|
|
|
39
74
|
// レスポンスが {}(空のJSONオブジェクト)なら成功らしい
|
|
40
75
|
if (res && Object.keys(res).length === 0) {
|
|
@@ -54,4 +89,4 @@ module.exports = (RED) => {
|
|
|
54
89
|
}
|
|
55
90
|
|
|
56
91
|
RED.nodes.registerType("Loading", main);
|
|
57
|
-
}
|
|
92
|
+
}
|
|
@@ -8,11 +8,14 @@
|
|
|
8
8
|
},
|
|
9
9
|
inputs: 1,
|
|
10
10
|
outputs: 1,
|
|
11
|
-
|
|
11
|
+
inputLabels: ["LINE Messages Object"],
|
|
12
|
+
outputLabels: ["LINE Messages Object or Error Message"],
|
|
13
|
+
icon: "font-awesome/fa-check-square",
|
|
12
14
|
align: 'right',
|
|
13
15
|
label: function () {
|
|
14
|
-
return this.name || '
|
|
16
|
+
return this.name || 'Mark As Read';
|
|
15
17
|
},
|
|
18
|
+
paletteLabel: 'MarkAsRead',
|
|
16
19
|
});
|
|
17
20
|
</script>
|
|
18
21
|
|
package/nodes/push/push.html
CHANGED
package/nodes/reply/reply.html
CHANGED
package/package.json
CHANGED