Commit 4e22671d authored by mercury233's avatar mercury233

big brother is watching you

parent 7d1b4543
......@@ -66,6 +66,11 @@
"post": "https://api.mycard.moe/ygopro/analytics/deck/text",
"arena": "233"
},
"big_brother": {
"enabled": false,
"accesskey": "233",
"post": "https://api.mycard.moe/ygopro/big-brother"
},
"arena_mode": {
"enabled": false,
"mode": "entertain",
......
......@@ -160,7 +160,7 @@
"room_name": "您当前的房间名是",
"banned_chat_tip": "您已被禁言!",
"banned_duel_tip": "您的发言存在严重不适当的内容,禁止您使用随机对战功能!",
"chat_warn_level0": "请不要发送垃圾信息!",
"chat_warn_level0": "请不要发送过长的消息或垃圾信息!",
"chat_warn_level2": "您的发言存在不适当的内容,发送失败!",
"chat_warn_level1": "请使用文明用语!",
"chat_banned": "已被禁言!",
......
......@@ -1449,6 +1449,27 @@ ygopro.ctos_follow 'SURRENDER', true, (buffer, info, client, server)->
return true
return false
report_to_big_brother = (roomname, sender, ip, level, content, match) ->
return unless settings.modules.big_brother.enabled
request.post { url : settings.modules.big_brother.post , form : {
accesskey: settings.modules.big_brother.accesskey,
roomname: roomname,
sender: sender,
ip: ip,
level: level,
content: content,
match: match
}}, (error, response, body)->
if error
log.warn 'BIG BROTHER ERROR', error
else
if response.statusCode != 200
log.warn 'BIG BROTHER FAIL', response.statusCode, roomname, body
#else
#log.info 'BIG BROTHER OK', response.statusCode, roomname, body
return
return
ygopro.ctos_follow 'CHAT', true, (buffer, info, client, server)->
room=ROOM_all[client.rid]
return unless room
......@@ -1512,7 +1533,8 @@ ygopro.ctos_follow 'CHAT', true, (buffer, info, client, server)->
regexp = new RegExp(badword, 'i')
return msg.match(regexp)
, msg))
log.warn "BAD WORD LEVEL 3", client.name, client.ip, oldmsg
log.warn "BAD WORD LEVEL 3", client.name, client.ip, oldmsg, RegExp.$1
report_to_big_brother room.name, client.name, client.ip, 3, oldmsg, RegExp.$1
cancel = true
if client.abuse_count>0
ygopro.stoc_send_chat(client, "${banned_duel_tip}", ygopro.constants.COLORS.RED)
......@@ -1539,7 +1561,8 @@ ygopro.ctos_follow 'CHAT', true, (buffer, info, client, server)->
regexp = new RegExp(badword, 'i')
return msg.match(regexp)
, msg))
log.warn "BAD WORD LEVEL 2", client.name, client.ip, oldmsg
log.warn "BAD WORD LEVEL 2", client.name, client.ip, oldmsg, RegExp.$1
report_to_big_brother room.name, client.name, client.ip, 2, oldmsg, RegExp.$1
client.abuse_count=client.abuse_count+3
ygopro.stoc_send_chat(client, "${chat_warn_level2}", ygopro.constants.COLORS.RED)
cancel = true
......@@ -1551,7 +1574,8 @@ ygopro.ctos_follow 'CHAT', true, (buffer, info, client, server)->
return
, msg)
if oldmsg != msg
log.warn "BAD WORD LEVEL 1", client.name, client.ip, oldmsg
log.warn "BAD WORD LEVEL 1", client.name, client.ip, oldmsg, RegExp.$1
report_to_big_brother room.name, client.name, client.ip, 1, oldmsg, RegExp.$1
client.abuse_count=client.abuse_count+1
ygopro.stoc_send_chat(client, "${chat_warn_level1}")
struct = ygopro.structs["chat"]
......@@ -1562,7 +1586,8 @@ ygopro.ctos_follow 'CHAT', true, (buffer, info, client, server)->
regexp = new RegExp(badword, 'i')
return msg.match(regexp)
, msg))
log.info "BAD WORD LEVEL 0", client.name, client.ip, oldmsg
log.info "BAD WORD LEVEL 0", client.name, client.ip, oldmsg, RegExp.$1
report_to_big_brother room.name, client.name, client.ip, 0, oldmsg, RegExp.$1
if client.abuse_count>=2
ROOM_unwelcome(room, client, "${random_ban_reason_abuse}")
if client.abuse_count>=5
......
// Generated by CoffeeScript 1.12.2
(function() {
var Cloud_replay_ids, ROOM_all, ROOM_bad_ip, ROOM_ban_player, ROOM_connected_ip, ROOM_find_by_name, ROOM_find_by_port, ROOM_find_by_title, ROOM_find_or_create_ai, ROOM_find_or_create_by_name, ROOM_find_or_create_random, ROOM_players_banned, ROOM_players_oppentlist, ROOM_unwelcome, ROOM_validate, Room, _, addCallback, ban_user, bunyan, cppversion, crypto, date, defaultconfig, execFile, fs, geoip, get_memory_usage, http, http_server, https, https_server, list, load_dialogues, load_tips, log, moment, nconf, net, options, os, path, pgClient, pg_client, pg_query, redis, redisdb, request, requestListener, roomlist, settings, spawn, spawnSync, url, users_cache, wait_room_start, windbot_process, ygopro, zlib;
var Cloud_replay_ids, ROOM_all, ROOM_bad_ip, ROOM_ban_player, ROOM_connected_ip, ROOM_find_by_name, ROOM_find_by_port, ROOM_find_by_title, ROOM_find_or_create_ai, ROOM_find_or_create_by_name, ROOM_find_or_create_random, ROOM_players_banned, ROOM_players_oppentlist, ROOM_unwelcome, ROOM_validate, Room, _, addCallback, ban_user, bunyan, cppversion, crypto, date, defaultconfig, execFile, fs, geoip, get_memory_usage, http, http_server, https, https_server, list, load_dialogues, load_tips, log, moment, nconf, net, options, os, path, pgClient, pg_client, pg_query, redis, redisdb, report_to_big_brother, request, requestListener, roomlist, settings, spawn, spawnSync, url, users_cache, wait_room_start, windbot_process, ygopro, zlib;
net = require('net');
......@@ -1780,6 +1780,32 @@
return false;
});
report_to_big_brother = function(roomname, sender, ip, level, content, match) {
if (!settings.modules.big_brother.enabled) {
return;
}
request.post({
url: settings.modules.big_brother.post,
form: {
accesskey: settings.modules.big_brother.accesskey,
roomname: roomname,
sender: sender,
ip: ip,
level: level,
content: content,
match: match
}
}, function(error, response, body) {
if (error) {
log.warn('BIG BROTHER ERROR', error);
} else {
if (response.statusCode !== 200) {
log.warn('BIG BROTHER FAIL', response.statusCode, roomname, body);
}
}
});
};
ygopro.ctos_follow('CHAT', true, function(buffer, info, client, server) {
var cancel, cmd, msg, name, oldmsg, room, struct, windbot;
room = ROOM_all[client.rid];
......@@ -1870,7 +1896,8 @@
regexp = new RegExp(badword, 'i');
return msg.match(regexp);
}, msg)) {
log.warn("BAD WORD LEVEL 3", client.name, client.ip, oldmsg);
log.warn("BAD WORD LEVEL 3", client.name, client.ip, oldmsg, RegExp.$1);
report_to_big_brother(room.name, client.name, client.ip, 3, oldmsg, RegExp.$1);
cancel = true;
if (client.abuse_count > 0) {
ygopro.stoc_send_chat(client, "${banned_duel_tip}", ygopro.constants.COLORS.RED);
......@@ -1898,7 +1925,8 @@
regexp = new RegExp(badword, 'i');
return msg.match(regexp);
}, msg)) {
log.warn("BAD WORD LEVEL 2", client.name, client.ip, oldmsg);
log.warn("BAD WORD LEVEL 2", client.name, client.ip, oldmsg, RegExp.$1);
report_to_big_brother(room.name, client.name, client.ip, 2, oldmsg, RegExp.$1);
client.abuse_count = client.abuse_count + 3;
ygopro.stoc_send_chat(client, "${chat_warn_level2}", ygopro.constants.COLORS.RED);
cancel = true;
......@@ -1909,7 +1937,8 @@
msg = msg.replace(regexp, "**");
}, msg);
if (oldmsg !== msg) {
log.warn("BAD WORD LEVEL 1", client.name, client.ip, oldmsg);
log.warn("BAD WORD LEVEL 1", client.name, client.ip, oldmsg, RegExp.$1);
report_to_big_brother(room.name, client.name, client.ip, 1, oldmsg, RegExp.$1);
client.abuse_count = client.abuse_count + 1;
ygopro.stoc_send_chat(client, "${chat_warn_level1}");
struct = ygopro.structs["chat"];
......@@ -1921,7 +1950,8 @@
regexp = new RegExp(badword, 'i');
return msg.match(regexp);
}, msg)) {
log.info("BAD WORD LEVEL 0", client.name, client.ip, oldmsg);
log.info("BAD WORD LEVEL 0", client.name, client.ip, oldmsg, RegExp.$1);
report_to_big_brother(room.name, client.name, client.ip, 0, oldmsg, RegExp.$1);
}
}
if (client.abuse_count >= 2) {
......
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