오규림

Merge branch 'master' into 'master'

change buttons



See merge request !2
Showing 1 changed file with 71 additions and 43 deletions
1 -var express = require('express'); 1 +var express = require("express");
2 2
3 -var http = require('http'); 3 +var http = require("http");
4 4
5 -var bodyParser = require('body-parser'); 5 +var bodyParser = require("body-parser");
6 6
7 var app = express(); 7 var app = express();
8 8
9 -app.get('/keyboard', function(req,res){ 9 +app.get("/Personal_color_chatbot", function (req, res) {
10 + var data = {
11 + type: "buttons",
12 + buttons: ["퍼스널 컬러 진단하기", "봄웜", "여름쿨", "가을웜", "겨울쿨"],
13 + };
10 14
11 - var data ={ 15 + res.json(data);
12 - 'type': 'buttons',
13 - 'buttons': ['질문','컬러','정보']
14 - };
15 -
16 - res.json(data);
17 }); 16 });
18 17
19 -app.use(bodyParser.urlencoded({extended:false})); 18 +app.use(bodyParser.urlencoded({ extended: false }));
20 app.use(bodyParser.json()); 19 app.use(bodyParser.json());
21 20
22 -app.post('/message',function(req,res){ 21 +app.post("/message", function (req, res) {
23 - 22 + var msg = req.body.content;
24 - var msg = req.body.content; 23 + console.log("전달받은 메세지: " + msg);
25 - console.log('전달받은 메세지: '+msg); 24 +
26 - 25 + var send = {};
27 - var send ={}; 26 +
28 - 27 + switch (msg) {
29 - switch(msg){ 28 + case "퍼스널 컬러 진단하기":
30 - case 'pink': 29 + send = {
31 - send = { 30 + message: {
32 - 31 + text: "퍼스널 컬러 진단하기 선택",
33 - } 32 + },
34 - break; 33 + };
35 - 34 + break;
36 - case 'orange': 35 +
37 - send ={ 36 + case "봄웜":
38 - 37 + send = {
39 - } 38 + message: {
40 - break; 39 + text: "봄웜 선택",
41 - 40 + },
42 - default: 41 + };
43 - send = { 42 + break;
44 - 43 +
45 - } 44 + case "여름쿨":
46 - break; 45 + send = {
47 - } 46 + message: {
48 - 47 + text: "여름쿨 선택",
49 - res.json(send); 48 + },
50 -}) 49 + };
50 + break;
51 +
52 + case "가을웜":
53 + send = {
54 + message: {
55 + text: "가을웜 선택",
56 + },
57 + };
58 + break;
59 +
60 + case "겨울쿨":
61 + send = {
62 + message: {
63 + text: "겨을쿨 선택",
64 + },
65 + };
66 + break;
67 +
68 + default:
69 + send = {
70 + message: {
71 + text: "알 수 없는 명령입니다.",
72 + },
73 + };
74 + break;
75 + }
76 +
77 + res.json(send);
78 +});
51 79
52 -http.createServer(app).listen(9090,function(){
53 - console.log('서버실행중..');
54 -});
...\ No newline at end of file ...\ No newline at end of file
80 +http.createServer(app).listen(9090, function () {
81 + console.log("서버실행중..");
82 +});
......