Toggle navigation
Toggle navigation
This project
Loading...
Sign in
오규림
/
Personal_color_chatbot
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
suhyunpark
2021-06-03 21:42:53 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
985f59f27d773a12bbb74646d5b9f6240fef300f
985f59f2
1 parent
3905c745
test image2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
76 additions
and
8 deletions
app.js
app.js
View file @
985f59f
...
...
@@ -21,6 +21,27 @@ const HTTPS = require('https');
const
domain
=
"2019102175.oss-2021.tk"
const
sslport
=
23023
;
var
spring
=
0
var
summer
=
0
var
fall
=
0
var
winter
=
0
var
files
=
[
'https://blog.kakaocdn.net/dn/bf78xb/btqGzYCfgcc/QNj0SdL6KP6Ww89Mtgrmh1/img.png'
,
'https://www.colorcombos.com/images/colors/990000.png'
// 'https://plainbackground.com/download.php?imagename=5b0000.png',
// 'https://www.solidbackgrounds.com/images/2048x2048/2048x2048-red-munsell-solid-color-background.jpg',
// 'https://www.cmu.edu/brand/brand-guidelines/images/colors-carnegie-red-600x600.png',
// 'https://3.imimg.com/data3/FO/EO/MY-149995/lake-amaranth-food-color-250x250.jpg'
]
var
previews
=
[
'https://blog.kakaocdn.net/dn/bf78xb/btqGzYCfgcc/QNj0SdL6KP6Ww89Mtgrmh1/preview.png'
,
'https://www.colorcombos.com/images/colors/990000/preview.png'
]
const
MULTI_TARGET_URL
=
'https://api.line.me/v2/bot/message/multicast'
const
BROAD_TARGET_URL
=
'https://api.line.me/v2/bot/message/broadcast'
const
USER_ID
=
'Ub99bb2ebebbbc1e06efe715b76ec9fcd'
...
...
@@ -62,16 +83,50 @@ app.post('/hook', function (req, res) {
var
source
=
eventObj
.
source
;
var
message
=
eventObj
.
message
;
start
(
eventObj
.
replyToken
,
eventObj
.
message
.
text
);
test1
(
eventObj
.
replyToken
,
eventObj
.
message
.
text
);
test1
(
eventObj
.
replyToken
,
eventObj
.
message
.
text
)
test2
(
eventObj
.
replyToken
,
eventObj
.
message
.
text
)
res
.
sendStatus
(
200
);
});
function
start
(
replyToken
,
message
)
{
function
test1
(
replyToken
,
message
)
{
if
(
message
==
"Y"
)
{
request
.
post
(
{
url
:
TARGET_URL
,
headers
:
{
'Authorization'
:
`Bearer
${
TOKEN
}
`
},
json
:
{
"replyToken"
:
replyToken
,
"messages"
:
[
{
"type"
:
"text"
,
"text"
:
"test1"
},
{
"type"
:
"image"
,
// "originalContentUrl": files[i],
// "previewImageUrl": previews[i],
"originalContentUrl"
:
"https://blog.kakaocdn.net/dn/bf78xb/btqGzYCfgcc/QNj0SdL6KP6Ww89Mtgrmh1/img.png"
,
"previewImageUrl"
:
"https://blog.kakaocdn.net/dn/bf78xb/btqGzYCfgcc/QNj0SdL6KP6Ww89Mtgrmh1/preview.png"
,
},
],
}
},
(
error
,
response
,
body
)
=>
{
console
.
log
(
body
)
});
}
}
function
test2
(
replyToken
,
message
)
{
if
(
message
==
"1"
||
message
==
"2"
||
message
==
"3"
||
message
==
"4"
)
{
request
.
post
(
{
url
:
TARGET_URL
,
...
...
@@ -82,6 +137,10 @@ function start(replyToken, message) {
"replyToken"
:
replyToken
,
"messages"
:
[
{
"type"
:
"text"
,
"text"
:
"test2"
},
{
"type"
:
"image"
,
"originalContentUrl"
:
"https://blog.kakaocdn.net/dn/bf78xb/btqGzYCfgcc/QNj0SdL6KP6Ww89Mtgrmh1/img.png"
,
"previewImageUrl"
:
"https://blog.kakaocdn.net/dn/bf78xb/btqGzYCfgcc/QNj0SdL6KP6Ww89Mtgrmh1/preview.png"
,
...
...
@@ -108,10 +167,20 @@ function start(replyToken, message) {
console
.
log
(
body
)
});
}
if
(
message
==
"1"
)
spring
+=
1
else
if
(
message
==
"2"
)
summer
+=
1
else
if
(
message
==
"3"
)
fall
+=
1
else
if
(
message
==
"4"
)
winter
+=
1
console
.
log
(
spring
,
summer
,
fall
,
winter
)
}
function
test1
(
replyToken
,
message
)
{
if
(
message
==
"네"
)
{
function
start
(
replyToken
,
message
)
{
if
(
message
==
"Y"
)
{
request
.
post
(
{
url
:
TARGET_URL
,
...
...
@@ -134,7 +203,6 @@ function test1(replyToken, message) {
}
try
{
const
option
=
{
ca
:
fs
.
readFileSync
(
'/etc/letsencrypt/live/'
+
domain
+
'/fullchain.pem'
),
...
...
Please
register
or
login
to post a comment