ID:272736
 
I was sitting at my desk (bed o.O) looking at the programming for my game, when it hit me. "I need a chat filter to block links on my game!" So I meddled around in the reference/F1 for a 'maybe' built-in function that would allow me to do that. I didn't find any. So I said to myself "Okay, I gotta make one v.v". I decided to use the findtext() function combined with the chat verb I have to block any links and boot the user for trying to.

Here's the basic gist of it...
mob/verb/Chat()
set hidden = 1
if(global.worldMuted) return
var/msg = input("","") as text|null
if(findtext(msg,"http://") || findtext(msg,"www.") || findtext(msg,"https://"))
del(usr)
return
msg = copytext(msg,1,250)
if(worldActive)
for(var/mob/M) M<<"[usr]: [msg]"
else if(sayActive)
for(var/mob/M in view(usr)) M<<"[usr]: [msg]"

I know that effectively ends any chance for anyone to send any links through the chat. But I kinda only want to end advertising of any other BYOND games. Why? Call me paranoid, but I don't like people joining my game to spam up the chat with a link to another game :\. What would I put in to replace the findtext() functions to prevent links to other BYOND games? I know there's at least 2 different ways to link to another game.
Check for byond.games and byond.members(since people can just link you to their member page for games).
In response to Andre-g1
Like...
if(findtext(msg,"byond.games") || findtext(msg,"byond.members"))

//I also was thinking...

if(findtext(msg,"byond://")) //So people can use direct links :)
In response to Mizukouken Ketsu
Yeah, that's good. Though I think there's a way to link to a byond game without or with something else besides the byond:// bit.
Mizukouken Ketsu wrote:
I know that effectively ends any chance for anyone to send any links through the chat.

Rather, you should remember such checks can be very easily circumvented. Additionally, if you block only links to BYOND worlds, people could still link to their game's website, or even hub page, and if you try and block those, they could always obfuscate the URL by using a redirection (such as using a site like TinyURL). URLs can also be obfuscated by converting them to other formats, like hexadecimal and Dword.

Also, I think the punishment, an immediate boot, is too harsh. If you don't have something similar to a warning system or as such, you could do something like a temporary mute instead. Consider that to a person entering your game solely for advertising, when he's already being blocked from advertising a boot wouldn't affect him much, it would affect an actual (possibly regular) player (which could have just happened to mention a game he likes and post a link) much more.
In response to Kaioken
Kaioken wrote:
Mizukouken Ketsu wrote:
I know that effectively ends any chance for anyone to send any links through the chat.

Rather, you should remember such checks can be very easily circumvented. Additionally, if you block only links to BYOND worlds, people could still link to their game's website, or even hub page, and if you try and block those, they could always obfuscate the URL by using a redirection (such as using a site like TinyURL). URLs can also be obfuscated by converting them to other formats, like hexadecimal and Dword.

Well yeah, but the average BYONDer isn't that smart ;p

Also, I think the punishment, an immediate boot, is too harsh. If you don't have something similar to a warning system or as such, you could do something like a temporary mute instead. Consider that to a person entering your game solely for advertising, when he's already being blocked from advertising a boot wouldn't affect him much, it would affect an actual (possibly regular) player (which could have just happened to mention a game he likes and post a link) much more.

Yeah I guess I can go with a mute instead :(