diff --git a/LittlePaimon/plugins/Learning_Chat/handler.py b/LittlePaimon/plugins/Learning_Chat/handler.py index 02a0807..86143ef 100644 --- a/LittlePaimon/plugins/Learning_Chat/handler.py +++ b/LittlePaimon/plugins/Learning_Chat/handler.py @@ -353,7 +353,7 @@ class LearningChat: return cmp(len(left_messages) / left_duration, len(right_messages) / right_duration) popularity: List[Tuple[int, List[ChatMessage]]] = sorted(total_messages.items(), - key=cmp_to_key(group_popularity_cmp)) + key=cmp_to_key(group_popularity_cmp), reverse=True) logger.debug('群聊学习', f'主动发言:群热度排行{">>".join([str(g[0]) for g in popularity])}') for group_id, messages in popularity: if len(messages) < 30: diff --git a/LittlePaimon/plugins/Learning_Chat/web_api.py b/LittlePaimon/plugins/Learning_Chat/web_api.py index a2866ed..d05d575 100644 --- a/LittlePaimon/plugins/Learning_Chat/web_api.py +++ b/LittlePaimon/plugins/Learning_Chat/web_api.py @@ -8,6 +8,11 @@ from LittlePaimon.plugins.Learning_Chat.models import ChatMessage, ChatContext, from LittlePaimon.web.api import BaseApiRouter from LittlePaimon.web.api.utils import authentication +try: + import jieba_fast as jieba +except ImportError: + import jieba + from .handler import LearningChat from .config import config_manager @@ -43,6 +48,7 @@ async def post_chat_global_config(data: dict): count=config_manager.config.learn_max_count) await ChatAnswer.filter(count__gt=config_manager.config.learn_max_count).update( count=config_manager.config.learn_max_count) + jieba.load_userdict(config_manager.config.dictionary) return { 'status': 0, 'msg': '保存成功'