Commit 90ec4082 authored by mercury233's avatar mercury233

add gag

parent 96780888
......@@ -496,6 +496,7 @@ class Room
@players.push client
client.ip = client.remoteAddress
if @random_type
client.abuse_count = 0
host_player = @get_host()
if host_player && (host_player != client)
# 进来时已经有人在等待了,互相记录为匹配过
......@@ -1300,24 +1301,33 @@ ygopro.ctos_follow 'CHAT', true, (buffer, info, client, server)->
# ygopro.stoc_send_hint_card_to_room(room, 2333365)
if !(room and room.random_type)
return cancel
if client.abuse_count>=5
log.warn "BANNED CHAT", client.name, client.remoteAddress, msg
ygopro.stoc_send_chat(client, "您已被禁言!", ygopro.constants.COLORS.RED)
return true
oldmsg = msg
if (_.any(settings.ban.badword_level3, (badword) ->
regexp = new RegExp(badword, 'i')
return msg.match(regexp)
, msg))
log.warn "BAD WORD LEVEL 3", client.name, client.remoteAddress, oldmsg
ygopro.stoc_send_chat(client, "您的发言存在不适当的内容,禁止您使用随机对战功能!", ygopro.constants.COLORS.RED)
ROOM_ban_player(client.name, client.ip, "发言违规")
ROOM_ban_player(client.name, client.ip, "发言违规", 3)
client.end()
cancel = true
if client.abuse_count>0
ygopro.stoc_send_chat(client, "您的发言存在严重不适当的内容,禁止您使用随机对战功能!", ygopro.constants.COLORS.RED)
ROOM_ban_player(client.name, client.ip, "发言违规")
ROOM_ban_player(client.name, client.ip, "发言违规", 3)
client.end()
return true
else
client.abuse_count=client.abuse_count+4
ygopro.stoc_send_chat(client, "您的发言存在不适当的内容,发送失败!", ygopro.constants.COLORS.RED)
else if (_.any(settings.ban.badword_level2, (badword) ->
regexp = new RegExp(badword, 'i')
return msg.match(regexp)
, msg))
log.warn "BAD WORD LEVEL 2", client.name, client.remoteAddress, oldmsg
ygopro.stoc_send_chat(client, "您的发言存在不适当的内容,发送失败,并记录一次违规!", ygopro.constants.COLORS.RED)
ROOM_ban_player(client.name, client.ip, "发言违规")
client.abuse_count=client.abuse_count+3
ygopro.stoc_send_chat(client, "您的发言存在不适当的内容,发送失败!", ygopro.constants.COLORS.RED)
cancel = true
else
_.each(settings.ban.badword_level1, (badword) ->
......@@ -1328,7 +1338,8 @@ ygopro.ctos_follow 'CHAT', true, (buffer, info, client, server)->
, msg)
if oldmsg != msg
log.warn "BAD WORD LEVEL 1", client.name, client.remoteAddress, oldmsg
ygopro.stoc_send_chat(client, "请使用文明用语")
client.abuse_count=client.abuse_count+1
ygopro.stoc_send_chat(client, "请使用文明用语!")
struct = ygopro.structs["chat"]
struct._setBuff(buffer)
struct.set("msg", msg)
......@@ -1338,6 +1349,9 @@ ygopro.ctos_follow 'CHAT', true, (buffer, info, client, server)->
return msg.match(regexp)
, msg))
log.info "BAD WORD LEVEL 0", client.name, client.remoteAddress, oldmsg
if client.abuse_count>=5
ygopro.stoc_send_chat_to_room(room, "#{client.name} 已被禁言!", ygopro.constants.COLORS.RED)
ROOM_ban_player(client.name, client.ip, "发言违规")
return cancel
ygopro.ctos_follow 'UPDATE_DECK', true, (buffer, info, client, server)->
......
......@@ -660,6 +660,7 @@
this.players.push(client);
client.ip = client.remoteAddress;
if (this.random_type) {
client.abuse_count = 0;
host_player = this.get_host();
if (host_player && (host_player !== client)) {
ROOM_players_oppentlist[host_player.remoteAddress] = client.remoteAddress;
......@@ -1606,6 +1607,11 @@
if (!(room && room.random_type)) {
return cancel;
}
if (client.abuse_count >= 5) {
log.warn("BANNED CHAT", client.name, client.remoteAddress, msg);
ygopro.stoc_send_chat(client, "您已被禁言!", ygopro.constants.COLORS.RED);
return true;
}
oldmsg = msg;
if (_.any(settings.ban.badword_level3, function(badword) {
var regexp;
......@@ -1613,19 +1619,25 @@
return msg.match(regexp);
}, msg)) {
log.warn("BAD WORD LEVEL 3", client.name, client.remoteAddress, oldmsg);
ygopro.stoc_send_chat(client, "您的发言存在不适当的内容,禁止您使用随机对战功能!", ygopro.constants.COLORS.RED);
ROOM_ban_player(client.name, client.ip, "发言违规");
ROOM_ban_player(client.name, client.ip, "发言违规", 3);
client.end();
cancel = true;
if (client.abuse_count > 0) {
ygopro.stoc_send_chat(client, "您的发言存在严重不适当的内容,禁止您使用随机对战功能!", ygopro.constants.COLORS.RED);
ROOM_ban_player(client.name, client.ip, "发言违规");
ROOM_ban_player(client.name, client.ip, "发言违规", 3);
client.end();
return true;
} else {
client.abuse_count = client.abuse_count + 4;
ygopro.stoc_send_chat(client, "您的发言存在不适当的内容,发送失败!", ygopro.constants.COLORS.RED);
}
} else if (_.any(settings.ban.badword_level2, function(badword) {
var regexp;
regexp = new RegExp(badword, 'i');
return msg.match(regexp);
}, msg)) {
log.warn("BAD WORD LEVEL 2", client.name, client.remoteAddress, oldmsg);
ygopro.stoc_send_chat(client, "您的发言存在不适当的内容,发送失败,并记录一次违规!", ygopro.constants.COLORS.RED);
ROOM_ban_player(client.name, client.ip, "发言违规");
client.abuse_count = client.abuse_count + 3;
ygopro.stoc_send_chat(client, "您的发言存在不适当的内容,发送失败!", ygopro.constants.COLORS.RED);
cancel = true;
} else {
_.each(settings.ban.badword_level1, function(badword) {
......@@ -1635,7 +1647,8 @@
}, msg);
if (oldmsg !== msg) {
log.warn("BAD WORD LEVEL 1", client.name, client.remoteAddress, oldmsg);
ygopro.stoc_send_chat(client, "请使用文明用语");
client.abuse_count = client.abuse_count + 1;
ygopro.stoc_send_chat(client, "请使用文明用语!");
struct = ygopro.structs["chat"];
struct._setBuff(buffer);
struct.set("msg", msg);
......@@ -1648,6 +1661,10 @@
log.info("BAD WORD LEVEL 0", client.name, client.remoteAddress, oldmsg);
}
}
if (client.abuse_count >= 5) {
ygopro.stoc_send_chat_to_room(room, client.name + " 已被禁言!", ygopro.constants.COLORS.RED);
ROOM_ban_player(client.name, client.ip, "发言违规");
}
return cancel;
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment