PtokaX forum

Archive => Archived 5.0 boards => Request for scripts => Topic started by: Kastor on 27 January, 2007, 20:15:08

Title: Mc scanner
Post by: Kastor on 27 January, 2007, 20:15:08
hi all  ;D

excused I would have need of a script similar to the "mc scanner" that it has ynhub,I have seen a script similar to this in the forum , but when one of the staff (or admin) says a "word forbidden" in main, the word comes changed . I want that the "words forbidden"  only forbidden from the op (comprised) to the categories low . It is possible?
thanks so much!
Title: Re: Mc scanner
Post by: Kastor on 27 January, 2007, 21:59:22
I have this script , but the forbidden words are extended to all the categories: admin, mod, op, etc. I would want that the categories under the op cannot say the forbitten words(for example : ["fuck"]= "***** ",), but over the op yes.(for example : ["fuck"]= "fuck ")

the scrit about which I speak it is following:



-- PtokaX Lua 5 version by PPK

-- Naruto www.narutodc.tk
-- Body by plop thx to him

-- This script stops the ***** words :) It has some words saved..
-- Plz if you know new words plz add them or go to my homepage and tell me..
-- Languages:  English
--             Frensh
--             Luxembourgois
--             Portuges
--             German
--             Italian
--             Swedish
--             Norsk
-- Version 1.0


---------------------------------------------------------------------------------------------

---- filter what? use 1 to enable, nil to disable the filter.
FilterPm = 1
FilterMain = 1

---- the words to be replaced and by what.
tBadWords = {
   ["fuck"]= "",
   ["Bitch"] = "",
   ["fuck you"] = "",
   ["motherfucker"] = "",
   ["fuck you all"] = "",
   ["fucking"] = "",
   ["pussy"] = "",
   ["suck"] = "",
   ["sucks"] = "",
   ["suckz"] = "",
   ["blow"] = "",
   ["fucker"] = "",
   ["shit"] = "",
   ["ass"] = "",
   ["mother fucker"] = "",
   ["cock sucker"] = "",
   ["stupid fucker"] = "",
   ["I   hate t  his    hu b"] = "",
   ["this hub sucks"] = "",
   ["this hub blows"] = "",
   ["suck my dick"] = "",
   ["stupid whore"] = "",
   ["fagget"] = "",
   ["je te deteste"] = "",
   ["conard"] = "",
   ["connard"] = "",
   ["batard"] = "",
   ["conasse"] = "",
   ["va te faire foutre"] = "",
   ["va te faire enculer"] = "",
   ["enculer"] = "",
   ["pute"] = "",
   ["PD"] = "",
   ["fils de pute"] = "",
   ["salopar"] = "",
   ["salop"] = "",
   ["salot"] = "",
   ["salo"] = "",
   ["filhu da puta"] = "",
   ["puta"] = "",
   ["puta qua pariu"] = "",
   ["vai a tua main filhu da puta"] = "",
   ["tu es un grand idiota"] = "",
   ["tu es un grande idiota"] = "",
   ["filu da puta"] = "",
   ["vai a merda"] = "",
   ["idiota de merda"] = "",
   ["tu es uma grande merda"] = "",
   ["arschgesit"] = "",
   ["arshgesit"] = "",
   ["allen penner"] = "",
   ["du arsch"] = "",
   ["du arsh"] = "",
   ["du bas en vixxer"] = "",
   ["vixer"] = "",
   ["vixxer"] = "",
   ["dier gid mer all op den sack"] = "",
   ["arschloch"] = "",
   ["arshloch"] = "",
   ["alter sack"] = "",
   ["du bist eine hure"] = "",
   ["hure"] = "",
   ["alter penner"] = "",
   ["wixer"] = "",
   ["wixxer"] = "",
   ["arschgesicht"] = "",
   ["arshgesicht"] = "",
   ["puff"] = "",
   ["puffmama"] = "",
   ["pufmama"] = "",
   ["schlampe"] = "",
   ["alte schlampe"] = "",
   ["fanculo"] = "",
   ["stronzo"] = "",
   ["merda"] = "",
   ["cazzo"] = "",
   ["troia"] = "",
   ["puttana"] = "adsadsd",
   ["coglione"] = "",
   ["Knulla din mamma"] = "",
   ["fitte"] = "",
   ["suge"] = "",
   ["r?v"] = "",
   ["vill du g?ra e i min r?v!"] = "",
   ["Knulla"] = "",
   




   
}

---- the words to be replaced and by what (function mode).
tBadFuncs = {
   -- replace lol with a random amount of o's
   ["lol"] = function()
      local i = math.random(1,20)
      return "L"..(string.rep("o", i)).."L"
   end
}

-- prefixes table, allowed for me and let commands bypase the replacer
tPre = { ["+"] = 1, ["!"] = 1, ["/"] = 1, ["-"]=1 }

function Main()
   local num = string.gsub(os.date(), "%D", "")
   math.randomseed(tonumber(num))
end

function CheckWord(word)
   local wordl = string.lower(word)
   if tBadWords[wordl] then
      return tBadWords[wordl]
   elseif tBadFuncs[wordl] then
      return tBadFuncs[wordl]()
   else
      return word
   end
end

function ChatArrival(user, data)
   if FilterMain then
      local s,e,data =string.find(string.sub(data, 1, (string.len(data)-1)), "%b<>%s+(.*)")
      local data,c = string.gsub(data , "(%w+)", function(word) return CheckWord(word) end)
      local s,e,pre, cmd = string.find(data, "^%s*(%W)(%S+)")
      if c ~= 0 then
         if pre and tPre[pre] then
            if cmd == "me" then
               SendToAll("* "..user.sName.." "..string.sub(data, 5, string.len(data)).."|")
               return 1
            else
               return 0
            end
         else
            SendToAll(user.sName, data.."|")
            return 1
         end
      end
   end
end

function ToArrival(user, data)
   if FilterPm then
      local s,e,whoto = string.find(data, "%S+%s*(%S+)")
      local s,e,data = string.find(strsub(data, 1, (string.len(data)-1)), "$%b<>%s*(.*)$")
      local data,c=string.gsub(data , "(%S+)", function(word) return CheckWord(word) end)
      if c ~= 0 then
         SendPmToNick(whoto, user.sName, data.."|")
         return 1
      end
   end
end
Title: Re: Mc scanner
Post by: BrotherBear on 09 February, 2007, 17:23:34
Hi!

I am looking for a similar script, but I want to replace words with another word.

Example:

[1.0]Nicko Hello hubbers

is changed to

[1.0]Nicko Hello folks

I want to have the possibillity to add the words trough Rightclick.

Some kind of a joke scripte, replace words :)
Title: Re: Mc scanner
Post by: plop on 09 February, 2007, 18:50:58
Quote from: BrotherBear on 09 February, 2007, 17:23:34
Hi!

I am looking for a similar script, but I want to replace words with another word.

Example:

[1.0]Nicko Hello hubbers

is changed to

[1.0]Nicko Hello folks

I want to have the possibillity to add the words trough Rightclick.

Some kind of a joke scripte, replace words :)


you need the script Kastor posted, or download my original wordreplacer from the script database.

plop
Title: Re: Mc scanner
Post by: BrotherBear on 09 February, 2007, 21:07:01
Oops sorry, didn't se that I should write something between " "   hehe

But when I want to repleace words with ??? (Swedish characters)
nothing happens :(

Thanks for this simple but very useful script :)
Title: Re: Mc scanner
Post by: plop on 09 February, 2007, 22:25:23
Quote from: BrotherBear on 09 February, 2007, 21:07:01
Oops sorry, didn't se that I should write something between " "   hehe

But when I want to repleace words with ??? (Swedish characters)
nothing happens :(

Thanks for this simple but very useful script :)

can you check if it works in pm.
if so replace this line on ChatArrival
      local data,c = string.gsub(data , "(%w+)", function(word) return CheckWord(word) end)
for
      local data,c = string.gsub(data , "(%S+)", function(word) return CheckWord(word) end)

plop
Title: Re: Mc scanner
Post by: bastya_elvtars on 09 February, 2007, 22:26:45
os.setlocale()?
Title: Re: Mc scanner
Post by: BrotherBear on 10 February, 2007, 09:26:50
Thanks plop, it worked in Main but not in PM :)

Does not work in PM at all :(

I'll get this error --> MCScanner.lua:98: attempt to call global 'strsub' (a nil value)
When I test the words in PM


What do you mean bastya_elvtars with

os.setlocale()?
Title: Re: Mc scanner
Post by: bastya_elvtars on 10 February, 2007, 12:09:37
Quote from: BrotherBear on 10 February, 2007, 09:26:50
Thanks plop, it worked in Main but not in PM :)

Does not work in PM at all :(

I'll get this error --> MCScanner.lua:98: attempt to call global 'strsub' (a nil value)

Replace strsub with string.sub.

Quote from: BrotherBear on 10 February, 2007, 09:26:50
What do you mean bastya_elvtars with

os.setlocale()?

That's a way to set up what characters count as letters in lua. It was a suggestion for plop.
Title: Re: Mc scanner
Post by: BrotherBear on 24 February, 2007, 17:30:14
Ahh, thanks bastya_elvtars :)

Oki, let's see what Plop do ;)
Hi again :)

Is it possible to get the scanner replace words like this:

h mm
h m m

Words with spaces?
Pleeeeeeeeeeeeeease Anyone ?
Title: Re: Mc scanner
Post by: bastya_elvtars on 24 February, 2007, 17:37:29
Yes, put %s+ where you expect spaces.
Title: Re: Mc scanner
Post by: bastya_elvtars on 24 February, 2007, 18:00:23
Quote from: Mutor on 24 February, 2007, 17:39:41
%s*, should serve you a little better.

Indeed. That also matches if there aren't spaces.
Title: Re: Mc scanner
Post by: BrotherBear on 24 February, 2007, 18:45:18
Thanks Guys, I don't get it to work :(

Is this right?

tBadWords = {
   ["h%s*mm,"]= "Halleluja",
   ["h%s*m%s*m,"]= "What !!!",
}

Title: Re: Mc scanner
Post by: bastya_elvtars on 24 February, 2007, 18:48:37
Yeah, that's it.
(Sidenote: why do we have to force characterclass-based matching in chatlines? :-/)
Title: Re: Mc scanner
Post by: BrotherBear on 24 February, 2007, 18:59:29
OK

Is it not anything that would be added here:

---- the words to be replaced and by what (function mode).
tBadFuncs = {
   -- replace lol with a random amount of o's
   ["lol"] = function()
      local i = math.random(1,20)
      return "L"..(string.rep("o", i)).."L"
   end
}

Or could it be something with I am using 5.1.1 Lua ?
Title: Re: Mc scanner
Post by: BrotherBear on 24 February, 2007, 19:10:12
Nope, no errors
Title: Re: Mc scanner
Post by: BrotherBear on 24 February, 2007, 19:20:26
Here you are :)


-- PtokaX Lua 5 version by PPK

-- Naruto www.narutodc.tk
-- Body by plop thx to him

-- This script stops the ***** words :) It has some words saved..
-- Plz if you know new words plz add them or go to my homepage and tell me..
-- Languages:  English
--             Frensh
--             Luxembourgois
--             Portuges
--             German
--             Italian
--             Swedish
--             Norsk
-- Version 1.0


---------------------------------------------------------------------------------------------

---- filter what? use 1 to enable, nil to disable the filter.
FilterPm = 1
FilterMain = 1

---- the words to be replaced and by what.
tBadWords = {
   ["hmm"]= "Fundilerar",
   ["hmmm"]= "Vad var det d?r d? ?",
   ["hm"]= "Hennes & Mauritz",
   ["hm,"]= "haha, den gick jag  eh..  p? :)",
   ["hmm,"]= "Halleluja",
   ["h%s*m%s*m,"]= "N?h? inte det :(",
   ["h%s*mm,"]= "Inte h?r heller :(",
   ["fan"]= "*SWORDOM*",
   ["faan"]= "*SWORDOM*",
   ["faaan"]= "*SWORDOM*",
   ["faaaan"]= "*SWORDOM*",
   ["j?vlar"]= "*SWORDOM*",
   ["j?vla"]= "*SWORDOM*",
   ["helvete"]= "*SWORDOM*",
   ["helvetes"]= "*SWORDOM*",
   ["j?sses"] = "g?sses",
   ["idiot"] = "ingen d?lig intelligens och tanke",
   ["hoho"] = "Jag andas...d?rf?r finns jag, eller? *k?nner mig ensam*",
   ["shit"] = "e n?dig :( ",
   ["ass"] = "En sak med skinkor",
   ["troia"] = "F?rvirrad Full H?st !!!",
   ["r?v"] = "e n?t man bajsar med",
   ["slot"] = "`I'm a slotbegger, yes I am?",
   ["ladda"] = "`Jag ?r en liten leecher, hihi?",
   ["msn"] = "MDN",
   ["h?h?"] = "Gn?ggGn?gg",
   ["hello"] = "Zippedi doh dah",
   ["tjena"] = "Boomshackalack",
   ["brb"] = "Be Right Back at Ya :)",
   ["bbl"] = "Be Back Later Dudes :)",
   ["s?k"] = "Anv?nd CTRL + S :)",
}

---- the words to be replaced and by what (function mode).
tBadFuncs = {
   -- replace lol with a random amount of o's
   ["lol"] = function()
      local i = math.random(1,20)
      return "L"..(string.rep("o", i)).."L"
   end
}

-- prefixes table, allowed for me and let commands bypase the replacer
tPre = { ["+"] = 1, ["!"] = 1, ["/"] = 1, ["-"]=1 }

function Main()
   local num = string.gsub(os.date(), "%D", "")
   math.randomseed(tonumber(num))
end

function CheckWord(word)
   local wordl = string.lower(word)
   if tBadWords[wordl] then
      return tBadWords[wordl]
   elseif tBadFuncs[wordl] then
      return tBadFuncs[wordl]()
   else
      return word
   end
end

function ChatArrival(user, data)
   if FilterMain then
      local s,e,data =string.find(string.sub(data, 1, (string.len(data)-1)), "%b<>%s+(.*)")
      local data,c = string.gsub(data , "(%S+)", function(word) return CheckWord(word) end)
      local s,e,pre, cmd = string.find(data, "^%s*(%W)(%S+)")
      if c ~= 0 then
         if pre and tPre[pre] then
            if cmd == "me" then
               SendToAll("* "..user.sName.." "..string.sub(data, 5, string.len(data)).."|")
               return 1
            else
               return 0
            end
         else
            SendToAll(user.sName, data.."|")
            return 1
         end
      end
   end
end

function ToArrival(user, data)
   if FilterPm then
      local s,e,whoto = string.find(data, "%S+%s*(%S+)")
      local s,e,data =string.find(string.sub(data, 1, (string.len(data)-1)), "%b<>%s+(.*)")
      local data,c=string.gsub(data , "(%S+)", function(word) return CheckWord(word) end)
      if c ~= 0 then
         SendPmToNick(whoto, user.sName, data.."|")
         return 1
      end
   end
end


Thanks Mutor :)
Title: Re: Mc scanner
Post by: BrotherBear on 24 February, 2007, 22:24:16
That would be very apritiated, Mutor :)

Thanks alot!
Title: Re: Mc scanner
Post by: BrotherBear on 25 February, 2007, 12:14:26
Thank You Very Much Mutor :)

It works great :D

Do you have a place that explain these:

$
%s*
%s+
etc..

Thanks again Mutor, I will let you know how it works out :)
Title: Re: Mc scanner
Post by: bastya_elvtars on 25 February, 2007, 13:36:38
WikiPx (http://wiki.ptokax.ath.cx/doku.php?id=scriptinghelp:strings#character_classes)
Title: Re: Mc scanner
Post by: BrotherBear on 03 March, 2007, 22:10:30
Thanks bastya :)
Mutor, after sometime the script get wierd!

Some of the words does not work and when I paste an ASCII pic it looks like this:

                     O       O       O       O       O       O        O       O                    ? ? ? ?  ?   ?   ????    ????    ????     ????    ????    ????     ????    ????   ?       ??  ??  ?       ? ?    ?    ?  ?    ?  ?    ?   ?    ?  ?    ?  ?    ?   ?    ?  ?    ?  ?       ??  ??  ? ? ? ?  ??     ??????  ??????  ??????   ??????  ??????  ??????   ??????  ??????  ?       ??  ??       ?  ? ?    ?    ?  ?    ?  ?    ?   ?    ?  ?    ?  ?    ?   ?    ?  ?    ?  ?  ? ? ? ?  ?   ?  ?    ?  ?    ?  ?    ?   ?    ?  ?    ?  ?    ?   ?    ?  ?    ?  ?????   ??  ??

Instead of this:

   
                                 O             O              O              O             O             O               O             O 
                                 
? ? ? ?    ?     ?      ????        ????        ????         ????        ????        ????         ????        ????      ?              ??    ?? 
?             ?  ?       ?        ?    ?        ?    ?        ?     ?        ?    ?        ?    ?        ?     ?        ?    ?        ?    ?              ??    ?? 
? ? ? ?    ??         ??????    ??????    ??????     ??????    ??????    ??????     ??????    ??????    ?              ??    ?? 
         ?    ?  ?       ?        ?    ?        ?    ?        ?     ?        ?    ?        ?    ?        ?     ?        ?    ?        ?    ? 
? ? ? ?    ?     ?    ?        ?    ?        ?    ?        ?     ?        ?    ?        ?    ?        ?     ?        ?    ?        ?    ?????      ??    ??     

Do you know what could be wrong?

Running Ptokax 0.3.5.2f and these scripts:

- [ 1 ]  ChatStatsv3.lua
- [ 1 ]  Lucifer6.6.6-build2.133.lua
- [ 1 ]  LV_3.lua
- [ 1 ]  chatrooms.v4.12.lua
- [ 1 ]  NoPub.lua
- [ 1 ]  MCScanner.lua
- [ 1 ]  Request.lua
- [ 1 ]  Release.lua
- [ 1 ]  BirthdayMan.v4.07.lua
- [ 1 ]  Ascii.lua
- [ 1 ]  Infos.lua

Disabled the McScanner.lua (your script) and the ASCII worked.