예제 #1
0
def get_timetable(text):
    neis = neispy.SyncClient(force=True)

    AE = "B10"  # 교육청 코드
    SE = 7010536  # 학교 코드

    YMD = get_ymd(text)

    try:
        grade_idx = text.index("학년") - 1
        class_idx = text.index("반") - 1
        grade_no = int(text[grade_idx])
        class_no = int(text[class_idx])
    except Exception as e:
        print(f'exception! {e}')
        return "학년 반 정보를 제대로 입력해주세요!"

    try:
        if YMD:
            timetable_info = neis.timeTable(schclass='his',
                                            ATPT_OFCDC_SC_CODE=AE,
                                            SD_SCHUL_CODE=SE,
                                            ALL_TI_YMD=YMD,
                                            GRADE=grade_no,
                                            CLRM_NM=class_no)
        else:
            timetable_info = neis.timeTable(schclass='his',
                                            ATPT_OFCDC_SC_CODE=AE,
                                            SD_SCHUL_CODE=SE,
                                            GRADE=grade_no,
                                            CLRM_NM=class_no)

        timetable = [i['ITRT_CNTNT'] for i in timetable_info.data]

        result = ''

        for index, item in enumerate(timetable):
            result += f'{index+1}교시 - {item}\n'

        return result
    except Exception as e:
        print(f'exception! {e}')
        return "해당 날짜의 시간표 정보가 없어요 ㅠㅠ"
예제 #2
0
def get_schedule(text):
    neis = neispy.SyncClient(force=True)

    AE = "B10"  # 교육청 코드
    SE = 7010536  # 학교 코드

    YMD = get_ymd(text)

    try:
        schedule_info = neis.SchoolSchedule(ATPT_OFCDC_SC_CODE=AE,
                                            SD_SCHUL_CODE=SE,
                                            AA_YMD=YMD)

        schedule = schedule_info.EVENT_NM

        return schedule

    except Exception as e:
        print(f'exception! {e}')
        return "해당 날짜의 학사일정 정보가 없어요 ㅠㅠ"
예제 #3
0
def get_meal(text):
    neis = neispy.SyncClient(force=True)

    AE = "B10"  # 교육청 코드
    SE = 7010536  # 학교 코드

    YMD = get_ymd(text)

    try:
        meal_info = neis.mealServiceDietInfo(ATPT_OFCDC_SC_CODE=AE,
                                             SD_SCHUL_CODE=SE,
                                             MLSV_YMD=YMD)

        meal = meal_info.DDISH_NM.replace('<br/>', '\n')

        return meal

    except Exception as e:
        print(f'exception! {e}')
        return "해당 날짜의 급식정보가 없어요 ㅠㅠ"
예제 #4
0
load_dotenv(verbose=True)

parser = argparse.ArgumentParser(description='Sunrinbot based on KoGPT-2')
parser.add_argument('--model_params', type=str, default='model_chp/model_last.ckpt')
args = parser.parse_args()

app = Flask(__name__)

ACCESS_TOKEN = os.getenv('ACCESS_TOKEN')
VERIFY_TOKEN = os.getenv('VERIFY_TOKEN')
bot = Bot(ACCESS_TOKEN)

SCHOOL_NAME = "선린인터넷고등학교"

neis = neispy.SyncClient(force=True)

AE = "B10" # 교육청 코드
SE = 7010536 # 학교 코드

model = KoGPT2Chat.load_from_checkpoint(args.model_params)

@app.route('/', methods=['GET', 'POST'])
def chat():
  res = ""
  if request.method == 'GET':
    token_sent = request.args.get('hub.verify_token')
    return vertify_token(token_sent)
  else:
    output = request.get_json()
    for event in output['entry']: