Skip to content
This repository has been archived by the owner on Oct 2, 2021. It is now read-only.

Commit

Permalink
2018-05-16
Browse files Browse the repository at this point in the history
  • Loading branch information
alstn2468 committed May 16, 2018
1 parent 21423af commit a6428ac
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 56 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,14 @@ Python과 Django 웹 프레임워크를 사용하여 제작한 자동 응답형
- 버튼 메뉴 세분화 완료

2018/05/14<br/>
- Version [(2.2.1)](https://github.com/alstn2468/SCH_Food_ChatBot/commit/22a2d0cd5613c5398dfb8c6656467389f1acbfbb) New Function Updated / Source Code Modularization<br/>
- Version [(2.2.0)](https://github.com/alstn2468/SCH_Food_ChatBot/commit/22a2d0cd5613c5398dfb8c6656467389f1acbfbb) New Function Updated / Source Code Modularization<br/>
- 학교 Wi-Fi 기능 추가 완료
- 소스 코드 모듈화 완료

2018/05/16<br/>
- Version [(2.3.0)](https://github.com/alstn2468/SCH_Food_ChatBot/commit/22a2d0cd5613c5398dfb8c6656467389f1acbfbb) New Function Updated / Source Code Modularization<br/>
- 식당 이용 시간 확인 기능 추가 완료
- 소스 코드 모듈화 완료

## 친구 추가

Expand Down
6 changes: 6 additions & 0 deletions app/my_module/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
'개발자 정보'
]

food_info_button = [
'메뉴',
'이용 시간',
'처음으로'
]

food_sel_process_button = [
'향설1 생활관',
'향설2 생활관',
Expand Down
53 changes: 53 additions & 0 deletions app/my_module/process.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
from django.http import JsonResponse
from app.my_module.button import *
import requests

# 결과를 출력하고 다시 입력을 받기 위한 함수
def re_process(output) :

return JsonResponse (
{
'message':
{
'text': output
},
'keyboard':
{
'type': 'buttons',
'buttons' : basic_button
}
}
)

# 학식 버튼을 눌렀을 때 세부 버튼을 받기 위한 함수
def food_sel_process() :

return JsonResponse (
{
'message' :
{
'text' : '어느 곳의 메뉴가 궁금하신가요?'
},
'keyboard' :
{
'type' : 'buttons',
'buttons' : food_sel_process_button
}
}
)

def food_info_process() :

return JsonResponse (
{
'message' :
{
'text' : '[확인할 수 있는 정보]\n· 메뉴\n· 이용 시간'
},
'keyboard' :
{
'type' : 'buttons',
'buttons' : food_info_button
}
}
)
9 changes: 9 additions & 0 deletions app/my_module/repdic.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,12 @@
'\n·\n' : '\n\n',
'·' : '· '
}

# 데이터를 보기 좋게 출력하기 위한 문자열 처리 함수
def char_replace(meal) :

for key, value in trans_dic.items() :

meal = meal.replace(key, value)

return meal
16 changes: 16 additions & 0 deletions app/my_module/stringformat.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,19 @@

# 심각한 오류
fatal_error = '[*] 심각한 오류입니다.\n[*] 개발자에게 알려주세요'

# 이용 가능 시간
using_time = '''
[향설1 생활관]
[향설2 생활관]
[향설3 생활관]
[학생회관]
[교직원 식당]'''

# 개발자 정보 메세지
dev_info = '''[*] 컴퓨터소프트웨어공학과
[*] 17학번 김민수
[*] Github : alstn2468
[*] KakaoTalk : alstn2468
[*] 새로운 기능 문의 환영
[*] 에러 발견 문의 환영'''
70 changes: 15 additions & 55 deletions app/views.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from django.shortcuts import render
from django.http import JsonResponse
from django.views.decorators.csrf import csrf_exempt
from app.my_module.button import *
from app.my_module.repdic import *
from app.my_module.scheduleparser import *
from app.my_module.stringformat import *
from app.my_module.process import *
from app.my_module.button import *
from pytz import timezone
import requests, datetime, json

Expand All @@ -15,63 +16,12 @@
# menu/StudentUnion.json 학생 회관
# menu/FacultyRestaurant.json 교직원 식당

# 개발자 정보 메세지
dev_info = '''[*] 컴퓨터소프트웨어공학과
[*] 17학번 김민수
[*] Github : alstn2468
[*] KakaoTalk : alstn2468
[*] 새로운 기능 문의 환영
[*] 에러 발견 문의 환영'''

# 데이터를 보기 좋게 출력하기 위한 문자열 처리 함수
def char_replace(meal) :

for key, value in trans_dic.items() :

meal = meal.replace(key, value)

return meal

# 결과를 출력하고 다시 입력을 받기 위한 함수
def re_process(output) :

return JsonResponse (
{
'message':
{
'text': output
},
'keyboard':
{
'type': 'buttons',
'buttons' : basic_button
}
}
)

# 학식 버튼을 눌렀을 때 세부 버튼을 받기 위한 함수
def food_sel_process() :

return JsonResponse (
{
'message' :
{
'text' : '어느 곳의 메뉴가 궁금하신가요?'
},
'keyboard' :
{
'type' : 'buttons',
'buttons' : food_sel_process_button
}
}
)

def keyboard(request) :

return JsonResponse (
{
'type' : 'buttons',
'buttons' : basic_button
'type' : 'buttons',
'buttons' : basic_button
}
)

Expand All @@ -90,8 +40,19 @@ def answer(request) :
today_weekday = today.weekday()

if content_name == '학식' :

return food_info_process()

elif content_name == '메뉴' :

return food_sel_process()

elif content_name == '이용 시간' :

send_message = select_else_button.format(content_name) + using_time

return re_process(send_message)

elif content_name == '향설1 생활관' :

try :
Expand Down Expand Up @@ -279,7 +240,6 @@ def answer(request) :
finish_info = finish.strftime('%Y년 %m월 %d일')
date_dif = finish - today


send_message = select_else_button.format(content_name) + end_day.format(today_info, finish_info, date_dif.days)

except Exception as e :
Expand Down

0 comments on commit a6428ac

Please sign in to comment.