k_process.py
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 | # -*- coding: utf-8 -*- import requests def response(menu): menu = menu.encode('utf-8') w=["학교 날씨"] f=["오늘의 학식"] b=["고양이 버스"] res = {} if menu in w: res = weather(menu) elif menu in f: res = food(menu) elif menu in b: res = bus(menu) else: res = { "message" : {"text" : "이해하지 못함"}, "keyboard" : buttons() } return res def buttons(): data = { "type" : "buttons", "buttons" : [ "학교 날씨", "오늘의 학식", "고양이 버스" ] } return data def weather(menu): data={} f=open("./info/weather",'r') data['message'] = {'text' : f.read()} data['keyboard'] = buttons() f.close() return data def food(menu): data={} f=open("./info/food",'r') data['message']={'text' : f.read()} data['keyboard'] = buttons() f.close() return data def bus(menu): data={} f=open("./info/catbus","r") data['message']={'text':f.read()} data['keyboard']=buttons() f.close() return data | cs |