이종규
Committed by EC2 Default User

Final_Update

1 +const express = require('express');
2 +const fs = require('fs');
3 +const path = require('path');
4 +const HTTPS = require('https');
5 +const domain = "2020105107.osschatbot.cf"
6 +const sslport = 23023;
7 +const app = express();
8 +
9 +app.use(express.urlencoded({ extended: false }));
10 +app.use(express.json());
11 +
12 +var club = require('./club');
13 +var haksik = require('./haksik');
14 +var haksa = require('./haksa');
15 +
16 +app.post('/message', (req, res) => {
17 + const question = req.body.userRequest.utterance;
18 + const goMain = '처음으로';
19 + var data;
20 +
21 + // 학사정보 간편보기
22 + if(question == "간편하게 보는 학사정보"){
23 + data = haksa.Haksa_Information(data);
24 + }
25 +
26 + //동아리 정보 보기 - 서울캠 공연
27 + if(question== "바운스" || question == "bounce"){
28 + data = club.Bounce(data);
29 + }else if(question == "GLEE" || question == "glee"){
30 + data = club.GLEE(data);
31 + }else if(question == "MDOP" || question == "mdop"){
32 + data = club.MDOP(data);
33 + }else if(question == "NAKED" || question == "네이키드"){
34 + data = club.NAKED(data);
35 + }else if(question == "경희극장"){
36 + data = club.Khutheatre(data);
37 + }else if(question == "노래여울"){
38 + data = club.Noraeyeoul(data);
39 + }else if(question == "발광"){
40 + data = club.Balgwang(data);
41 + }else if(question == "발라드림"){
42 + data = club.Balladream(data);
43 + }else if(question == "칸타빌레"){
44 + data = club.Cantabile(data);
45 + }
46 +
47 + //동아리 정보 보기 - 서울캠 학술
48 + if(question == "ABS" || question == "abs"){
49 + data = club.ABS(data);
50 + }else if(question == "ACE" || question == "ace"){
51 + data = club.ACE(data);
52 + }else if(question == "IDS" || question == "ids"){
53 + data = club.IDS(data);
54 + }else if(question == "SEN경희" || question == "sen경희"){
55 + data = club.SENkh(data);
56 + }else if(question == "UNSA" || question == "unsa"){
57 + data = club.UNSA(data);
58 + }else if(question == "이감"){
59 + data = club.Egam(data);
60 + }
61 +
62 + //동아리 정보 보기 - 서울캠 봉사
63 + if(question == "miraKHle" || question == "mirakhle"){
64 + data = club.miraKHle(data);
65 + }else if(question == "PTPI" || question == "ptpi"){
66 + data = club.PTPI(data);
67 + }else if(question == "바인"){
68 + data = club.VINE(data);
69 + }
70 +
71 + //동아리 정보 보기 - 서울캠 체육
72 + if(question == "BRAVES" || question == "braves"){
73 + data = club.BRAVES(data);
74 + }else if(question == "ESpers" || question == "espers"){
75 + data = club.ESpers(data);
76 + }else if(question == "FAKIE" || question == "fakie"){
77 + data = club.FAKIE(data);
78 + }else if(question == "KUTA" || question == "kuta"){
79 + data = club.KUTA(data);
80 + }else if(question == "WBA" || question == "wba"){
81 + data = club.WBA(data);
82 + }else if(question == "검도부"){
83 + data = club.KENDO(data);
84 + }else if(question == "경희랑달리기"){
85 + data = club.Running_with_kyunghee(data);
86 + }else if(question == "산악부"){
87 + data = club.Alpine(data);
88 + }else if(question == "스키부"){
89 + data = club.SKI(data);
90 + }else if(question == "유혼"){
91 + data = club.JUDO(data);
92 + }else if(question == "태권도부"){
93 + data = club.TKD(data);
94 + }
95 +
96 + //동아리 정보 보기 - 서울캠 종교
97 + if(question == "CCC" || question == "ccc"){
98 + data = club.CCC(data);
99 + }else if(question == "IVF" || question == "ivf"){
100 + data = club.IVF(data);
101 + }else if(question == "JOY" || question == "joy"){
102 + data = club.JOY(data);
103 + }else if(question == "SFC" || question == "sfc"){
104 + data = club.SFC(data);
105 + }else if(question == "경불회"){
106 + data = club.Buddha(data);
107 + }else if(question == "네비게이토"){
108 + data = club.Navigators(data);
109 + }else if(question == "경희기독교연합동아리"){
110 + data = club.CCC_agape(data);
111 + }
112 +
113 + //동아리 정보 보기 - 서울캠 취미, 교양
114 + if(question == "PLANET-X" || question == "planet-x"){
115 + data = club.PLANET_X(data);
116 + }else if(question == "SENET" || question == "senet"){
117 + data = club.SENET(data);
118 + }else if(question == "유스호스텔"){
119 + data = club.YH(data);
120 + }
121 +
122 + //동아리 정보 보기 -서울캠 전시, 창작
123 + if(question == "KHPC" || question == "khpc"){
124 + data = club.KHPC(data);
125 + }else if(question == "경희서도회"){
126 + data = club.Groups_kh(data);
127 + }else if(question == "그림자 놀이" || question == "그림자놀이"){
128 + data = club.ShadowPlay(data);
129 + }else if(question == "문맥"){
130 + data = club.Munmaek(data);
131 + }else if(question == "카피울림"){
132 + data = club.CopyWoolim(data);
133 + }
134 +
135 + //학식
136 + if (question == "서울캠퍼스") {
137 + data = haksik.Seoul(data);
138 + }else if (question == "국제캠퍼스") {
139 + data = haksik.Global(data);
140 + }
141 +
142 +
143 + res.json(data);
144 +});
145 +
146 +try {
147 + const option = {
148 + ca: fs.readFileSync('/etc/letsencrypt/live/' + domain +'/fullchain.pem'),
149 + key: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + domain +'/privkey.pem'), 'utf8').toString(),
150 + cert: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + domain +'/cert.pem'), 'utf8').toString(),
151 + };
152 +
153 + HTTPS.createServer(option, app).listen(sslport, () => {
154 + console.log(`[HTTPS] Server is started on port ${sslport}`);
155 + });
156 +} catch (error) {
157 + console.log('[HTTPS] HTTPS 오류가 발생하였습니다. HTTPS 서버는 실행되지 않습니다.');
158 + console.log(error);
159 +}
This diff is collapsed. Click to expand it.
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 +
This diff could not be displayed because it is too large.
1 +{
2 + "name": "project",
3 + "version": "1.0.0",
4 + "description": "",
5 + "main": "app.js",
6 + "scripts": {
7 + "test": "echo \"Error: no test specified\" && exit 1"
8 + },
9 + "keywords": [],
10 + "author": "이종규",
11 + "license": "ISC",
12 + "dependencies": {
13 + "axios": "^0.24.0",
14 + "cheerio": "^1.0.0-rc.10",
15 + "express": "^4.17.1",
16 + "pm2": "^5.1.2"
17 + }
18 +}