Merge pull request #5086 from UristMcKerman/spam-filter

Spam filter
This commit is contained in:
Chinsky
2014-06-01 20:09:06 +04:00
5 changed files with 96 additions and 20 deletions

View File

@@ -48,6 +48,15 @@
target << law
target.add_ion_law(law)
if(message_servers)
for (var/obj/machinery/message_server/MS in message_servers)
MS.spamfilter.Cut()
var/i
for (i = 1, i <= MS.spamfilter_limit, i++)
MS.spamfilter += pick("kitty","HONK","rev","malf","liberty","freedom","drugs", "Exodus", \
"admin","ponies","heresy","meow","Pun Pun","monkey","Ian","moron","pizza","message","spam",\
"diector", "Hello", "Hi!"," ","nuke","crate","dwarf","xeno")
/datum/event/ionstorm/tick()
if(botEmagChance)
for(var/obj/machinery/bot/bot in world)

View File

@@ -1,27 +1,31 @@
/datum/event/pda_spam
endWhen = 6000
var/time_failed = 0
endWhen = 36000
var/last_spam_time = 0
var/obj/machinery/message_server/useMS
/datum/event/pda_spam/setup()
time_failed = world.time
for (var/obj/machinery/message_server/MS in message_servers)
if(MS.active)
useMS = MS
break
last_spam_time = world.time
pick_message_server()
/datum/event/pda_spam/proc/pick_message_server()
if(message_servers)
for (var/obj/machinery/message_server/MS in message_servers)
if(MS.active)
useMS = MS
break
/datum/event/pda_spam/tick()
if(world.time > last_spam_time + 3000)
//if there's no spam managed to get to receiver for five minutes, give up
kill()
return
if(!useMS || !useMS.active)
useMS = null
if(message_servers)
for (var/obj/machinery/message_server/MS in message_servers)
if(MS.active)
useMS = MS
break
pick_message_server()
if(useMS)
time_failed = world.time
if(prob(2))
if(prob(5))
// /obj/machinery/message_server/proc/send_pda_message(var/recipient = "",var/sender = "",var/message = "")
var/obj/item/device/pda/P
var/list/viables = list()
@@ -86,7 +90,10 @@
"You have won tickets to the newest romantic comedy 16 RULES OF LOVE!",\
"You have won tickets to the newest thriller THE CULT OF THE SLEEPING ONE!")
useMS.send_pda_message("[P.owner]", sender, message)
if (useMS.send_pda_message("[P.owner]", sender, message)) //Message been filtered by spam filter.
return
last_spam_time = world.time
if (prob(50)) //Give the AI an increased chance to intercept the message
for(var/mob/living/silicon/ai/ai in mob_list)
@@ -111,6 +118,3 @@
if(L)
L << "\icon[P] <b>Message from [sender] (Unknown / spam?), </b>\"[message]\" (Unable to Reply)"
else if(world.time > time_failed + 1200)
//if there's no server active for two minutes, give up
kill()