diff --git a/README.md b/README.md index e72dc67d..2186ef24 100644 --- a/README.md +++ b/README.md @@ -252,6 +252,8 @@ PS: **ARM平台** 请使用全量版 同时 **如果你的机器 RAM < 1G 可能 ### 感谢名单 (可以告诉我你的 __github__ 地址,我偷偷换掉0v|) +[腊条](https://afdian.net/u/f739c4d69eca11eba94b52540025c377) +[ze roller](https://afdian.net/u/0e599e96257211ed805152540025c377) [爱发电用户_4jrf](https://afdian.net/u/6b2cdcc817c611ed949152540025c377) [爱发电用户_TBsd](https://afdian.net/u/db638b60217911ed9efd52540025c377) [烟寒若雨](https://afdian.net/u/067bd2161eec11eda62b52540025c377) @@ -277,6 +279,24 @@ PS: **ARM平台** 请使用全量版 同时 **如果你的机器 RAM < 1G 可能 ## 更新 +### 2022/9/3 + +* 原神玩家查询增加须弥地区 [@pull/1053](https://github.com/HibiKier/zhenxun_bot/pull/1053) +* 修复词条含有CQ回答的模糊匹配无法被解析 + +### 2022/8/27 + +* 修复签到积分双倍后,日志记录获得积分变4倍问题 [@pull/1044](https://github.com/HibiKier/zhenxun_bot/pull/1044) + +### 2022/8/26 + +* 修复群管理员无法添加词条 +* 修复词条关键词"问"前空格问题 + +### 2022/8/23 + +* 修了下模糊匹配 issue#1026 [@pull/1026](https://github.com/HibiKier/zhenxun_bot/pull/1026) + ### 2022/8/22 * 修复首次安装时词条旧表出错(因为根本就没有这张表!) diff --git a/plugins/genshin/query_user/query_role/data_source.py b/plugins/genshin/query_user/query_role/data_source.py index 1aa5ad20..01b6fb70 100644 --- a/plugins/genshin/query_user/query_role/data_source.py +++ b/plugins/genshin/query_user/query_role/data_source.py @@ -195,6 +195,7 @@ def parsed_data( "magic_chest_number": data["stats"]["magic_chest_number"], # 奇馈宝箱 "common_chest_number": data["stats"]["common_chest_number"], # 普通宝箱 "electroculus_number": data["stats"]["electroculus_number"], # 雷神瞳已收集 + "dendroculus_number": data["stats"]["dendroculus_number"], # 草神瞳已收集 } world_data_dict = {} for world in data["world_explorations"]: diff --git a/plugins/genshin/query_user/query_role/draw_image.py b/plugins/genshin/query_user/query_role/draw_image.py index 31a3d07b..6bea3866 100644 --- a/plugins/genshin/query_user/query_role/draw_image.py +++ b/plugins/genshin/query_user/query_role/draw_image.py @@ -129,7 +129,7 @@ def get_user_data_image( """ if mys_data: nickname = [x["nickname"] for x in mys_data if x["game_id"] == 2][0] - region = BuildImage(1440, 450, color="#E3DBD1", font="HYWenHei-85W.ttf") + region = BuildImage(1440, 560, color="#E3DBD1", font="HYWenHei-85W.ttf") region.circle_corner(30) uname_img = BuildImage( 0, @@ -163,36 +163,42 @@ def get_user_data_image( / random.choice(os.listdir(image_path / "chars_ava")), ) ava_bk.paste(ava_img, (12, 16), alpha=True) - region.paste(uname_img, (int(170 + uid_img.w / 2 - uname_img.w / 2), 305), True) - region.paste(uid_img, (170, 355), True) - region.paste(ava_bk, (int(550 / 2 - ava_bk.w / 2), 40), True) + region.paste(uname_img, (int(170 + uid_img.w / 2 - uname_img.w / 2), 365), True) + region.paste(uid_img, (170, 415), True) + region.paste(ava_bk, (int(550 / 2 - ava_bk.w / 2), 100), True) data_img = BuildImage( - 800, 400, color="#E3DBD1", font="HYWenHei-85W.ttf", font_size=40 + 800, 510, color="#E3DBD1", font="HYWenHei-85W.ttf", font_size=40 ) _height = 0 keys = [ - ["活跃天数", "成就达成", "获得角色", "深境螺旋"], - ["华丽宝箱", "珍贵宝箱", "精致宝箱", "普通宝箱"], - ["奇馈宝箱", "风神瞳", "岩神瞳", "雷神瞳"], + ["活跃天数", "成就达成", "获得角色", "解锁传送"], + ["风神瞳", "岩神瞳", "雷神瞳", "草神瞳"], + ["解锁秘境", "深境螺旋", "华丽宝箱", "珍贵宝箱"], + ["精致宝箱", "普通宝箱", "奇馈宝箱",], ] values = [ [ role_data["active_day_number"], role_data["achievement_number"], role_data["avatar_number"], - role_data["spiral_abyss"], + role_data["way_point_number"], ], [ - role_data["luxurious_chest_number"], - role_data["precious_chest_number"], - role_data["exquisite_chest_number"], - role_data["common_chest_number"], - ], - [ - role_data["magic_chest_number"], role_data["anemoculus_number"], role_data["geoculus_number"], role_data["electroculus_number"], + role_data["dendroculus_number"], + ], + [ + role_data["domain_number"], + role_data["spiral_abyss"], + role_data["luxurious_chest_number"], + role_data["precious_chest_number"], + ], + [ + role_data["exquisite_chest_number"], + role_data["common_chest_number"], + role_data["magic_chest_number"], ], ] for key, value in zip(keys, values): @@ -215,7 +221,7 @@ def get_user_data_image( ) tmp_.text((0, 0), str(v), center_type="by_width") tmp_.paste(t_, (0, 50), True, "by_width") - _tmp_data_img.paste(tmp_, (_width if len(key) > 3 else _width + 15, 0)) + _tmp_data_img.paste(tmp_, ((_width + 15) if keys.index(key) == 1 else _width, 0)) _width += 200 data_img.paste(_tmp_data_img, (0, _height)) _height += _tmp_data_img.h - 70 @@ -228,7 +234,7 @@ def get_home_data_image(home_data_list: List[Dict]) -> BuildImage: 画出家园数据 :param home_data_list: 家园列表 """ - h = 130 + 300 * 4 + h = 130 + 340 * 4 region = BuildImage( 550, h, color="#E3DBD1", font="HYWenHei-85W.ttf", font_size=40 ) @@ -287,7 +293,7 @@ def get_home_data_image(home_data_list: List[Dict]) -> BuildImage: x.paste(black_img, alpha=True, center_type="center") x.circle_corner(50) region.paste(x, (0, height), True, "by_width") - height += 300 + height += 340 return region @@ -299,7 +305,7 @@ def get_country_data_image(world_data_dict: Dict) -> BuildImage: # 层岩巨渊 和 地下矿区 算一个 region = BuildImage(790, 267 * (len(world_data_dict) - 1), color="#F9F6F2") height = 0 - for country in ["蒙德", "龙脊雪山", "璃月", "层岩巨渊", "稻妻", "渊下宫"]: + for country in ["蒙德", "龙脊雪山", "璃月", "层岩巨渊", "稻妻", "渊下宫", "须弥"]: if not world_data_dict.get(country): continue x = BuildImage(790, 250, color="#3A4467") @@ -311,15 +317,15 @@ def get_country_data_image(world_data_dict: Dict) -> BuildImage: ) content_bk.paste(logo, (50, 0), True, "by_height") if country in ["蒙德", "璃月"]: - content_bk.text((300, 40), "探索", fill=(239, 211, 114)) + content_bk.text((300, 40), "蒙德探索" if country == "蒙德" else "璃月探索", fill=(239, 211, 114)) content_bk.text( - (450, 40), + (500, 40), f"{world_data_dict[country]['exploration_percentage'] / 10}%", fill=(255, 255, 255), ) - content_bk.text((300, 120), "声望", fill=(239, 211, 114)) + content_bk.text((300, 120), "蒙德声望" if country == "蒙德" else "璃月声望", fill=(239, 211, 114)) content_bk.text( - (450, 120), + (500, 120), f"Lv.{world_data_dict[country]['level']}", fill=(255, 255, 255), ) @@ -344,45 +350,65 @@ def get_country_data_image(world_data_dict: Dict) -> BuildImage: fill=(255, 255, 255), ) elif country in ["龙脊雪山"]: - content_bk.text((300, 40), "探索", fill=(239, 211, 114)) + content_bk.text((300, 40), "雪山探索", fill=(239, 211, 114)) content_bk.text( - (450, 40), + (500, 40), f"{world_data_dict[country]['exploration_percentage'] / 10}%", fill=(255, 255, 255), ) - content_bk.text((300, 120), "供奉", fill=(239, 211, 114)) + content_bk.text((300, 120), "忍冬之树", fill=(239, 211, 114)) content_bk.text( - (450, 120), + (500, 120), f"Lv.{world_data_dict[country]['offerings'][0]['level']}", fill=(255, 255, 255), ) elif country in ["稻妻"]: - content_bk.text((300, 20), "探索", fill=(239, 211, 114)) + content_bk.text((300, 20), "稻妻探索", fill=(239, 211, 114)) content_bk.text( - (450, 20), + (500, 20), f"{world_data_dict[country]['exploration_percentage'] / 10}%", fill=(255, 255, 255), ) - content_bk.text((300, 85), "声望", fill=(239, 211, 114)) + content_bk.text((300, 85), "稻妻声望", fill=(239, 211, 114)) content_bk.text( - (450, 85), + (500, 85), f"Lv.{world_data_dict[country]['level']}", fill=(255, 255, 255), ) - content_bk.text((300, 150), "神樱", fill=(239, 211, 114)) + content_bk.text((300, 150), "神樱眷顾", fill=(239, 211, 114)) content_bk.text( - (450, 150), + (500, 150), f"Lv.{world_data_dict[country]['offerings'][0]['level']}", fill=(255, 255, 255), ) elif country in ["渊下宫"]: - content_bk.text((300, 0), "探索", fill=(239, 211, 114), center_type="by_height") + content_bk.text((300, 0), "渊下宫探索", fill=(239, 211, 114), center_type="by_height") content_bk.text( - (450, 20), + (530, 20), f"{world_data_dict[country]['exploration_percentage'] / 10}%", fill=(255, 255, 255), center_type="by_height", ) + elif country in ["须弥"]: + content_bk.text((300, 20), "须弥探索", fill=(239, 211, 114)) + content_bk.text( + (500, 20), + f"{world_data_dict[country]['exploration_percentage'] / 10}%", + fill=(255, 255, 255), + ) + content_bk.text((300, 85), "须弥声望", fill=(239, 211, 114)) + content_bk.text( + (500, 85), + f"Lv.{world_data_dict[country]['level']}", + fill=(255, 255, 255), + ) + content_bk.text((300, 150), "梦之树", fill=(239, 211, 114)) + content_bk.text( + (500, 150), + f"Lv.{world_data_dict[country]['offerings'][0]['level']}", + fill=(255, 255, 255), + ) + x.paste(tmp_bk, alpha=True, center_type="center") x.paste(content_bk, alpha=True, center_type="center") x.circle_corner(20) diff --git a/plugins/sign_in/group_user_checkin.py b/plugins/sign_in/group_user_checkin.py index 52ec4c6f..87174d34 100755 --- a/plugins/sign_in/group_user_checkin.py +++ b/plugins/sign_in/group_user_checkin.py @@ -81,19 +81,15 @@ async def _handle_check_in( await BagUser.add_gold(user_qq, group, gold) await BagUser.add_property(user_qq, group, gift) gift += ' + 1' + + logger.info( + f"(USER {user.user_qq}, GROUP {user.group_id})" + f" CHECKED IN successfully. score: {user.impression:.2f} " + f"(+{impression_added:.2f}).获取金币:{gold + gift if gift == 'gold' else gold}" + ) if critx2 + add_probability > 0.97 or critx2 < specify_probability: - logger.info( - f"(USER {user.user_qq}, GROUP {user.group_id})" - f" CHECKED IN successfully. score: {user.impression:.2f} " - f"(+{impression_added * 2:.2f}).获取金币:{gold + gift if gift == 'gold' else gold}" - ) return await get_card(user, nickname, impression_added, gold, gift, True) else: - logger.info( - f"(USER {user.user_qq}, GROUP {user.group_id})" - f" CHECKED IN successfully. score: {user.impression:.2f} " - f"(+{impression_added:.2f}).获取金币:{gold + gift if gift == 'gold' else gold}" - ) return await get_card(user, nickname, impression_added, gold, gift) diff --git a/plugins/word_bank/_model.py b/plugins/word_bank/_model.py index 2eec7b00..2e6557be 100644 --- a/plugins/word_bank/_model.py +++ b/plugins/word_bank/_model.py @@ -237,12 +237,21 @@ class WordBank(db.Model): if await query.where( ((cls.word_type == 0) | (cls.word_type == 3)) & (cls.problem == problem) ).gino.first(): - return query.where(cls.problem == problem) + return query.where( + ((cls.word_type == 0) | (cls.word_type == 3)) & (cls.problem == problem) + ) # 模糊匹配 - if await query.where( - (cls.word_type == 1) & (cls.problem.contains(problem)) - ).gino.first(): - return query.where(cls.problem.contains(problem)) + if await db.first( + db.text( + sql_text + + f" and word_type = 1 and :problem like '%' || problem || '%';" + ), + problem=problem, + ): + return ( + sql_text + + f" and word_type = 1 and :problem like '%' || problem || '%';" + ) # 正则匹配 if await db.first( db.text( @@ -253,7 +262,7 @@ class WordBank(db.Model): ): return ( sql_text - + f" and word_type = 2 and word_scope != 999 and '{problem}' ~ problem;" + + f" and word_type = 2 and word_scope != 999 and :problem ~ problem;" ) # if await db.first( # db.text(sql_text + f" and word_type = 1 and word_scope != 999 and '{problem}' ~ problem;") @@ -281,10 +290,10 @@ class WordBank(db.Model): query = await cls.check(event, problem, word_scope, word_type) if query is not None: if isinstance(query, str): - answer_list = await db.all(db.text(query)) + answer_list = await db.all(db.text(query), problem=problem) answer = random.choice(answer_list) return ( - await cls._format2answer(problem, answer[7], answer[1], answer[2]) + await cls._format2answer(answer[6], answer[7], answer[1], answer[2]) if answer.placeholder else answer.answer ) diff --git a/plugins/word_bank/_rule.py b/plugins/word_bank/_rule.py index 54498d6f..63f5b741 100644 --- a/plugins/word_bank/_rule.py +++ b/plugins/word_bank/_rule.py @@ -27,8 +27,6 @@ async def check(event: MessageEvent, state: T_State) -> bool: for seg in event.message: if seg.type == 'at': temp += f"[at:{seg.data['qq']}]" - elif isinstance(seg, str): - temp += seg elif seg.type == 'text': temp += seg.data["text"] problem = temp diff --git a/plugins/word_bank/word_handle.py b/plugins/word_bank/word_handle.py index 8aa44b54..5d6158ed 100644 --- a/plugins/word_bank/word_handle.py +++ b/plugins/word_bank/word_handle.py @@ -93,7 +93,7 @@ async def _( state: T_State, reg_group: Tuple[Any, ...] = RegexGroup(), ): - if str(event.user_id) not in bot.config.superusers: + if isinstance(event, PrivateMessageEvent) and str(event.user_id) not in bot.config.superusers: await add_word.finish('权限不足捏') word_scope, word_type, problem, answer = reg_group if ( @@ -130,8 +130,9 @@ async def _( problem = temp break problem = unescape(problem) - index = len((word_scope or "") + "添加词条" + (word_type or "") + problem) + 1 - event.message[0] = event.message[0].data["text"][index + 1 :].strip() + # index = len((word_scope or "") + "添加词条" + (word_type or "") + problem) + 1 + # event.message[0] = event.message[0].data["text"][index + 1 :].strip() + event.message[0] = event.message[0].data["text"].split('答', maxsplit=1)[-1].strip() state["word_scope"] = word_scope state["word_type"] = word_type state["problem"] = problem