PtokaX forum

Archive => Archived 5.0 boards => Finished Scripts => Topic started by: plop on 28 February, 2005, 17:49:58

Title: word replacer
Post by: plop on 28 February, 2005, 17:49:58
-- 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"] = "",
   ["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

plop
Title:
Post by: Jaakko on 28 February, 2005, 18:35:52
Few finnish words to add.
      ["Paska"] = "",
          ["Paskan"] = "",
       ["Paskat"] = "",       ["Paskaa"] = "",
       ["Perkele"] = "",
       ["Perkeleen"] = "",
       ["Perkeleet"] = "",
       ["Perkelett?"] = "",
       ["Saatana"] = "",
       ["Saatanan"] = "",
       ["Saatanat"] = "",
       ["Saatanaa"] = "",
       ["Vittu"] = "",
       ["Vitun"] = "",
          ["Vitut"] = "",
       ["Vittua"] = "",
       ["Pillu"] = "",
       ["Pillun"] = "",
       ["Pillut"] = "",
       ["Pillua"] = "",
       ["Helvetti"] = "",
       ["Helvetin"] = "",
       ["Helvetit"] = "",
       ["Helvetti?"] = "",
       ["Kusi"] = "",
       ["Kusta"] = "",
       ["Kusen"] = "",  
Title:
Post by: bastya_elvtars on 28 February, 2005, 19:53:55
For why not make an array?
Title:
Post by: Troubadour on 28 February, 2005, 22:06:08
it gives a nil value error on this line in pm filter part

      local s,e,data = string.find(strsub(data, 1, (string.len(data)-1)), "$%b<>%s*(.*)$")
Title:
Post by: Typhoon on 28 February, 2005, 23:05:08
QuoteOriginally posted by Troubadour
it gives a nil value error on this line in pm filter part

      local s,e,data = string.find(strsub(data, 1, (string.len(data)-1)), "$%b<>%s*(.*)$")

try changing strsub too string.sub .. that should fix it


Typhoon?
Title:
Post by: plop on 01 March, 2005, 01:05:12
QuoteOriginally posted by bastya_elvtars
For why not make an array?
because gsub sends every word 2 the function CheckWord, and now it can be hashed instead of looping the array for every word.
the array would only be faster if the words being checked are more then the amount of vallue's in the array.
this rarely happens in practize.

plop
Title:
Post by: exlepra on 15 March, 2005, 22:22:14
PM filter does not seem to be working (I set FilterPm to 1 and replaced strsub with string.sub)
Title:
Post by: dragos_sto on 03 May, 2005, 14:33:35
plop , some requirement ,you cant put a file whit what to
"" and master have option to add in the file
new word to be replace whit something else ?
Title:
Post by: plop on 08 May, 2005, 18:12:47
try this (http://lua.uknnet.com/thread.php?threadid=681&sid=) version.
it's fully made by me and has some extra features.

plop