PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: Twix on 27 November, 2003, 13:14:48

Title: Word script
Post by: Twix on 27 November, 2003, 13:14:48
I'm after a script, or part of a script that I can use that will warn and then kick a user who mentions a word either in main chat or a PM.

Any ideas?

TIA

Twix
Title:
Post by: kepp on 27 November, 2003, 16:40:04
sBot = "BotName_here"

BadWords = {["fuck"]=1,["dick"]=2,["pussy"]=3}

               function Main()
               frmHub:RegBot(sBot)
end

              function DataArrival(user, data)
                       if not user.bOperator then
                       for key,a in BadWords do
                       if strfind(strlower(data), key, 1, 1) or strfind(strlower(data), key, 1, 4) then
                      user:SendData(BotName, "Do Not missbehave in here")
                      --SendToAll(BotName, ""..user.sName.." has been kicked due to Misbehave")
                      user:Disconnect()
               end
          end
     end
end

Just a quick one... Not tested!

*Edit* Oups... some changes :)
Title:
Post by: chub on 27 November, 2003, 17:57:05
Good one Kepp, it sure silenced me. Didn't think anything could gag the hubowner. LOL.

I felt I had to try it since there are a lot of ppl comming into the hub screaming things about the hub "theme" and kinda wanted the worse most common stuff out of the hub as fast as possible. Well, turned out the script  disconnected the user sending abusing posts to main chat but also totally gagged me (owner/host) So except for the owner gag it is a nice script.  :D
Title:
Post by: plop on 27 November, 2003, 19:23:35
lol, it gags all operators.
kepp: you want 2 check if a user is not a operator, if it is a operator you don't want 2 do anything.
return 1  means stop processing and stop any further data going out.

plop
Title:
Post by: kepp on 27 November, 2003, 21:22:43
Sorry about that... :D

Updated ***
Title:
Post by: chub on 27 November, 2003, 21:52:41
Ok, since I am at work atm, I can't test it, but have a question: Is it possible to have phrases in it and not just words? Like ["a phrase instead of one word"]=1 ?
Also, I assume the limit is not only 3 words?  :D
Title:
Post by: kepp on 27 November, 2003, 22:11:07
Nope, but i can't think of any other words that i care about...

Hmm, and nope, well, i can't do it....
i think it will search for spaces between eachword...
and the user will get kicked for saying nothing at all...
But then again, i don't know for sure
Title:
Post by: plop on 27 November, 2003, 23:46:53
posible, but for safety you better replace spaces for %s.
["a%sphrase%sinstead%sof%sone%sword"]=1
like this.

plop
Title:
Post by: chub on 27 November, 2003, 23:53:09
QuoteOriginally posted by plop
posible, but for safety you better replace spaces for %s.
["a%sphrase%sinstead%sof%sone%sword"]=1
like this.

plop
Thanks plop, if that works, u may have solved one of my biggest problems, hubwise. Will test it when I get home from work in 6 hours or so and report back here  8)
Title:
Post by: Twix on 28 November, 2003, 02:16:18
Thanks kepp, just what I was after  :D
Title:
Post by: chub on 28 November, 2003, 05:54:09
well... works fine after some modding...  :D
Title:
Post by: kepp on 28 November, 2003, 07:25:44
np... And thanks Plop!!!
Title:
Post by: plop on 28 November, 2003, 10:32:51
np folks.

plop
Title:
Post by: tezlo on 28 November, 2003, 13:33:43
few things..
but on Search or anything coming to DataArrival

badWords = { "fuck", "dick", "pussy", "my ass" }

function DataArrival(user, data)
if not user.bOperator and (strsub(data, 1, 1) == "<" or strsub(data, 1, 4) == "$To:") then
data = strlower(data) -- !!
for id, word in badWords do
if strfind(data, word, 1, 1) then
-- do whatever
end
end
end
end
Title:
Post by: kepp on 28 November, 2003, 15:05:25
Some copy and paste misstakes, as i wrote it for something else..
yep, true, Pm's are private so who care about a bad word in there?

badWords = { "fuck", "dick", "pussy", "my ass" }

function DataArrival(user, data)
if not user.bOperator and (strsub(data, 1, 1) == "<") then
data = strlower(data) -- !!
for id, word in badWords do
if strfind(data, word, 1, 1) then
-- do whatever
end
end
end
end
Title:
Post by: chub on 28 November, 2003, 15:15:52
QuoteOriginally posted by tezlo
few things..
  • no need for an associative array.. you iterate them all anyway
  • you only need to strlower(data) once
  • %s will NOT work since the strfind is not regexp enabled
  • this code will try to find badwords not only on chat and PM..
but on Search or anything coming to DataArrival
  • whats the point of censoring PMs anyway?



What's the point of censoring PMs? I gather most ppl here know I host a gaythemed hub, by now. And there are ppl popping in just to vent their narrowminded thoughts of almost any outlook on life so for instance this, I got in a PM, the other day:
[2003-11-24 23:36] <[Telia]Sphinxx> YOU ARE SICK!!!! A FUCKING PERVERT!!
[2003-11-24 23:36] (automated message) I am not around the computer. Please leave me a note or ask someone else!    

This happy guy rambled on in main chat aswell and I got notified that he'd been on others in PM aswell.
I have rather thick skin after a few years in the "scene" so I don't mind it and frankly don't care, either, but there are ppl much less secure than me and things like this posted to them are kinda hurtful.
I want to be able to filter out as much of this kind of stuff as possible, in main and in PM.

Reason enough?
Title:
Post by: kepp on 28 November, 2003, 15:27:20
*** <---
Title:
Post by: chub on 28 November, 2003, 15:38:00
QuoteOriginally posted by kepp
*** <---

LOL... eeh good point!   :D
Title:
Post by: kepp on 28 November, 2003, 15:42:45
sorry, i was about to comment something, but noticed i didn't have too :)
Title:
Post by: plop on 28 November, 2003, 16:37:26
more then enough reason 2 do so chub.
got 2 gay nephew's and had a couple gay teachers.
some can do like you, others feel the pain from such remarks.
it's sad that there are such narrow minded ppl around.
it's everybody's free right 2 love who he/she wants whether it's from the same sex or not.
if some1 can't except that he/she has a problem him-/herself.

plop
Title:
Post by: kepp on 28 November, 2003, 17:22:13
Hoyya ^^
Title:
Post by: chub on 29 November, 2003, 18:14:46
QuoteOriginally posted by plop

it's sad that there are such narrow minded ppl around.
it's everybody's free right 2 love who he/she wants whether it's from the same sex or not.
if some1 can't except that he/she has a problem him-/herself.

plop
Couldn't agree more.

Anyhow, I am running the script in the hub and it seems to be working grand ok. Adding more phrases to it when I find new word combos that these ppl use.