Toggle navigation
Toggle navigation
This project
Loading...
Sign in
방승일
/
mamuri-bot
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
유명현
2022-05-14 19:56:27 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
58acd87b96dd29cdca98d8bf67b66d2108da9815
58acd87b
1 parent
541412fa
EDIT: .gitignore (.env) & ADD: line flexMessage
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
179 additions
and
8 deletions
server/app.js
server/pushMessage.js
server/app.js
View file @
58acd87
const
express
=
require
(
"express"
);
const
line
=
require
(
"@line/bot-sdk"
);
const
setFlexMessage
=
require
(
"./pushMessage"
);
require
(
"dotenv"
).
config
();
console
.
log
(
process
.
env
.
channelAccessToken
,
process
.
env
.
channelSecret
);
const
config
=
{
channelAccessToken
:
process
.
env
.
channelAccessToken
,
channelSecret
:
process
.
env
.
channelSecret
,
...
...
@@ -22,14 +22,22 @@ function handleEvent(event) {
console
.
log
(
event
);
// push
client
.
pushMessage
(
event
.
source
.
userId
,
{
type
:
"text"
,
text
:
"hihihi"
,
});
return
client
.
replyMessage
(
event
.
replyToken
,
{
type
:
"text"
,
text
:
event
.
message
.
text
,
// 매물 테스트 알림
return
client
.
pushMessage
(
event
.
source
.
userId
,
{
type
:
"flex"
,
altText
:
"새로운 매물이 왔어요!"
,
contents
:
setFlexMessage
(
"daangn"
,
"RTX 3080"
,
"1000000"
,
"https://dnvefa72aowie.cloudfront.net/origin/article/202205/94cdd237258671d5806a70f64ab2b3c7dcd790da0384b394ef5809fe10c08ced.webp?q=95&s=1440x1440&t=inside"
,
"https://www.daangn.com/articles/403755360"
),
});
// return client.replyMessage(event.replyToken, {
// type: "text",
// text: event.message.text,
// });
}
app
.
listen
(
3000
);
...
...
server/pushMessage.js
0 → 100644
View file @
58acd87
function
priceToString
(
price
)
{
return
price
.
toString
().
replace
(
/
\B(?=(\d{3})
+
(?!\d))
/g
,
","
);
}
function
setFlexMessage
(
platform
,
name
,
price
,
thumbnailUrl
,
itemUrl
)
{
let
koreanPlatformName
=
""
;
if
(
platform
===
"daangn"
)
{
koreanPlatformName
=
"당근"
;
}
else
if
(
platform
===
"joongna"
)
{
koreanPlatformName
=
"중고나라"
;
}
else
if
(
platform
===
"bunjang"
)
{
koreanPlatformName
=
"번개나라"
;
}
else
{
koreanPlatformName
=
"Unknown"
;
}
let
flexMessage
=
{
type
:
"bubble"
,
hero
:
{
type
:
"image"
,
url
:
thumbnailUrl
,
size
:
"full"
,
aspectRatio
:
"20:13"
,
aspectMode
:
"cover"
,
action
:
{
type
:
"uri"
,
uri
:
itemUrl
,
},
},
body
:
{
type
:
"box"
,
layout
:
"vertical"
,
contents
:
[
{
type
:
"text"
,
text
:
name
,
weight
:
"bold"
,
size
:
"xl"
,
},
// {
// type: "box",
// layout: "baseline",
// margin: "md",
// contents: [
// {
// type: "icon",
// size: "sm",
// url: "https://scdn.line-apps.com/n/channel_devcenter/img/fx/review_gold_star_28.png",
// },
// {
// type: "icon",
// size: "sm",
// url: "https://scdn.line-apps.com/n/channel_devcenter/img/fx/review_gold_star_28.png",
// },
// {
// type: "icon",
// size: "sm",
// url: "https://scdn.line-apps.com/n/channel_devcenter/img/fx/review_gold_star_28.png",
// },
// {
// type: "icon",
// size: "sm",
// url: "https://scdn.line-apps.com/n/channel_devcenter/img/fx/review_gold_star_28.png",
// },
// {
// type: "icon",
// size: "sm",
// url: "https://scdn.line-apps.com/n/channel_devcenter/img/fx/review_gray_star_28.png",
// },
// {
// type: "text",
// text: "4.0",
// size: "sm",
// color: "#999999",
// margin: "md",
// flex: 0,
// },
// ],
// },
{
type
:
"box"
,
layout
:
"vertical"
,
margin
:
"lg"
,
spacing
:
"sm"
,
contents
:
[
{
type
:
"box"
,
layout
:
"baseline"
,
spacing
:
"sm"
,
contents
:
[
{
type
:
"text"
,
text
:
"플랫폼"
,
color
:
"#aaaaaa"
,
size
:
"sm"
,
flex
:
1
,
},
{
type
:
"text"
,
text
:
koreanPlatformName
,
wrap
:
true
,
color
:
"#666666"
,
size
:
"sm"
,
flex
:
5
,
},
],
},
{
type
:
"box"
,
layout
:
"baseline"
,
spacing
:
"sm"
,
contents
:
[
{
type
:
"text"
,
text
:
"가격"
,
color
:
"#aaaaaa"
,
size
:
"sm"
,
flex
:
1
,
},
{
type
:
"text"
,
text
:
priceToString
(
price
*
1
)
+
"원"
,
wrap
:
true
,
color
:
"#666666"
,
size
:
"sm"
,
flex
:
5
,
},
],
},
],
},
],
},
footer
:
{
type
:
"box"
,
layout
:
"vertical"
,
spacing
:
"sm"
,
contents
:
[
{
type
:
"button"
,
style
:
"link"
,
height
:
"sm"
,
action
:
{
type
:
"uri"
,
label
:
"매물 확인"
,
uri
:
itemUrl
,
},
},
{
type
:
"box"
,
layout
:
"vertical"
,
contents
:
[],
margin
:
"sm"
,
},
],
flex
:
0
,
},
};
return
flexMessage
;
//return JSON.stringify(flexMessage);
}
module
.
exports
=
setFlexMessage
;
Please
register
or
login
to post a comment