node-red-contrib-line-messaging-api 0.4.4 → 0.4.6

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.
@@ -14,10 +14,13 @@
14
14
  },
15
15
  inputs: 1,
16
16
  outputs: 1,
17
- icon: "comment.png",
17
+ icon: "font-awesome/fa-comment",
18
18
  align: "right",
19
19
  paletteLabel: 'Push',
20
- label: () => this.name || 'PushMessage_New'
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
- icon: "comment.png",
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 || 'ReplyMessage_New';
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">ReplyMessage</span></label>
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-channelSecret"><i class="icon-tag"></i> <span data-i18n="bloadcast.label.channelSecret">チャンネルシークレット</span></label>
34
- <input type="password" id="node-input-channelSecret" placeholder="ChannelSecret">
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
- lineconfig = { channelSecret: node.credentials.channelSecret, channelAccessToken: node.credentials.channelAccessToken};
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
- credentials: {
48
- channelSecret: {type:"password"},
49
- channelAccessToken: {type:"password"},
50
- },
51
- });
52
- }
51
+ RED.nodes.registerType("BloadcastMessage", main);
52
+ }
@@ -2,8 +2,7 @@
2
2
  "bloadcast": {
3
3
  "label": {
4
4
  "name": "名前",
5
- "channelSecret": "チャンネルシークレット",
6
- "channelAccessToken": "チャンネルアクセストークン"
5
+ "lineConfig": "LINE Bot設定"
7
6
  }
8
7
  }
9
- }
8
+ }
@@ -8,11 +8,12 @@
8
8
  },
9
9
  inputs: 1,
10
10
  outputs: 1,
11
- icon: "watch.png",
11
+ icon: "font-awesome/fa-robot",
12
12
  align: 'right',
13
13
  label: function () {
14
- return this.name || 'getBotInfo';
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
 
@@ -38,7 +38,7 @@ module.exports = (RED) => {
38
38
  done(error);
39
39
  }
40
40
 
41
- console.log("Message received:", msg.payload);
41
+ // console.log("Message received:", msg.payload);
42
42
  });
43
43
  }
44
44
 
@@ -8,11 +8,12 @@
8
8
  },
9
9
  inputs: 1,
10
10
  outputs: 1,
11
- icon: "watch.png",
11
+ icon: "font-awesome/fa-user",
12
12
  align: 'right',
13
13
  label: function () {
14
- return this.name || 'getProfile';
14
+ return this.name || 'Get Profile';
15
15
  },
16
+ paletteLabel: 'Get Profile',
16
17
  });
17
18
  </script>
18
19
 
@@ -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-AccessToken">
28
+ <label for="node-input-lineConfig">
30
29
  <i class="icon-tag"></i>
31
- <span data-i18n="limit.label.accessToken">チャンネルアクセストークン</span>
32
- </label>
33
- <input type="password" id="node-input-AccessToken" placeholder="LINE Limit AccessToken">
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>
@@ -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
- const LINE_TOKEN = node.credentials.AccessToken;
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
- credentials: {
57
- AccessToken: {type:"password"}
58
- }
59
- });
60
- }
70
+ RED.nodes.registerType("Limit", main);
71
+ }
@@ -2,7 +2,7 @@
2
2
  "limit": {
3
3
  "label": {
4
4
  "name": "名前",
5
- "accessToken": "チャンネルアクセストークン"
5
+ "lineConfig": "LINE Bot設定"
6
6
  }
7
7
  }
8
- }
8
+ }
@@ -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: "timer.png",
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
- <p>
62
+ <div class="form-row">
63
+ <label>&nbsp;</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>
@@ -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
- // channelSecret: node.credentials.channelSecret,
16
- channelAccessToken: node.credentials.channelAccessToken
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.targetId || node.credentials.targetId;
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
+ }
@@ -4,7 +4,8 @@
4
4
  "name": "名前",
5
5
  "lineConfig": "LINE Bot設定",
6
6
  "targetId": "ユーザーID",
7
- "loadingSeconds": "ローディング秒数"
7
+ "loadingSeconds": "ローディング秒数",
8
+ "waitForCompletion": "ローディング秒数分、実際の処理も待機する"
8
9
  }
9
10
  }
10
- }
11
+ }
@@ -8,11 +8,14 @@
8
8
  },
9
9
  inputs: 1,
10
10
  outputs: 1,
11
- icon: "check.png",
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 || 'markAsRead';
16
+ return this.name || 'Mark As Read';
15
17
  },
18
+ paletteLabel: 'MarkAsRead',
16
19
  });
17
20
  </script>
18
21
 
@@ -17,7 +17,8 @@
17
17
  paletteLabel: 'Push_old',
18
18
  label: function() {
19
19
  return this.name || 'PushMessage';
20
- }
20
+ },
21
+ paletteLabel: "(old) Push"
21
22
  });
22
23
  </script>
23
24
 
@@ -17,7 +17,8 @@
17
17
  paletteLabel: 'Reply_old',
18
18
  label: function () {
19
19
  return this.name || 'ReplyMessage';
20
- }
20
+ },
21
+ paletteLabel: "(old) Reply"
21
22
  });
22
23
  </script>
23
24
 
@@ -8,6 +8,7 @@
8
8
  },
9
9
  inputs: 0,
10
10
  outputs: 1,
11
+ outputLabels: ['msg.line'],
11
12
  icon: 'inject.svg',
12
13
  paletteLabel: 'Webhook',
13
14
  label: function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-line-messaging-api",
3
- "version": "0.4.4",
3
+ "version": "0.4.6",
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": {
@@ -39,8 +39,8 @@
39
39
  "author": "n0bisuke",
40
40
  "license": "Apache 2.0",
41
41
  "dependencies": {
42
- "@line/bot-sdk": "^10.5.0",
43
- "body-parser": "^1.19.1",
44
- "cors": "^2.8.5"
42
+ "@line/bot-sdk": "~10.5.0",
43
+ "body-parser": "~1.19.1",
44
+ "cors": "~2.8.5"
45
45
  }
46
46
  }
@@ -1,12 +0,0 @@
1
- {
2
- "permissions": {
3
- "allow": [
4
- "Bash(mkdir:*)",
5
- "Bash(mv:*)",
6
- "Bash(grep:*)",
7
- "Bash(find:*)",
8
- "Bash(rm:*)"
9
- ],
10
- "deny": []
11
- }
12
- }