node-red-contrib-line-messaging-api 0.4.3 → 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/README.ja.md +1 -0
- package/README.md +1 -0
- package/nodes/_new/push/push.html +5 -2
- package/nodes/_new/reply/reply.html +8 -6
- package/nodes/_new/reply/reply.js +1 -1
- 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/locales/ja/markAsRead.json +8 -0
- package/nodes/markAsRead/markAsRead.html +47 -0
- package/nodes/markAsRead/markAsRead.js +57 -0
- package/nodes/push/push.html +2 -1
- package/nodes/reply/reply.html +2 -1
- package/nodes/reply/reply.js +10 -4
- package/nodes/webhook/webhook.html +1 -0
- package/package.json +5 -5
- package/.claude/settings.local.json +0 -12
package/README.ja.md
CHANGED
|
@@ -152,6 +152,7 @@ https://developers.line.biz/ja/reference/messaging-api/#get-bot-info
|
|
|
152
152
|
|
|
153
153
|
## リリースノート
|
|
154
154
|
|
|
155
|
+
- 2024/12/27: v0.4.3 - 多言語化(i18n)対応、LINE Notifyノード削除(API終了)、英語・日本語ドキュメント整備
|
|
155
156
|
- 2024/12/27: Loading / getProfile / configノードの追加
|
|
156
157
|
- 2023/12/11: Notify_newを追加。スタンプや画像も送れるように。
|
|
157
158
|
- 2021/8/1: Reply Messageが画像に対応(thanks [@ukkz](https://github.com/ukkz))
|
package/README.md
CHANGED
|
@@ -152,6 +152,7 @@ https://developers.line.biz/en/reference/messaging-api/#get-bot-info
|
|
|
152
152
|
|
|
153
153
|
## Release Notes
|
|
154
154
|
|
|
155
|
+
- 2024/12/27: v0.4.3 - Added internationalization (i18n) support, removed LINE Notify nodes (API discontinued), updated documentation with English/Japanese versions
|
|
155
156
|
- 2024/12/27: Added Loading, getProfile, and config nodes
|
|
156
157
|
- 2023/12/11: Added Notify_new with sticker and image support
|
|
157
158
|
- 2021/8/1: Reply Message now supports images (thanks [@ukkz](https://github.com/ukkz))
|
|
@@ -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>
|
|
@@ -64,7 +64,7 @@ module.exports = (RED) => {
|
|
|
64
64
|
|
|
65
65
|
// 新仕様
|
|
66
66
|
const reply = async (msg) => {
|
|
67
|
-
console.log(typeof msg.payload, msg.payload);
|
|
67
|
+
// console.log(typeof msg.payload, msg.payload);
|
|
68
68
|
if (!msg.line || !msg.line.event || !msg.line.event.type) {
|
|
69
69
|
throw 'no valid LINE event found within msg';
|
|
70
70
|
} else if (!msg.line.event.replyToken) {
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
RED.nodes.registerType('markAsRead', {
|
|
3
|
+
category: 'LINE',
|
|
4
|
+
color: '#01B301',
|
|
5
|
+
defaults: {
|
|
6
|
+
name: {value: ''},
|
|
7
|
+
lineConfig: {value: "", type:"lineConfig", required:true},
|
|
8
|
+
},
|
|
9
|
+
inputs: 1,
|
|
10
|
+
outputs: 1,
|
|
11
|
+
inputLabels: ["LINE Messages Object"],
|
|
12
|
+
outputLabels: ["LINE Messages Object or Error Message"],
|
|
13
|
+
icon: "font-awesome/fa-check-square",
|
|
14
|
+
align: 'right',
|
|
15
|
+
label: function () {
|
|
16
|
+
return this.name || 'Mark As Read';
|
|
17
|
+
},
|
|
18
|
+
paletteLabel: 'MarkAsRead',
|
|
19
|
+
});
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<script type="text/html" data-template-name="markAsRead">
|
|
23
|
+
<!-- 名前 -->
|
|
24
|
+
<div class="form-row">
|
|
25
|
+
<label for="node-input-name">
|
|
26
|
+
<i class="fa fa-tag"></i>
|
|
27
|
+
<span data-i18n="markAsRead.label.name">名前</span>
|
|
28
|
+
</label>
|
|
29
|
+
<input type="text" id="node-input-name" placeholder="Name">
|
|
30
|
+
</div>
|
|
31
|
+
|
|
32
|
+
<!-- LINE Config -->
|
|
33
|
+
<div class="form-row">
|
|
34
|
+
<label for="node-input-lineConfig">
|
|
35
|
+
<i class="fa fa-tag"></i>
|
|
36
|
+
<span data-i18n="markAsRead.label.lineConfig">LINE Bot設定</span>
|
|
37
|
+
</label>
|
|
38
|
+
<input type="text" id="node-input-lineConfig">
|
|
39
|
+
</div>
|
|
40
|
+
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
<script type="text/html" data-help-name="markAsRead">
|
|
44
|
+
<p>Gets the user profile information.</p>
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
|
|
@@ -0,0 +1,57 @@
|
|
|
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
|
+
node.lineConfig = RED.nodes.getNode(config.lineConfig); //共通のlineConfigを取得
|
|
15
|
+
|
|
16
|
+
lineconfig = {
|
|
17
|
+
channelSecret: node.lineConfig.credentials.LineChannelSecret,
|
|
18
|
+
channelAccessToken: node.lineConfig.credentials.LineChannelAccessToken
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
if(lineconfig.channelAccessToken === undefined || lineconfig.channelAccessToken === '') {
|
|
22
|
+
console.error('LINE token not found');
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const client = new line.messagingApi.MessagingApiClient(lineconfig);
|
|
26
|
+
|
|
27
|
+
// ここでLINE APIを呼び出す処理
|
|
28
|
+
node.on('input', async(msg, send, done) => {
|
|
29
|
+
// console.log("markAsReadToken:");
|
|
30
|
+
// console.log(msg.line.event, send);
|
|
31
|
+
try {
|
|
32
|
+
const markAsReadToken = msg.line?.event?.message?.markAsReadToken;
|
|
33
|
+
const res = await client.markMessagesAsReadByToken({ markAsReadToken: markAsReadToken });
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
if(Object.keys(res).length !== 0) { // 正常だと{}が返ってくる
|
|
37
|
+
throw new Error(`Marked as read failed.`);
|
|
38
|
+
}else{
|
|
39
|
+
// console.log("Marked as read successfully.");
|
|
40
|
+
// 成功した場合の処理 そのままpayloadを返す
|
|
41
|
+
msg.payload = msg.payload || {};
|
|
42
|
+
send(msg);
|
|
43
|
+
}
|
|
44
|
+
} catch (error) {
|
|
45
|
+
// console.error(error.body);
|
|
46
|
+
node.error(error.body, msg.payload);
|
|
47
|
+
msg.payload = error.body; //エラーメッセージをDebugに表示するためにmsg.payloadにセット
|
|
48
|
+
send(msg);
|
|
49
|
+
done(error);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// console.log("Message received:", msg.payload);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
RED.nodes.registerType("markAsRead", main);
|
|
57
|
+
}
|
package/nodes/push/push.html
CHANGED
package/nodes/reply/reply.html
CHANGED
package/nodes/reply/reply.js
CHANGED
|
@@ -10,10 +10,16 @@ module.exports = (RED) => {
|
|
|
10
10
|
try {
|
|
11
11
|
lineconfig = require('../../env');
|
|
12
12
|
} catch (error) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
13
|
+
const globalLineConfig = node.context().global.get("lineConfig");
|
|
14
|
+
if (globalLineConfig) {
|
|
15
|
+
lineconfig = globalLineConfig;
|
|
16
|
+
} else {
|
|
17
|
+
lineconfig = {
|
|
18
|
+
channelSecret: node.credentials.channelSecret,
|
|
19
|
+
channelAccessToken: node.credentials.channelAccessToken
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
17
23
|
}
|
|
18
24
|
|
|
19
25
|
if (lineconfig.channelSecret === '' || lineconfig.channelAccessToken === '') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-red-contrib-line-messaging-api",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.5",
|
|
4
4
|
"description": "Node-RED nodes for LINE Messaging API integration. Build LINE Bots easily with visual programming.",
|
|
5
5
|
"main": "line.js",
|
|
6
6
|
"repository": {
|
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
"lineConfig": "./nodes/config/config.js",
|
|
24
24
|
"Loading": "./nodes/loading/loading.js",
|
|
25
25
|
"ReplyMessage": "./nodes/reply/reply.js",
|
|
26
|
-
"PushMessage": "./nodes/push/push.js"
|
|
26
|
+
"PushMessage": "./nodes/push/push.js",
|
|
27
|
+
"MarkAsRead": "./nodes/markAsRead/markAsRead.js"
|
|
27
28
|
}
|
|
28
29
|
},
|
|
29
30
|
"keywords": [
|
|
@@ -38,9 +39,8 @@
|
|
|
38
39
|
"author": "n0bisuke",
|
|
39
40
|
"license": "Apache 2.0",
|
|
40
41
|
"dependencies": {
|
|
41
|
-
"@line/bot-sdk": "^
|
|
42
|
+
"@line/bot-sdk": "^10.5.0",
|
|
42
43
|
"body-parser": "^1.19.1",
|
|
43
|
-
"cors": "^2.8.5"
|
|
44
|
-
"express": "^4.17.1"
|
|
44
|
+
"cors": "^2.8.5"
|
|
45
45
|
}
|
|
46
46
|
}
|