Don't Work ?!
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

Don't Work ?!

Started by CaSaNoVa, 30 May, 2005, 03:30:07

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

CaSaNoVa

-- word replace script.
-- by plop


---- 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"]= "havin sex",
   ["shit"] = "bleeeeeeeeh",
   ["ass"] = "my hiny",
   ["asshole"] = "(place where dirty stuff exits the body)",
   ["dick"] = "male saucage",
   ["cum"] = "body cream",
   ["fucker"] = "I love you",
   ["fuckers"] = "I love you guy's",
   ["fucking"] = "doing dirty",
   ["bastard"] = "naughty boy",
   ["hell"] = "mac donalds",
   ["whore"] = "angel",
   ["rtfm"] = "read the fucking manual",
   ["stfw"] = "surf the fucking web",
   ["coffee"] = "ploppy potion",
}

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

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

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

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

function DataArrival(user, data)
   if( strsub(data, 1, 1) == "<" ) then
      if FilterMain then
         local s,e,data =strfind(strsub(data, 1, (strlen(data)-1)), "%b<>%s+(.*)")
         local data,c = gsub(data , "(%w+)", function(word) return CheckWord(word) end)
         local s,e,pre, cmd = strfind(data, "^%s*(%W)(%S+)")
         if c ~= 0 then
            if pre and tPre
 then
               if cmd == "me" then
                  SendToAll("* "..user.sName.." "..strsub(data, 5, strlen(data)).."|")
                  return 1
               else
                  return 0
               end
            else
               SendToAll(user.sName, data.."|")
               return 1
            end
         end
      end
   elseif(strsub(data, 1, 4) == "$To:") then
      if FilterPm then
         local s,e,whoto = strfind(data, "%S+%s*(%S+)")
         local s,e,data = strfind(strsub(data, 1, (strlen(data)-1)), "$%b<>%s*(.*)$")
         local data,c=gsub(data , "(%S+)", function(word) return CheckWord(word) end)
         if c ~= 0 then
            SendPmToNick(whoto, user.sName, data.."|")
            return 1
         end
      end
   end
end



>> Syntax ...0.3.3.0.b17.09.nt.dbg\scripts\word_replacer_1.1p.lua:41: attempt to call global `gsub' (a nil value)

SMF spam blocked by CleanTalk