群聊学习不学以命令前缀开头的消息,修复web ui禁用列表不能翻页的问题

This commit is contained in:
CMHopeSunshine 2023-01-09 14:14:43 +08:00
parent 0546be70c8
commit d8e81fefdd
4 changed files with 12 additions and 6 deletions

View File

@ -15,10 +15,14 @@ from nonebot import get_bot
from nonebot.adapters.onebot.v11 import GroupMessageEvent, MessageSegment, ActionFailed
from tortoise.functions import Count
from LittlePaimon.utils import NICKNAME, SUPERUSERS, logger
from LittlePaimon.utils.typing import command_start
from .models import ChatBlackList, ChatContext, ChatAnswer, ChatMessage
from .config import config_manager
chat_config = config_manager.config
command_start_ = command_start.copy()
if '' in command_start_:
command_start.remove('')
NO_PERMISSION_WORDS = [f'{NICKNAME}就喜欢说这个,哼!', f'你管得着{NICKNAME}吗!']
ENABLE_WORDS = [f'{NICKNAME}会尝试学你们说怪话!', f'好的呢,让{NICKNAME}学学你们的说话方式~']
@ -76,6 +80,10 @@ class LearningChat:
logger.debug('群聊学习', f'➤该群<m>{self.data.group_id}</m>未开启群聊学习,跳过')
# 如果未开启群聊学习,跳过
return Result.Pass
elif command_start_ and self.data.message.startswith(tuple(command_start_)):
# 以命令前缀开头的消息,跳过
logger.debug('群聊学习', '➤消息以命令前缀开头,跳过')
return Result.Pass
elif self.data.user_id in self.ban_users:
# 发言人在屏蔽列表中,跳过
logger.debug('群聊学习', f'➤发言人<m>{self.data.user_id}</m>在屏蔽列表中,跳过')

View File

@ -164,10 +164,7 @@ async def get_chat_blacklist(page: int = 1, perPage: int = 10, keywords: Optiona
filter_arg = {'keywords__contains': keywords} if keywords else {}
items = await ChatBlackList.filter(**filter_arg).offset((page - 1) * perPage).limit(perPage).values()
for item in items:
if item['global_ban']:
item['bans'] = '全局禁用'
else:
item['bans'] = str(item['ban_group_id'][0])
item['bans'] = '全局禁用' if item['global_ban'] else str(item['ban_group_id'][0])
if bans:
items = list(filter(lambda x: bans in x['bans'], items))
return {
@ -175,7 +172,7 @@ async def get_chat_blacklist(page: int = 1, perPage: int = 10, keywords: Optiona
'msg': 'ok',
'data': {
'items': items,
'total': len(items)
'total': await ChatBlackList.filter(**filter_arg).count()
}
}

View File

@ -96,6 +96,7 @@ blacklist_table = TableCRUD(mode='table',
title='',
syncLocation=False,
api='/LittlePaimon/api/get_chat_blacklist',
interval=15000,
headerToolbar=[ActionType.Ajax(label='取消所有禁用',
level=LevelEnum.warning,
confirmText='确定要取消所有禁用吗?',

View File

@ -4,7 +4,7 @@ from nonebot import get_driver
from .logger import logger
from .scheduler import scheduler
__version__ = '3.0.3'
__version__ = '3.0.4'
DRIVER = get_driver()
try: