def library_check_auth(content, renew=False): """检查有无授权,进行查询或续借""" user_library_info = get_user_library_info(openid) if user_library_info: # 解密密码 cipher = AESCipher(app.config["PASSWORD_SECRET_KEY"]) librarypwd = cipher.decrypt(user_library_info["librarypwd"]) library.borrowing_record.delay(openid, user_library_info["libraryid"], librarypwd, renew=renew) return wechat.response_text(content) else: url = app.config["HOST_URL"] + "/auth-library/" + openid content = app.config["AUTH_LIBRARY_TEXT"] % url return wechat.response_text(content)
def exam_grade(): """查询期末成绩""" user_student_info = get_user_student_info(openid) if user_student_info: # 解密密码 cipher = AESCipher(app.config["PASSWORD_SECRET_KEY"]) studentpwd = cipher.decrypt(user_student_info["studentpwd"]) score.get_info.delay(openid, user_student_info["studentid"], studentpwd) return wechat.response_text("查询中……") else: url = app.config["HOST_URL"] + "/auth-score/" + openid content = app.config["AUTH_JW_TEXT"] % url return wechat.response_text(content)
def exam_grade(): """查询期末成绩""" user_student_info = get_user_student_info(openid) if user_student_info: # 解密密码 cipher = AESCipher(app.config['PASSWORD_SECRET_KEY']) studentpwd = cipher.decrypt(user_student_info['studentpwd']) score.get_info.delay(openid, user_student_info['studentid'], studentpwd) return wechat.response_text('查询中……') else: url = app.config['HOST_URL'] + '/auth-score/' + openid content = app.config['AUTH_JW_TEXT'] % url return wechat.response_text(content)
def exam_grade(): """查询期末成绩""" user_student_info = get_user_student_info(openid) if user_student_info: # 解密密码 cipher = AESCipher(app.config['PASSWORD_SECRET_KEY']) studentpwd = cipher.decrypt(user_student_info['studentpwd']) score.get_info.delay(openid, user_student_info['studentid'], studentpwd) return wechat.response_text('查询中……') else: url = app.config['HOST_URL'] + '/auth-score/' + openid content = app.config['AUTH_JW_TEXT'] % url return wechat.response_text(content)
def library_check_auth(content, renew=False): """检查有无授权,进行查询或续借""" user_library_info = get_user_library_info(openid) if user_library_info: # 解密密码 cipher = AESCipher(app.config['PASSWORD_SECRET_KEY']) librarypwd = cipher.decrypt(user_library_info['librarypwd']) library.borrowing_record.delay(openid, user_library_info['libraryid'], librarypwd, renew=renew) return wechat.response_text(content) else: url = app.config['HOST_URL'] + '/auth-library/' + openid content = app.config['AUTH_LIBRARY_TEXT'] % url return wechat.response_text(content)
def daily_sign(): """每日签到""" data = sign.daily_sign(openid) if data: return wechat.response_news(data) else: content = app.config['NOT_SIGN_TIME_TEXT'] return wechat.response_text(content)
def daily_sign(): """每日签到""" data = sign.daily_sign(openid) if data: return wechat.response_news(data) else: content = app.config['NOT_SIGN_TIME_TEXT'] return wechat.response_text(content)
def express_shipment_tracking(): """快递物流查询""" if message.type == "text": timeout = int(message.time) - int(get_user_last_interact_time(openid)) # 超过一段时间,退出模式 if timeout > 15 * 60: set_user_state(openid, "default") content = app.config["COMMAND_NOT_FOUND_TEXT"] + u"\n\n回复 “快递” 进入查询快递模式" + app.config["HELP_TEXT"] return wechat.response_text(content) else: # 放入队列任务执行,异步回复 express.get_tracking_info.delay(openid, message.content) # 立即返回 return "success" else: if message.ScanCodeInfo[0]["ScanType"] == "barcode": # 读取条形码扫描的单号 num = message.ScanCodeInfo[0]["ScanResult"].split(",", 1)[1] # 异步查询 express.get_tracking_info.delay(openid, num) return "success" else: return wechat.response_text("识别错误,请扫描快递条形码")
def express_shipment_tracking(): """快递物流查询""" if message.type == 'text': timeout = int(message.time) - int(get_user_last_interact_time(openid)) # 超过一段时间,退出模式 if timeout > 15 * 60: set_user_state(openid, 'default') content = app.config['COMMAND_NOT_FOUND_TEXT'] + \ u'\n\n回复 “快递” 进入查询快递模式' + app.config['HELP_TEXT'] return wechat.response_text(content) else: # 放入队列任务执行,异步回复 express.get_tracking_info.delay(openid, message.content) # 立即返回 return 'success' else: if message.ScanCodeInfo[0]['ScanType'] == 'barcode': # 读取条形码扫描的单号 num = message.ScanCodeInfo[0]['ScanResult'].split(",", 1)[1] # 异步查询 express.get_tracking_info.delay(openid, num) return 'success' else: return wechat.response_text('识别错误,请扫描快递条形码')
def express_shipment_tracking(): """快递物流查询""" if message.type == 'text': timeout = int(message.time) - int(get_user_last_interact_time(openid)) # 超过一段时间,退出模式 if timeout > 15 * 60: set_user_state(openid, 'default') content = app.config['COMMAND_NOT_FOUND_TEXT'] + \ u'\n\n回复 “快递” 进入查询快递模式' + app.config['HELP_TEXT'] return wechat.response_text(content) else: # 放入队列任务执行,异步回复 express.get_tracking_info.delay(openid, message.content) # 立即返回 return 'success' else: if message.ScanCodeInfo[0]['ScanType'] == 'barcode': # 读取条形码扫描的单号 num = message.ScanCodeInfo[0]['ScanResult'].split(",", 1)[1] # 异步查询 express.get_tracking_info.delay(openid, num) return 'success' else: return wechat.response_text('识别错误,请扫描快递条形码')
def contact_us(): """合作信息""" content = app.config['CONTACT_US_TEXT'] + app.config['HELP_TEXT'] return wechat.response_text(content)
def enter_chat_state(): """进入聊天模式""" set_user_state(openid, 'chat') return wechat.response_text(app.config['ENTER_CHAT_STATE_TEXT'])
def postcard(): """明信片查询""" content = app.config['POSTCARD_TEXT'] + app.config['HELP_TEXT'] return wechat.response_text(content)
def update_menu_setting(): """更新自定义菜单""" try: wechat.create_menu(app.config['MENU_SETTING']) except Exception, e: return wechat.response_text(e)
def enter_express_state(): """进入快递查询模式""" set_user_state(openid, 'express') return wechat.response_text(app.config['ENTER_EXPRESS_STATE_TEXT'])
def enter_express_state(): """进入快递查询模式""" set_user_state(openid, 'express') return wechat.response_text(app.config['ENTER_EXPRESS_STATE_TEXT'])
def enter_chat_state(): """进入聊天模式""" set_user_state(openid, 'chat') return wechat.response_text(app.config['ENTER_CHAT_STATE_TEXT'])
def weather_radar(): """气象雷达动态图""" content = app.config['WEATHER_RADAR_TEXT'] + app.config['HELP_TEXT'] return wechat.response_text(content)
def leave_a_message(): """留言提示""" content = app.config['LEAVE_A_MESSAGE_TEXT'] + app.config['HELP_TEXT'] return wechat.response_text(content)
def contact_us(): """合作信息""" content = app.config['CONTACT_US_TEXT'] + app.config['HELP_TEXT'] return wechat.response_text(content)
def bbs_url(): """论坛网址""" content = app.config['BBS_URL_TXT'] + app.config['HELP_TEXT'] return wechat.response_text(content)
def html5_games(): """HTML5游戏""" content = app.config['HTML5_GAMES_TEXT'] + app.config['HELP_TEXT'] return wechat.response_text(content)
def postcard(): """明信片查询""" content = app.config['POSTCARD_TEXT'] + app.config['HELP_TEXT'] return wechat.response_text(content)
def cet_score(): """回复四六级查询网址""" content = app.config['CET_SCORE_TEXT'] + app.config['HELP_TEXT'] return wechat.response_text(content)
def weather_radar(): """气象雷达动态图""" content = app.config['WEATHER_RADAR_TEXT'] + app.config['HELP_TEXT'] return wechat.response_text(content)
def search_books(): """图书馆找书""" content = app.config['LIBRARY_TEXT'] + app.config['HELP_TEXT'] return wechat.response_text(content)
def command_not_found(): """非关键词回复""" content = app.config['COMMAND_NOT_FOUND_TEXT'] + app.config['HELP_TEXT'] return wechat.response_text(content)
def update_menu_setting(): """更新自定义菜单""" try: wechat.create_menu(app.config['MENU_SETTING']) except Exception, e: return wechat.response_text(e)
def command_not_found(): """非关键词回复""" content = app.config['COMMAND_NOT_FOUND_TEXT'] + app.config['HELP_TEXT'] return wechat.response_text(content)
def cancel_command(): """取消状态""" content = app.config['CANCEL_COMMAND_TEXT'] + app.config['COMMAND_TEXT'] return wechat.response_text(content)
def all_command(): """回复全部指令""" content = app.config['COMMAND_TEXT'] return wechat.response_text(content)
def subscribe(): """回复订阅事件""" content = app.config['WELCOME_TEXT'] + app.config['COMMAND_TEXT'] return wechat.response_text(content)
def auth_url(): """教务系统、图书馆绑定的 URL""" jw_url = app.config['HOST_URL'] + '/auth-score/' + openid library_url = app.config['HOST_URL'] + '/auth-library/' + openid content = app.config['AUTH_TEXT'] % (jw_url, library_url) return wechat.response_text(content)
def phone_number(): """回复电话号码""" content = app.config['PHONE_NUMBER_TEXT'] + app.config['HELP_TEXT'] return wechat.response_text(content)
def developing(): """维护公告""" return wechat.response_text('该功能维护中')
def get_weather_news(): """获取天气预报""" weather.get.delay(openid) return "success" def update_menu_setting(): """更新自定义菜单""" try: wechat.create_menu(app.config["MENU_SETTING"]) except Exception, e: return wechat.response_text(e) else: return wechat.response_text("Done!") def developing(): """维护公告""" return wechat.response_text("该功能维护中") def enter_express_state(): """进入快递查询模式""" set_user_state(openid, "express") return wechat.response_text(app.config["ENTER_EXPRESS_STATE_TEXT"]) def cancel_command(): """取消状态"""
def cancel_command(): """取消状态""" content = app.config['CANCEL_COMMAND_TEXT'] + app.config['COMMAND_TEXT'] return wechat.response_text(content)
def subscribe(): """回复订阅事件""" content = app.config['WELCOME_TEXT'] + app.config['COMMAND_TEXT'] return wechat.response_text(content)
def cet_score(): """回复四六级查询网址""" content = app.config['CET_SCORE_TEXT'] + app.config['HELP_TEXT'] return wechat.response_text(content)
def search_books(): """图书馆找书""" content = app.config['LIBRARY_TEXT'] + app.config['HELP_TEXT'] return wechat.response_text(content)
def html5_games(): """HTML5游戏""" content = app.config['HTML5_GAMES_TEXT'] + app.config['HELP_TEXT'] return wechat.response_text(content)
def auth_url(): """教务系统、图书馆绑定的 URL""" jw_url = app.config['HOST_URL'] + '/auth-score/' + openid library_url = app.config['HOST_URL'] + '/auth-library/' + openid content = app.config['AUTH_TEXT'] % (jw_url, library_url) return wechat.response_text(content)
def bbs_url(): """论坛网址""" content = app.config['BBS_URL_TXT'] + app.config['HELP_TEXT'] return wechat.response_text(content)
def auth_url(): """教务系统、图书馆绑定的 URL""" jw_url = app.config["HOST_URL"] + "/auth-score/" + openid library_url = app.config["HOST_URL"] + "/auth-library/" + openid content = app.config["AUTH_TEXT"] % (jw_url, library_url) return wechat.response_text(content)
def leave_a_message(): """留言提示""" content = app.config['LEAVE_A_MESSAGE_TEXT'] + app.config['HELP_TEXT'] return wechat.response_text(content)
def get_weather_news(): """获取天气预报""" weather.get.delay(openid) return 'success' def update_menu_setting(): """更新自定义菜单""" try: wechat.create_menu(app.config['MENU_SETTING']) except Exception, e: return wechat.response_text(e) else: return wechat.response_text('Done!') def developing(): """维护公告""" return wechat.response_text('该功能维护中') def enter_express_state(): """进入快递查询模式""" set_user_state(openid, 'express') return wechat.response_text(app.config['ENTER_EXPRESS_STATE_TEXT']) def cancel_command(): """取消状态"""
def all_command(): """回复全部指令""" content = app.config['COMMAND_TEXT'] return wechat.response_text(content)
def developing(): """维护公告""" return wechat.response_text('该功能维护中')
def phone_number(): """回复电话号码""" content = app.config['PHONE_NUMBER_TEXT'] + app.config['HELP_TEXT'] return wechat.response_text(content)
def get_weather_news(): """获取天气预报""" weather.get.delay(openid) return 'success' def update_menu_setting(): """更新自定义菜单""" try: wechat.create_menu(app.config['MENU_SETTING']) except Exception, e: return wechat.response_text(e) else: return wechat.response_text('Done!') def developing(): """维护公告""" return wechat.response_text('该功能维护中') def enter_express_state(): """进入快递查询模式""" set_user_state(openid, 'express') return wechat.response_text(app.config['ENTER_EXPRESS_STATE_TEXT']) def cancel_command(): """取消状态"""