suhyunpark

test image2

Showing 1 changed file with 76 additions and 8 deletions
...@@ -21,6 +21,27 @@ const HTTPS = require('https'); ...@@ -21,6 +21,27 @@ const HTTPS = require('https');
21 const domain = "2019102175.oss-2021.tk" 21 const domain = "2019102175.oss-2021.tk"
22 const sslport = 23023; 22 const sslport = 23023;
23 23
24 +var spring = 0
25 +var summer = 0
26 +var fall = 0
27 +var winter = 0
28 +
29 +var files = [
30 + 'https://blog.kakaocdn.net/dn/bf78xb/btqGzYCfgcc/QNj0SdL6KP6Ww89Mtgrmh1/img.png',
31 + 'https://www.colorcombos.com/images/colors/990000.png'
32 + // 'https://plainbackground.com/download.php?imagename=5b0000.png',
33 + // 'https://www.solidbackgrounds.com/images/2048x2048/2048x2048-red-munsell-solid-color-background.jpg',
34 + // 'https://www.cmu.edu/brand/brand-guidelines/images/colors-carnegie-red-600x600.png',
35 + // 'https://3.imimg.com/data3/FO/EO/MY-149995/lake-amaranth-food-color-250x250.jpg'
36 +]
37 +
38 +var previews = [
39 + 'https://blog.kakaocdn.net/dn/bf78xb/btqGzYCfgcc/QNj0SdL6KP6Ww89Mtgrmh1/preview.png',
40 + 'https://www.colorcombos.com/images/colors/990000/preview.png'
41 +]
42 +
43 +
44 +
24 const MULTI_TARGET_URL = 'https://api.line.me/v2/bot/message/multicast' 45 const MULTI_TARGET_URL = 'https://api.line.me/v2/bot/message/multicast'
25 const BROAD_TARGET_URL = 'https://api.line.me/v2/bot/message/broadcast' 46 const BROAD_TARGET_URL = 'https://api.line.me/v2/bot/message/broadcast'
26 const USER_ID = 'Ub99bb2ebebbbc1e06efe715b76ec9fcd' 47 const USER_ID = 'Ub99bb2ebebbbc1e06efe715b76ec9fcd'
...@@ -62,16 +83,50 @@ app.post('/hook', function (req, res) { ...@@ -62,16 +83,50 @@ app.post('/hook', function (req, res) {
62 var source = eventObj.source; 83 var source = eventObj.source;
63 var message = eventObj.message; 84 var message = eventObj.message;
64 85
65 - 86 + test1(eventObj.replyToken, eventObj.message.text)
66 - start(eventObj.replyToken, eventObj.message.text); 87 + test2(eventObj.replyToken, eventObj.message.text)
67 - test1(eventObj.replyToken, eventObj.message.text);
68 -
69 88
70 res.sendStatus(200); 89 res.sendStatus(200);
71 }); 90 });
72 91
73 -function start(replyToken, message) { 92 +function test1(replyToken, message) {
74 if (message == "Y") { 93 if (message == "Y") {
94 +
95 + request.post(
96 + {
97 + url: TARGET_URL,
98 + headers: {
99 + 'Authorization': `Bearer ${TOKEN}`
100 + },
101 + json: {
102 + "replyToken": replyToken,
103 + "messages": [
104 + {
105 + "type": "text",
106 + "text": "test1"
107 + },
108 + {
109 + "type": "image",
110 + // "originalContentUrl": files[i],
111 + // "previewImageUrl": previews[i],
112 + "originalContentUrl": "https://blog.kakaocdn.net/dn/bf78xb/btqGzYCfgcc/QNj0SdL6KP6Ww89Mtgrmh1/img.png",
113 + "previewImageUrl": "https://blog.kakaocdn.net/dn/bf78xb/btqGzYCfgcc/QNj0SdL6KP6Ww89Mtgrmh1/preview.png",
114 + },
115 + ],
116 +
117 + }
118 + }, (error, response, body) => {
119 + console.log(body)
120 + });
121 +
122 +
123 + }
124 +
125 +
126 +}
127 +
128 +function test2(replyToken, message) {
129 + if (message == "1" || message == "2" || message == "3" || message == "4") {
75 request.post( 130 request.post(
76 { 131 {
77 url: TARGET_URL, 132 url: TARGET_URL,
...@@ -82,6 +137,10 @@ function start(replyToken, message) { ...@@ -82,6 +137,10 @@ function start(replyToken, message) {
82 "replyToken": replyToken, 137 "replyToken": replyToken,
83 "messages": [ 138 "messages": [
84 { 139 {
140 + "type": "text",
141 + "text": "test2"
142 + },
143 + {
85 "type": "image", 144 "type": "image",
86 "originalContentUrl": "https://blog.kakaocdn.net/dn/bf78xb/btqGzYCfgcc/QNj0SdL6KP6Ww89Mtgrmh1/img.png", 145 "originalContentUrl": "https://blog.kakaocdn.net/dn/bf78xb/btqGzYCfgcc/QNj0SdL6KP6Ww89Mtgrmh1/img.png",
87 "previewImageUrl": "https://blog.kakaocdn.net/dn/bf78xb/btqGzYCfgcc/QNj0SdL6KP6Ww89Mtgrmh1/preview.png", 146 "previewImageUrl": "https://blog.kakaocdn.net/dn/bf78xb/btqGzYCfgcc/QNj0SdL6KP6Ww89Mtgrmh1/preview.png",
...@@ -108,10 +167,20 @@ function start(replyToken, message) { ...@@ -108,10 +167,20 @@ function start(replyToken, message) {
108 console.log(body) 167 console.log(body)
109 }); 168 });
110 } 169 }
170 + if (message == "1") spring += 1
171 + else if (message == "2") summer += 1
172 + else if (message == "3") fall += 1
173 + else if (message == "4") winter += 1
174 + console.log(spring, summer, fall, winter)
175 +
111 } 176 }
112 177
113 -function test1(replyToken, message) { 178 +
114 - if (message == "네") { 179 +
180 +
181 +
182 +function start(replyToken, message) {
183 + if (message == "Y") {
115 request.post( 184 request.post(
116 { 185 {
117 url: TARGET_URL, 186 url: TARGET_URL,
...@@ -134,7 +203,6 @@ function test1(replyToken, message) { ...@@ -134,7 +203,6 @@ function test1(replyToken, message) {
134 } 203 }
135 204
136 205
137 -
138 try { 206 try {
139 const option = { 207 const option = {
140 ca: fs.readFileSync('/etc/letsencrypt/live/' + domain + '/fullchain.pem'), 208 ca: fs.readFileSync('/etc/letsencrypt/live/' + domain + '/fullchain.pem'),
......