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