• Print

Author Topic: Kicking people based on keywords  (Read 5265 times)

0 Members and 1 Guest are viewing this topic.

Offline OpticPotatOS

  • Jr. Member
  • **
  • Posts: 53
  • Karma: 0
  • GLaDOS
    • Gaming for Everyone
Kicking people based on keywords
« on: March 01, 2016, 01:02:07 pm »
This might be the wrong place, but seeing as it said anything and everything, I figured it was my best shot.

So, our server is part of GFE (Gaming for Everyone: gfe.nu). An intersectional feminist gaming group. We are LGBTQ friendly and all that. Just look at the website. Currently we are in the business of actually getting everything working.

Anyway, the internet is a horrible place, so our admins won't be able to deal with every individual case of inappropriate language. We (well, mostly me of our little group) were wondering if there is a way to have people kicked/muted/banned etc. if certain keywords (n-word etc.) are detected in chat. Is this in any way possible? Or would we have to write our own little bit of stuff for this? Any help would be much appreciated. Thanks.
My website isn't my website, rather, it's the gaming network my sever is connected to.

ttt.gfe.nu

Unforeseen Consequences

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: Kicking people based on keywords
« Reply #1 on: March 01, 2016, 01:59:13 pm »
Rudimentary example (you would definitely want to modify this to fit your needs):

Code: Lua
  1. local blacklist = {
  2.     "***",
  3.     "add more words here",
  4. }
  5.  
  6. local function checkMessage(ply, msg, team)
  7.     msg = string.lower(msg)
  8.     for _, v in pairs(blacklist) do
  9.         if string.find(msg, v) then
  10.             ply:Kick("Please do not say " .. v .. " on our server!")
  11.             return ""
  12.         end
  13.     end
  14.     return msg
  15. end
  16.  
  17. hook.Add("PlayerSay", "chat_blacklist_check", checkMessage)

Untested, but this should work fine. Of course, it's entirely rudimentary, and is very easily circumvented.
« Last Edit: March 01, 2016, 02:19:58 pm by Bytewave »
bw81@ulysses-forums ~ % whoami
Homepage

Offline OpticPotatOS

  • Jr. Member
  • **
  • Posts: 53
  • Karma: 0
  • GLaDOS
    • Gaming for Everyone
Re: Kicking people based on keywords
« Reply #2 on: March 01, 2016, 02:26:16 pm »
Thanks!

I see where we would put in the keywords, but can we put multiple keywords in there or would we have to copy that code out over for each individual keyword? Sorry if I'm appearing stupid.
My website isn't my website, rather, it's the gaming network my sever is connected to.

ttt.gfe.nu

Unforeseen Consequences

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: Kicking people based on keywords
« Reply #3 on: March 01, 2016, 02:32:32 pm »
It's perfectly fine. I understand not everyone is a programmer. ;p

To add more keywords, you would do it like this:
Code: Lua
  1. local blacklist = {
  2.     "keyword or phrase one",
  3.     "two",
  4.    "three",
  5.     -- and so on and so forth
  6. }

Note the pattern—a keyword should appear between two double quotes, and the string of keyword plus quotes should be followed by a comma. Please write all of your keywords in lowercase—the system will check for any variation of upper and lowercase letters, and requires all keywords in lowercase as a result.

Again, this is a rather easy system to circumvent, but if you're happy with it, it ought to run fine.

Drop this file in /lua/autorun/server/ for it to take effect, by the way. Name it something like "chat_blacklist.lua" (note the file extension).
bw81@ulysses-forums ~ % whoami
Homepage

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Kicking people based on keywords
« Reply #4 on: March 01, 2016, 07:29:03 pm »
I've seen this discussion before. Might even be a release somewhere for it.
Search Releases and or Developers Corner.

/index.php/topic,6938.0.html
See page 4 for version 1.2 (I think that was latest - Neku still comes here occasionally I think)
« Last Edit: March 01, 2016, 07:32:44 pm by JamminR »
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline OpticPotatOS

  • Jr. Member
  • **
  • Posts: 53
  • Karma: 0
  • GLaDOS
    • Gaming for Everyone
Re: Kicking people based on keywords
« Reply #5 on: March 02, 2016, 10:55:27 am »
Thanks! You people are great.  :)
My website isn't my website, rather, it's the gaming network my sever is connected to.

ttt.gfe.nu

Unforeseen Consequences

  • Print