이종규
Committed by EC2 Default User

Final_Update

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());
var club = require('./club');
var haksik = require('./haksik');
var haksa = require('./haksa');
app.post('/message', (req, res) => {
const question = req.body.userRequest.utterance;
const goMain = '처음으로';
var data;
// 학사정보 간편보기
if(question == "간편하게 보는 학사정보"){
data = haksa.Haksa_Information(data);
}
//동아리 정보 보기 - 서울캠 공연
if(question== "바운스" || question == "bounce"){
data = club.Bounce(data);
}else if(question == "GLEE" || question == "glee"){
data = club.GLEE(data);
}else if(question == "MDOP" || question == "mdop"){
data = club.MDOP(data);
}else if(question == "NAKED" || question == "네이키드"){
data = club.NAKED(data);
}else if(question == "경희극장"){
data = club.Khutheatre(data);
}else if(question == "노래여울"){
data = club.Noraeyeoul(data);
}else if(question == "발광"){
data = club.Balgwang(data);
}else if(question == "발라드림"){
data = club.Balladream(data);
}else if(question == "칸타빌레"){
data = club.Cantabile(data);
}
//동아리 정보 보기 - 서울캠 학술
if(question == "ABS" || question == "abs"){
data = club.ABS(data);
}else if(question == "ACE" || question == "ace"){
data = club.ACE(data);
}else if(question == "IDS" || question == "ids"){
data = club.IDS(data);
}else if(question == "SEN경희" || question == "sen경희"){
data = club.SENkh(data);
}else if(question == "UNSA" || question == "unsa"){
data = club.UNSA(data);
}else if(question == "이감"){
data = club.Egam(data);
}
//동아리 정보 보기 - 서울캠 봉사
if(question == "miraKHle" || question == "mirakhle"){
data = club.miraKHle(data);
}else if(question == "PTPI" || question == "ptpi"){
data = club.PTPI(data);
}else if(question == "바인"){
data = club.VINE(data);
}
//동아리 정보 보기 - 서울캠 체육
if(question == "BRAVES" || question == "braves"){
data = club.BRAVES(data);
}else if(question == "ESpers" || question == "espers"){
data = club.ESpers(data);
}else if(question == "FAKIE" || question == "fakie"){
data = club.FAKIE(data);
}else if(question == "KUTA" || question == "kuta"){
data = club.KUTA(data);
}else if(question == "WBA" || question == "wba"){
data = club.WBA(data);
}else if(question == "검도부"){
data = club.KENDO(data);
}else if(question == "경희랑달리기"){
data = club.Running_with_kyunghee(data);
}else if(question == "산악부"){
data = club.Alpine(data);
}else if(question == "스키부"){
data = club.SKI(data);
}else if(question == "유혼"){
data = club.JUDO(data);
}else if(question == "태권도부"){
data = club.TKD(data);
}
//동아리 정보 보기 - 서울캠 종교
if(question == "CCC" || question == "ccc"){
data = club.CCC(data);
}else if(question == "IVF" || question == "ivf"){
data = club.IVF(data);
}else if(question == "JOY" || question == "joy"){
data = club.JOY(data);
}else if(question == "SFC" || question == "sfc"){
data = club.SFC(data);
}else if(question == "경불회"){
data = club.Buddha(data);
}else if(question == "네비게이토"){
data = club.Navigators(data);
}else if(question == "경희기독교연합동아리"){
data = club.CCC_agape(data);
}
//동아리 정보 보기 - 서울캠 취미, 교양
if(question == "PLANET-X" || question == "planet-x"){
data = club.PLANET_X(data);
}else if(question == "SENET" || question == "senet"){
data = club.SENET(data);
}else if(question == "유스호스텔"){
data = club.YH(data);
}
//동아리 정보 보기 -서울캠 전시, 창작
if(question == "KHPC" || question == "khpc"){
data = club.KHPC(data);
}else if(question == "경희서도회"){
data = club.Groups_kh(data);
}else if(question == "그림자 놀이" || question == "그림자놀이"){
data = club.ShadowPlay(data);
}else if(question == "문맥"){
data = club.Munmaek(data);
}else if(question == "카피울림"){
data = club.CopyWoolim(data);
}
//학식
if (question == "서울캠퍼스") {
data = haksik.Seoul(data);
}else if (question == "국제캠퍼스") {
data = haksik.Global(data);
}
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);
}
This diff is collapsed. Click to expand it.
const express = require('express');
const app = express();
app.use(express.urlencoded({ extended: false }));
app.use(express.json());
var haksa_data;
//학사정보 간편보기
module.exports.Haksa_Information = function(haksa_data){
haksa_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"
}
]
}
}
]
}
}
return haksa_data;
}
\ No newline at end of file
const express = require('express');
const app = express();
app.use(express.urlencoded({ extended: false }));
app.use(express.json());
var haksik_data;
module.exports.Seoul = function(haksik_data){
const goMain = '처음으로';
haksik_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
}]
}
}
return haksik_data;
}
module.exports.Global = function(haksik_data){
const goMain = '처음으로';
haksik_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"
}
]
}
}
]
}
}
return haksik_data;
}
This diff could not be displayed because it is too large.
{
"name": "project",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "이종규",
"license": "ISC",
"dependencies": {
"axios": "^0.24.0",
"cheerio": "^1.0.0-rc.10",
"express": "^4.17.1",
"pm2": "^5.1.2"
}
}