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-23 18:50:45 +0000
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
2974e080e2000cf240bbcb62a9b5357701e5654e
2974e080
1 parent
78ace778
챔피언 정보 출력 기능 추가
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
47 deletions
data/app.js
data/app.js
View file @
2974e08
...
...
@@ -2,7 +2,7 @@ const express = require('express');
const
app
=
express
();
const
logger
=
require
(
'morgan'
);
const
bodyParser
=
require
(
'body-parser'
);
const
fs
=
require
(
'fs'
);
const
apiRouter
=
express
.
Router
();
app
.
use
(
logger
(
'dev'
,
{}));
...
...
@@ -13,42 +13,50 @@ app.use(bodyParser.urlencoded({
app
.
use
(
'/api'
,
apiRouter
);
apiRouter
.
post
(
'/sayHello'
,
function
(
req
,
res
)
{
apiRouter
.
post
(
'/champion'
,
function
(
req
,
res
)
{
console
.
log
(
req
.
body
)
const
championName
=
req
[
"detailParams"
][
"champion_name"
][
"value"
];
let
championRawData
=
fs
.
readFileSync
(
'data/json data/champions.json'
);
let
championData
=
JSON
.
parse
(
championRawData
);
var
i
=
0
;
for
(
i
;
i
<
championData
.
length
;
++
i
){
if
(
championData
[
i
].
name
==
championName
){
break
;
}
};
const
championQuery
=
(
championData
[
i
].
championID
).
replace
(
/"TF3_"/g
,
''
);
const
responseBody
=
{
version
:
"2.0"
,
template
:
{
outputs
:
[
"version"
:
"2.0"
,
"template"
:
{
"outputs"
:
[
{
simpleText
:
{
text
:
"hello I'm Ryan"
"basicCard"
:
{
"title"
:
championName
,
"description"
:
"비용 : "
+
championData
[
i
].
cost
+
"\n"
+
"시너지 : "
+
championData
[
i
].
traits
,
"thumbnail"
:
{
"imageUrl"
:
"data/Image data/champions/"
+
championName
+
".png"
},
"buttons"
:
[
{
"action"
:
"webLink"
,
"label"
:
"상세한 정보 확인"
,
"webLinkUrl"
:
"https://lolchess.gg/champions/set3.5/"
+
championQuery
}
]
}
}
]
}
}
;
}
res
.
status
(
200
).
send
(
responseBody
);
});
apiRouter
.
post
(
'/showHello'
,
function
(
req
,
res
)
{
console
.
log
(
req
.
body
);
const
responseBody
=
{
version
:
"2.0"
,
template
:
{
outputs
:
[
{
simpleImage
:
{
imageUrl
:
"https://t1.daumcdn.net/friends/prod/category/M001_friends_ryan2.jpg"
,
altText
:
"hello I'm Ryan"
}
}
]
}
};
res
.
status
(
200
).
send
(
responseBody
);
app
.
listen
(
23023
,
function
()
{
console
.
log
(
'Example skill server listening on port 23023!'
);
});
/*
const fs = require('fs');
app.post('/champion',function(req,res){
...
...
@@ -63,26 +71,4 @@ app.post('/champion',function(req,res){
}
}
})
app.get('/', function(req, res){
res.send('Hello, World!');
})
app.get('/test', function(req, res){
res.send('Hello, TEST!');
})
app.put('/oss', function(req, res){
res.send('Hello, OSS!');
})
app.get('/users/:userId/books/:bookId', function(req, res){
console.log(req.params.userId)
console.log(req.params.bookId)
res.send(req.params);
})
*/
app
.
listen
(
3000
,
function
(){
console
.
log
(
"Example skill server listening on port 3000!"
);
});
...
...
Please
register
or
login
to post a comment