diff --git a/src/dao.py b/src/dao.py index 466f95e..4f51364 100644 --- a/src/dao.py +++ b/src/dao.py @@ -107,7 +107,7 @@ def fetch_all_menu() -> Generator[tuple[str, str, str], None, None]: db.close() -def fetch_roll_result() -> str|None: +def fetch_roll_result() -> str | None: """ 获取N天前的抽签结果 :return: 抽签结果 @@ -118,7 +118,7 @@ def fetch_roll_result() -> str|None: cursor = db.cursor() try: cursor.execute("select value from roll_result where datestr=?", - (datestr, )) + (datestr,)) row = cursor.fetchone() if row is not None: return row[0] diff --git a/src/dinner.py b/src/dinner.py index b81ce4f..0d8adac 100644 --- a/src/dinner.py +++ b/src/dinner.py @@ -55,6 +55,7 @@ def vote_reduce(summary: dict[str, float], limit: int = 2) -> tuple[dict[str, fl """ 按规则对投票结果进行修饰 :param summary: 投票汇总结果 + :param limit: 降低最近N次点餐结果概率 :return: 投票汇总结果 """ last_results = list(fetch_roll_result_list(-1, limit)) diff --git a/src/utils.py b/src/utils.py index 0b5aca5..6d47a93 100644 --- a/src/utils.py +++ b/src/utils.py @@ -3,10 +3,10 @@ from configparser import ConfigParser from flask import request - config = ConfigParser() config.read('./config.ini') + def is_mobile_request(user_agent: str) -> bool: """ 判断是否是移动端 @@ -16,6 +16,7 @@ def is_mobile_request(user_agent: str) -> bool: ua_expression = config.get('Settings', 'UA_EXPRESSION') return bool(eval(ua_expression, {"user_agent": user_agent, "re": re})) + def get_user() -> str: """ 根据访问IP决定用户ID