From eaac3e35792f3cfd205dc9f984cff3647f040885 Mon Sep 17 00:00:00 2001 From: lanvent Date: Thu, 6 Apr 2023 01:35:42 +0800 Subject: [PATCH] feat: add min simularity to match role --- plugins/role/role.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/role/role.py b/plugins/role/role.py index 7b6cd74..fd29fa3 100644 --- a/plugins/role/role.py +++ b/plugins/role/role.py @@ -52,7 +52,7 @@ class Role(Plugin): logger.warn("[Role] init failed, ignore or see https://github.com/zhayujie/chatgpt-on-wechat/tree/master/plugins/role .") raise e - def get_role(self, name, find_closest=True): + def get_role(self, name, find_closest=True, min_sim = 0.35): name = name.lower() found_role = None if name in self.roles: @@ -62,7 +62,7 @@ class Role(Plugin): def str_simularity(a, b): return difflib.SequenceMatcher(None, a, b).ratio() - max_sim = 0.0 + max_sim = min_sim max_role = None for role in self.roles: sim = str_simularity(name, role)