Toggle navigation
Toggle navigation
This project
Loading...
Sign in
장재훈
/
TFT_Chat_Bot
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
2
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
장재훈
2020-06-25 05:07:36 +0000
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
e16d3a15781f321e521c353e9e4023d0800b425b
e16d3a15
1 parent
f10da0ac
Add galaxy.js
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
70 additions
and
0 deletions
data/galaxy.js
data/galaxy.js
0 → 100644
View file @
e16d3a1
const
express
=
require
(
'express'
);
const
app
=
express
();
const
logger
=
require
(
'morgan'
);
const
bodyParser
=
require
(
'body-parser'
);
const
apiRouter
=
express
.
Router
();
const
fs
=
require
(
'fs'
);
const
galaxyRawData
=
fs
.
readFileSync
(
'data/json data/galaxies.json'
);
const
galaxyData
=
JSON
.
parse
(
galaxyRawData
);
exports
.
galaxyFunction
=
function
(
req
,
res
){
var
responseBody
=
{};
const
galaxyName
=
req
.
body
[
"action"
][
"params"
][
"galaxy_name"
];
console
.
log
(
galaxyName
);
if
(
galaxyName
==
undefined
){
var
galaxyList
=
"현재 시즌의 은하계 체계 목록 :\n"
for
(
var
i
=
0
;
i
<
galaxyData
.
length
;
++
i
){
galaxyList
+=
galaxyData
[
i
].
name
+
'\n'
;
}
responseBody
=
{
"version"
:
"2.0"
,
"template"
:
{
"outputs"
:
[
{
"simpleText"
:
{
"text"
:
"원하시는 은하계 체계 정보를 검색하신다면 해당 체계에 대한 정보를 확인할 수 있습니다!\n\n현재 존재하는 은하계 체계 목록 :\n"
+
galaxyList
}
}
]
}
}
res
.
status
(
200
).
send
(
responseBody
);
}
else
{
var
index
=
0
;
for
(
index
;
index
<
galaxyData
.
length
;
++
index
){
if
(
galaxyData
[
index
].
name
==
galaxyName
){
break
;
}
};
responseBody
=
{
"version"
:
"2.0"
,
"template"
:
{
"outputs"
:
[
{
"basicCard"
:
{
"title"
:
galaxyName
,
"description"
:
"효과 : "
+
galaxyData
[
index
].
description
,
"thumbnail"
:
{
"imageUrl"
:
"http://tft-helper.tk:23023/static/etc/galaxy.png"
},
"buttons"
:[
{
"action"
:
"block"
,
"label"
:
"메뉴로 돌아가기"
,
"blockId"
:
"5ee0eef3e0d4e2000176b3f7"
}
]
}
}
]
}
}
res
.
status
(
200
).
send
(
responseBody
);
}
};
\ No newline at end of file
Please
register
or
login
to post a comment