聊天:添加屏蔽
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
import {Application, RouteRecord, FrontendOrBackendSession, HandlerCallback, pinus} from "pinus";
|
||||
// import { checkEvent } from '../../../services/eventSercive';
|
||||
import { refresh } from '../../../services/refreshService';
|
||||
import { checkFilterWords, getWorldChannelSid } from "../../../services/chatService";
|
||||
import { checkPrivateChat, checkGuildChat, checkOtherChat, getWorldChannelSid } from "../../../services/chatService";
|
||||
import { resResult, checkWhiteListWithUid } from "../../../pubUtils/util";
|
||||
import { STATUS } from "../../../consts";
|
||||
import { CHANNEL_PREFIX, STATUS } from "../../../consts";
|
||||
import { UserModel } from "../../../db/User";
|
||||
import { SERVER_DEBUG_MODE } from "../../../pubUtils/dicParam";
|
||||
export function globalFilter(app: Application) {
|
||||
return new Filter(app);
|
||||
}
|
||||
@@ -31,15 +32,39 @@ Filter.prototype.before = async function (routeRecord: RouteRecord, msg: any, se
|
||||
}
|
||||
|
||||
let hasBlockWords = false;
|
||||
if(pinus.app.get('env') == 'production') {
|
||||
if(routeRecord.route == 'guild.guildHandler.createGuild') {
|
||||
hasBlockWords = await checkFilterWords(msg.name);
|
||||
} else if (routeRecord.route == 'role.roleHandler.initRole') {
|
||||
hasBlockWords = await checkFilterWords(msg.roleName);
|
||||
} else if (routeRecord.route == 'role.roleHandler.rename') {
|
||||
hasBlockWords = await checkFilterWords(msg.roleName);
|
||||
// if(pinus.app.get('env') == 'production') {
|
||||
// if(routeRecord.route == 'guild.guildHandler.createGuild') {
|
||||
// hasBlockWords = await checkFilterWords(msg.name);
|
||||
// } else if (routeRecord.route == 'role.roleHandler.initRole') {
|
||||
// hasBlockWords = await checkFilterWords(msg.roleName);
|
||||
// } else if (routeRecord.route == 'role.roleHandler.rename') {
|
||||
// hasBlockWords = await checkFilterWords(msg.roleName);
|
||||
// }
|
||||
// }
|
||||
if(SERVER_DEBUG_MODE.CHECK_WORD == 1) {
|
||||
switch(routeRecord.route) {
|
||||
case 'chat.chatHandler.sendPrivateMessage':
|
||||
{
|
||||
let result = await checkPrivateChat(roleId, msg.targetRoleId, msg.content);
|
||||
if(!result) hasBlockWords = true;
|
||||
break;
|
||||
}
|
||||
case 'chat.chatHandler.sendGroupMessage':
|
||||
{
|
||||
if(msg.channel == CHANNEL_PREFIX.GUILD) {
|
||||
const guildCode = session.get('guildCode');
|
||||
let result = await checkGuildChat(roleId, guildCode, msg.content);
|
||||
if(!result) hasBlockWords = true;
|
||||
break;
|
||||
} else {
|
||||
let result = await checkOtherChat(roleId, msg.channel, msg.content);
|
||||
if(!result) hasBlockWords = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(hasBlockWords) return next(new Error(), resResult(STATUS.BLOCK_WORDS));
|
||||
|
||||
next(null);
|
||||
|
||||
Reference in New Issue
Block a user