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

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 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))
@@ -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) {
@@ -0,0 +1,8 @@
1
+ {
2
+ "markAsRead": {
3
+ "label": {
4
+ "name": "名前",
5
+ "accessToken": "チャンネルアクセストークン"
6
+ }
7
+ }
8
+ }
@@ -0,0 +1,44 @@
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
+ icon: "check.png",
12
+ align: 'right',
13
+ label: function () {
14
+ return this.name || 'markAsRead';
15
+ },
16
+ });
17
+ </script>
18
+
19
+ <script type="text/html" data-template-name="markAsRead">
20
+ <!-- 名前 -->
21
+ <div class="form-row">
22
+ <label for="node-input-name">
23
+ <i class="fa fa-tag"></i>
24
+ <span data-i18n="markAsRead.label.name">名前</span>
25
+ </label>
26
+ <input type="text" id="node-input-name" placeholder="Name">
27
+ </div>
28
+
29
+ <!-- LINE Config -->
30
+ <div class="form-row">
31
+ <label for="node-input-lineConfig">
32
+ <i class="fa fa-tag"></i>
33
+ <span data-i18n="markAsRead.label.lineConfig">LINE Bot設定</span>
34
+ </label>
35
+ <input type="text" id="node-input-lineConfig">
36
+ </div>
37
+
38
+ </script>
39
+
40
+ <script type="text/html" data-help-name="markAsRead">
41
+ <p>Gets the user profile information.</p>
42
+ </script>
43
+
44
+
@@ -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
+ }
@@ -10,10 +10,16 @@ module.exports = (RED) => {
10
10
  try {
11
11
  lineconfig = require('../../env');
12
12
  } catch (error) {
13
- lineconfig = {
14
- channelSecret: node.credentials.channelSecret,
15
- channelAccessToken: node.credentials.channelAccessToken
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",
3
+ "version": "0.4.4",
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": "^9.5.0",
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
  }