JKL

Modularization

...@@ -9,6 +9,10 @@ const app = express(); ...@@ -9,6 +9,10 @@ const app = express();
9 app.use(express.urlencoded({ extended: false })); 9 app.use(express.urlencoded({ extended: false }));
10 app.use(express.json()); 10 app.use(express.json());
11 11
12 +var club = require('./club');
13 +var haksik = require('./haksik');
14 +var haksa = require('./haksa');
15 +
12 app.post('/message', (req, res) => { 16 app.post('/message', (req, res) => {
13 const question = req.body.userRequest.utterance; 17 const question = req.body.userRequest.utterance;
14 const goMain = '처음으로'; 18 const goMain = '처음으로';
...@@ -16,150 +20,20 @@ app.post('/message', (req, res) => { ...@@ -16,150 +20,20 @@ app.post('/message', (req, res) => {
16 20
17 // 학사정보 간편보기 21 // 학사정보 간편보기
18 if(question == "간편하게 보는 학사정보"){ 22 if(question == "간편하게 보는 학사정보"){
19 - data ={ 23 + data = haksa.Haksa_Information(data);
20 - "version": "2.0",
21 - "template": {
22 - "outputs": [
23 - {
24 - "listCard": {
25 - "header": {
26 - "title": "KHU 학사정보 알리미"
27 - },
28 - "items": [
29 - {
30 - "title": "장학금 공지사항",
31 - "description": "챗봇으로 손쉽게 알아보는 학사정보",
32 - "imageUrl": "https://mblogthumb-phinf.pstatic.net/20140716_293/envicontest_1405437648963lV4y4_GIF/University_Seal.gif?type=w2",
33 - "link": {
34 - "web": "https://www.khu.ac.kr/kor/notice/list.do?category=SCHOLARSHIP&page=1"
35 - }
36 - },
37 - {
38 - "title": "공용 소프트웨어 필요할 땐?",
39 - "description": "경희대학교 정보처를 이용해보세요.",
40 - "imageUrl": "https://cdn-icons.flaticon.com/png/128/2888/premium/2888407.png?token=exp=1638455259~hmac=d58c655e0ac8a16809b48323ea83a75f",
41 - "link": {
42 - "web": "https://ois.khu.ac.kr/index.do?sso=ok"
43 - }
44 - },
45 - {
46 - "title": "학사 공지사항",
47 - "description": "학사 일정 공지사항 알아보기",
48 - "imageUrl": "https://cdn-icons.flaticon.com/png/128/3277/premium/3277431.png?token=exp=1638455425~hmac=4fe1afa937ad2ca62e17e25a34aa342e",
49 - "link": {
50 - "web": "https://www.khu.ac.kr/kor/notice/list.do?category=UNDERGRADUATE&page=1"
51 - }
52 - }
53 - ],
54 - "buttons": [
55 - {
56 - "label": "홈페이지 구경가기",
57 - "action": "webLink",
58 - "webLinkUrl": "https://www.khu.ac.kr/kor/main/index.do"
59 - }
60 - ]
61 - }
62 - }
63 - ]
64 - }
65 - }
66 } 24 }
67 25
68 //동아리 정보 보기 26 //동아리 정보 보기
69 if(question== "바운스" || question == "bounce"){ 27 if(question== "바운스" || question == "bounce"){
70 - data = { 28 + data = club.Bounce(data);
71 - "version": "2.0",
72 - "template": {
73 - "outputs": [
74 - {
75 - "listCard": {
76 - "header": {
77 - "title": "BOUNCE"
78 - },
79 - "items": [
80 - {
81 - "title": "Instagram",
82 - "description": "인스타그램으로 이동",
83 - "imageUrl": "https://cdn-icons.flaticon.com/png/128/3955/premium/3955024.png?token=exp=1638459829~hmac=5fedfb0e259d3541fa15144c8329704c",
84 - "link": {
85 - "web": "https://www.instagram.com/official_bnc/"
86 - }
87 - },
88 - {
89 - "title": "Facebook",
90 - "description": "페이스북으로 이동",
91 - "imageUrl": "https://cdn-icons-png.flaticon.com/128/145/145802.png",
92 - "link": {
93 - "web": "https://m.facebook.com/khubounce"
94 - }
95 - },
96 - {
97 - "title": "Youtube",
98 - "description": "유튜브로 이동",
99 - "imageUrl": "https://cdn-icons-png.flaticon.com/128/187/187209.png",
100 - "link": {
101 - "web": "https://m.youtube.com/channel/UCdqjjUiX3nTsr0neeC1ovvw"
102 - }
103 - }
104 - ]
105 - }
106 - }
107 - ]
108 - }
109 - }
110 } 29 }
111 30
31 +
112 //학식 32 //학식
113 if (question == "서울캠퍼스") { 33 if (question == "서울캠퍼스") {
114 - data = { 34 + data = haksik.Seoul(data);
115 - 'version': '2.0',
116 - 'template': {
117 - 'outputs': [{
118 - 'simpleImage': {
119 - 'imageUrl': "https://coop.khu.ac.kr/wp-content/uploads/2021/11/20211129-1301x2048.png",
120 - 'altText' : "서울캠퍼스 식단입니다."
121 - }
122 - }],
123 - 'quickReplies': [{
124 - 'label': goMain,
125 - 'action': 'message',
126 - 'messageText': goMain
127 - }]
128 - }
129 - }
130 }else if (question == "국제캠퍼스") { 35 }else if (question == "국제캠퍼스") {
131 - data = { 36 + data = haksik.Global(data);
132 - "version": "2.0",
133 - "template": {
134 - "outputs": [
135 - {
136 - "basicCard": {
137 - "title": "국제캠퍼스 학식",
138 - "description": "오늘의 학식은 무엇일까?!",
139 - "thumbnail": {
140 - "imageUrl": "https://ww.namu.la/s/e38da99cb3bbad5d4a7f19a015fc2a888e01a7c996bb18465f8ba242a21ac5b3d1f2f977094552b00c706aab9c5c7e48dedae0103ed84d8039376458bebeaf0c43c7642b2544a52a016d0633eeab043924071315d41e15ef8df134009508ec03"
141 - },
142 - "profile": {
143 - "imageUrl": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcT4BJ9LU4Ikr_EvZLmijfcjzQKMRCJ2bO3A8SVKNuQ78zu2KOqM",
144 - "nickname": "학식"
145 - },
146 - "social": {
147 - "like": 1238,
148 - "comment": 8,
149 - "share": 780
150 - },
151 - "buttons": [
152 - {
153 - "action": "webLink",
154 - "label": "학식보기",
155 - "webLinkUrl": "https://www.khu.ac.kr/kor/forum/list.do?type=RESTAURANT&category=INTL&page=1"
156 - }
157 - ]
158 - }
159 - }
160 - ]
161 - }
162 - }
163 } 37 }
164 res.json(data); 38 res.json(data);
165 }); 39 });
......
1 +const express = require('express');
2 +const app = express();
3 +
4 +app.use(express.urlencoded({ extended: false }));
5 +app.use(express.json());
6 +var club_data;
7 +
8 +//동아리 정보 보기
9 +module.exports.Bounce = function(club_data){
10 + club_data = {
11 + "version": "2.0",
12 + "template": {
13 + "outputs": [
14 + {
15 + "listCard": {
16 + "header": {
17 + "title": "BOUNCE"
18 + },
19 + "items": [
20 + {
21 + "title": "Instagram",
22 + "description": "인스타그램으로 이동",
23 + "imageUrl": "https://cdn-icons.flaticon.com/png/128/4494/premium/4494488.png?token=exp=1638510204~hmac=e5de773ad3fee42dd34e247d2c695246",
24 + "link": {
25 + "web": "https://www.instagram.com/official_bnc/"
26 + }
27 + },
28 + {
29 + "title": "Facebook",
30 + "description": "페이스북으로 이동",
31 + "imageUrl": "https://cdn-icons-png.flaticon.com/128/145/145802.png",
32 + "link": {
33 + "web": "https://m.facebook.com/khubounce"
34 + }
35 + },
36 + {
37 + "title": "Youtube",
38 + "description": "유튜브로 이동",
39 + "imageUrl": "https://cdn-icons-png.flaticon.com/128/187/187209.png",
40 + "link": {
41 + "web": "https://m.youtube.com/channel/UCdqjjUiX3nTsr0neeC1ovvw"
42 + }
43 + }
44 + ]
45 + } }
46 + ]
47 + }
48 + }
49 + return club_data;
50 +}
51 +
52 +
1 +const express = require('express');
2 +const app = express();
3 +
4 +app.use(express.urlencoded({ extended: false }));
5 +app.use(express.json());
6 +var haksa_data;
7 +
8 +//학사정보 간편보기
9 +module.exports.Haksa_Information = function(haksa_data){
10 + haksa_data = {
11 + "version": "2.0",
12 + "template": {
13 + "outputs": [
14 + {
15 + "listCard": {
16 + "header": {
17 + "title": "KHU 학사정보 알리미"
18 + },
19 + "items": [
20 + {
21 + "title": "장학금 공지사항",
22 + "description": "챗봇으로 손쉽게 알아보는 학사정보",
23 + "imageUrl": "https://mblogthumb-phinf.pstatic.net/20140716_293/envicontest_1405437648963lV4y4_GIF/University_Seal.gif?type=w2",
24 + "link": {
25 + "web": "https://www.khu.ac.kr/kor/notice/list.do?category=SCHOLARSHIP&page=1"
26 + }
27 + },
28 + {
29 + "title": "공용 소프트웨어 필요할 땐?",
30 + "description": "경희대학교 정보처를 이용해보세요.",
31 + "imageUrl": "https://cdn-icons.flaticon.com/png/128/2888/premium/2888407.png?token=exp=1638455259~hmac=d58c655e0ac8a16809b48323ea83a75f",
32 + "link": {
33 + "web": "https://ois.khu.ac.kr/index.do?sso=ok"
34 + }
35 + },
36 + {
37 + "title": "학사 공지사항",
38 + "description": "학사 일정 공지사항 알아보기",
39 + "imageUrl": "https://cdn-icons.flaticon.com/png/128/3277/premium/3277431.png?token=exp=1638455425~hmac=4fe1afa937ad2ca62e17e25a34aa342e",
40 + "link": {
41 + "web": "https://www.khu.ac.kr/kor/notice/list.do?category=UNDERGRADUATE&page=1"
42 + }
43 + }
44 + ],
45 + "buttons": [
46 + {
47 + "label": "홈페이지 구경가기",
48 + "action": "webLink",
49 + "webLinkUrl": "https://www.khu.ac.kr/kor/main/index.do"
50 + }
51 + ]
52 + }
53 + }
54 + ]
55 + }
56 + }
57 + return haksa_data;
58 +}
...\ No newline at end of file ...\ No newline at end of file
1 +const express = require('express');
2 +const app = express();
3 +
4 +app.use(express.urlencoded({ extended: false }));
5 +app.use(express.json());
6 +var haksik_data;
7 +
8 +module.exports.Seoul = function(haksik_data){
9 + const goMain = '처음으로';
10 +
11 + haksik_data = {
12 + 'version': '2.0',
13 + 'template': {
14 + 'outputs': [{
15 + 'simpleImage': {
16 + 'imageUrl': "https://coop.khu.ac.kr/wp-content/uploads/2021/11/20211129-1301x2048.png",
17 + 'altText' : "서울캠퍼스 식단입니다."
18 + }
19 + }],
20 + 'quickReplies': [{
21 + 'label': goMain,
22 + 'action': 'message',
23 + 'messageText': goMain
24 + }]
25 + }
26 + }
27 + return haksik_data;
28 +}
29 +
30 +module.exports.Global = function(haksik_data){
31 + const goMain = '처음으로';
32 +
33 + haksik_data = {
34 + "version": "2.0",
35 + "template": {
36 + "outputs": [
37 + {
38 + "basicCard": {
39 + "title": "국제캠퍼스 학식",
40 + "description": "오늘의 학식은 무엇일까?!",
41 + "thumbnail": {
42 + "imageUrl": "https://ww.namu.la/s/e38da99cb3bbad5d4a7f19a015fc2a888e01a7c996bb18465f8ba242a21ac5b3d1f2f977094552b00c706aab9c5c7e48dedae0103ed84d8039376458bebeaf0c43c7642b2544a52a016d0633eeab043924071315d41e15ef8df134009508ec03"
43 + },
44 + "profile": {
45 + "imageUrl": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcT4BJ9LU4Ikr_EvZLmijfcjzQKMRCJ2bO3A8SVKNuQ78zu2KOqM",
46 + "nickname": "학식"
47 + },
48 + "social": {
49 + "like": 1238,
50 + "comment": 8,
51 + "share": 780
52 + },
53 + "buttons": [
54 + {
55 + "action": "webLink",
56 + "label": "학식보기",
57 + "webLinkUrl": "https://www.khu.ac.kr/kor/forum/list.do?type=RESTAURANT&category=INTL&page=1"
58 + }
59 + ]
60 + }
61 + }
62 + ]
63 + }
64 + }
65 + return haksik_data;
66 +}
67 +
68 +
69 +