Word replace script
 

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

Word replace script

Started by VAZ, 19 September, 2004, 02:38:42

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

VAZ

is it possible to get word replace script?
because word replace manager does not work on my ptokax soft.. :(

thanks in advance.

BottledHate

#1
sure... here ya go:

--//Word Replace Bot v0.1
--//By: BottledHate
--//Requested by: VAZ
--//18/09/04(first release)


-----get later version ---


--//Word Replacce Bot v0.1, by BottledHate (18/09/04)

it's best to name it "_zwordreplace.lua" so it loads last... this will help make sure it doesn't effect other bots.

-BH
Homepage: www.bottledhate.webhop.org

Compiling  Lua scripts is LAME!!!!!

VAZ

#2
Cool it works great thnx alot :]
wery nice script

BottledHate

no problem... glad i could put it together for you.. if you have any feature requests for it, feel free to ask...


-BH
Homepage: www.bottledhate.webhop.org

Compiling  Lua scripts is LAME!!!!!

Flux

Very nice script and keeping with the original word replacement like on PtokaX.

Only one trhing I think is wrong and may need attention.

When replacing a word for example:

lol = laughing out loud

but in the replaced word u cannot have spaces unless with under score ( _)

Is there way have this changed so that you can use normal spaces in replaced word even if it's enclosed with *laughing out loud*

lol = *laughing out loud*

I think it will be best with no under score as spacing
? Official HoD Website - http://www.houseofdance.net
? Official HoD Hub Community -  hodhub.dyndns.org:2007

BottledHate

#5
QuoteOriginally posted by Flux
Very nice script and keeping with the original word replacement like on PtokaX.

Only one trhing I think is wrong and may need attention.

When replacing a word for example:

lol = laughing out loud

but in the replaced word u cannot have spaces unless with under score ( _)

Is there way have this changed so that you can use normal spaces in replaced word even if it's enclosed with *laughing out loud*

lol = *laughing out loud*

I think it will be best with no under score as spacing

i agree completly with you.. thanks for bringing that up.

done... edited above.


-BH
Homepage: www.bottledhate.webhop.org

Compiling  Lua scripts is LAME!!!!!

Flux

Also another one i have notice just now.

Example: ss = supersaver

well if u type in main chat to some one and have a word that has double ss in it (example: guess) then it will show like this guesupersaver...

I gather u must re-define letters on their own
? Official HoD Website - http://www.houseofdance.net
? Official HoD Hub Community -  hodhub.dyndns.org:2007

bastya_elvtars

Everything could have been anything else and it would have just as much meaning.

BottledHate

#8
hmmmmmm


while that does fix that bastya.. it doesn't do it the way i like.... because... what if i wanted to replace anything that contained "fuck" for example.... i woulnd't want to type in every instance of fuck.... so a better way to do it is define a way to make words absolute...

so.. in the above script i have changed it so that putting a "*" in front of the word you want replaced makes it absolute, and therefore can have nothing else around it.

-BH

cmd: !aword *ss SuperSaver

*** Word Replacce Bot v0.1: The word '*ss' will be replaced with 'SuperSaver'. *** 
 SuperSaver 
 SuperSaver 
 guess 
 ssmile 
 blah SuperSaver blah 
 blahssblah

cmd: !aword fuck having sex

*** Word Replacce Bot v0.1: The word 'fuck' will be replaced with 'having sex'. *** 
 having sex 
 having sexhaving sexhaving sex 
 dsa;jfns;zdfbnkjhaving sexlkhfdblaibsf
Homepage: www.bottledhate.webhop.org

Compiling  Lua scripts is LAME!!!!!

BottledHate

#9
updated... 100% lua compatible. (hopefully) :D

--//Word Replace Bot v0.2
--//By: BottledHate
--//Requested by: VAZ
--//20/09/04
--//18/09/04(first release)


---SNIP!---- get later a version...

-BH
Homepage: www.bottledhate.webhop.org

Compiling  Lua scripts is LAME!!!!!

Skyhawk

Hi!

Very nice script!

Hmmm can you modify it so it also replaces words in PM chats?

Thx in advance!

Madman

Great script.. One thing thoo.. I noticed while i tested it in my test hub...

My nick is Madman  Notice The big M in the begining...
but when i write a word that the scripts replace..
it writes with a small m....

[15:27:18] *** Word Replacce Bot v0.2: The word '*sunnis' will be replaced with 'Sunnis'. ***
[15:27:21] Sunnis
[15:27:29] sunnisssds
[15:27:45] *** Word Replacce Bot v0.2: The word '*sunis' will be replaced with 'Sunnis'. ***
[15:28:04] *** Word Replacce Bot v0.2: The word '*dide' will be replaced with 'Didde'. ***
[15:28:19] *** Word Replacce Bot v0.2: The word 'didde' will be replaced with 'Didde'. ***
[15:28:57] *** Word Replacce Bot v0.2: The word '*madman' will be replaced with 'Madman'. ***
[15:29:18] Madman
[15:29:24] Didde
[15:29:30] Sunnis
[15:29:36] we

Also tryed with the nick [DN]Madman
it ended up like this...
[15:32:45] <[dn]madman> Didde

Is It anyway to make it write my nick exactly as it should be? beacuse if a op write a word that will be replacd it will look like this... [op]nick  with IMO look ugly...
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

Skyhawk

#12
Sorry wrong thread [EDIT]

BottledHate

#13
QuoteIs It anyway to make it write my nick exactly as it should be? beacuse if a op write a word that will be replacd it will look like this... [op]nick with IMO look ugly...

fixed... :D

QuoteHmmm can you modify it so it also replaces words in PM chats?

done... :D


...new version works in pm's as well... (sender will alway see what they type in pm.. but recipient will get replaced words)
...fixed issue with usernames changing to lower case.

here it is:

--//Word Replace Bot v0.3
--//By: BottledHate
--//Requested by: VAZ
--//22/09/04
--//18/09/04(first release)

--//if using new pto w/ lua 5 erase this stuff...
string = {}
string.sub = strsub
string.find = strfind
string.gsub = gsub
string.len = strlen
string.lower = strlower
string.type = type
string.format = format
io = {}
io.open = openfile
io.close = closefile
io.write = write
os={}
os.execute = execute
os.clock = clock
table= {}
table.getn = getn
table.insert = tinsert
table.remove = tremove
math = {}
math.random = random
--// ok stop erasing!

rUserDefined = {
--//edit the stuff in quotes to your liking:
 --//(cmds are for ops only)
aWord = "!aword", --//  
rWord = "!rword", --//  
rHelp = "!rhelp", --//displays the help list
rView = "!rview", --//displays the current list of replace words.
--//OK STOP EDITING!
}
----------------------------------------
rFileName = "ReplaceBot.dat"
rTable = {}
rVer = "v0.3"
function DataArrival(user, data) 
   if (string.sub(data, 1, 1) == "<" ) then 
      data= string.sub(data,1,string.len(data)-1)
      ------------
      local _,_,c =strfind(data, "%b<>%s+(%S+)")
      if rcmdF[c] and user.bOperator then
         local _,_,c,p1,p2,p3=strfind(data, "%b<>%s+(%S+)%s*(%S*)%s*(.*)")
         rcmdF[c](user,p1,p2,p3)
         return 1
      end
      ------------
      local x = 0
      local _,_,data = strfind(data, "%b<>%s?(.*)")
      data = string.lower(data)
      x = rFunctions.doStuff(user,data)      
      if x == 1 then return 1 end
   elseif strsub(data, 1, 5) == "$To: " then 
      local s,e,to = strfind(data, "$To: (%S+)")
      local x=0
      local _,_,to,d =string.find(data, "$To:%s(%S+)%sFrom:%s%S+%s%$%b<> (.*)|")
      x = rFunctions.doStuff(user,d,to)      
      if x == 1 then return 1 end
   end
end
-------------------------
rFunctions = {
   doStuff = function(u,d,pm)
      local reply = d
      r = nil
      for k,v in rTable do
         x = k
         if string.sub(x,1,1) =="*" then
            x = string.gsub(k,"*","")
            rr = nil
            local msg = gsub(reply,"(%S+)",
            function (w)
               if w == x then
                  r,rr = 1,1
                  return rTable["*"..x]
               else
                  return w
               end
            end)
            if rr then reply = msg end               
         else
            if string.find(reply, x) then
               r = 1
               reply = string.gsub(reply,"("..x..")",v)
            end
         end
      end
      if r then
         if pm then
            GetItemByName(pm):SendData("$To: "..pm.." From: "..u.sName.." $<"..u.sName.."> "..reply.."|")
            return 1             
         else
            SendToAll(u.sName, reply)
            return 1 
         end
      end
   end,
   -------------------------   
   saveData = function(t,tn,file)
      local data = rFunctions.Serialize(t, tn, "")
      local f,e = io.open( file, "w+" ) 
      if f then
        io.write(f, data )
        io.close(f)
      end
   end,
   -------------------------   
   VerifyFile = function(file)
      local f,e = io.open(file, "a+" ) 
      if f then io.close(f) return 1
      else 
         local _,_,path = string.find(file, "(.+[/_\\]).+$") 
         if path ~= nil then os.execute("mkdir ".."\""..string.gsub(path, "/", "\\").."\"") end
         f,e = io.open( file, "a+" )
         if f then io.close(f) return 2
         else return 0 end
      end
   end,
   -------------------------
   Serialize = function(Table, sTableName, sTab)
      sTab = sTab or "";
      sTmp = ""
      sTmp = sTmp..sTab..sTableName.."={"
      local tStart = 0
      for key, value in Table do
         if tStart == 1 then
            sTmp = sTmp..",\r\n"
         else
            sTmp = sTmp.."\r\n"
            tStart = 1
         end
         local sKey = (string.type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key);
         if(type(value) == "table") then
            sTmp = sTmp..rFunctions.Serialize(value, sKey, sTab.."\t");
         else
            local sValue = (string.type(value) == "string") and string.format("%q",value) or tostring(value);
            sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
         end
      end
      sTmp = sTmp.."\r\n"..sTab.."}"
      return sTmp 
   end,
}

---------------------------------------
rcmdF = {
   [rUserDefined.aWord] = function(u,p1,p2)
      if p1 ~= "" then
         rTable[p1] = p2
         u:SendData("*** Word Replacce Bot "..rVer..": The word '"..p1.."' will be replaced with '"..p2.."'. ***")
         rFunctions.saveData(rTable,"rTable",rFileName)
      else
         u:SendData("*** Word Replacce Bot "..rVer..": Syntax Error. "..rUserDefined.rhelp.." for help. ***")
      end
   end,
-------------------------    
   [rUserDefined.rWord] = function(u,p1)
      if rTable[p1] then
         rTable[p1] = nil
         u:SendData("*** Word Replacce Bot "..rVer..": The word '"..p1.."' was removed from the words list. ***")
         rFunctions.saveData(rTable,"rTable",rFileName)
      else
         u:SendData("*** Word Replacce Bot "..rVer..": Error '"..p1.."' not on words list. "..rUserDefined.rView.." to view the words list. ***")
      end
   end,
-------------------------    
   [rUserDefined.rHelp] = function(u)
      u:SendData("*** Word Replacce Bot "..rVer.." ***\r\n\r\n"..
         "\t\t\t\t-=Help Menu=-\r\n\r\n"..
         "\t"..rUserDefined.aWord.."  \tAdds a word to the words list. (\"*\" in front of  makes  absolute.)\r\n"..
         "\t"..rUserDefined.rWord.." \t\t\tRemoves a word from the words list.\r\n"..
         "\t"..rUserDefined.rView.."\t\t\t\tShows the current words list.\r\n"..
         "\t"..rUserDefined.rHelp.."\t\t\t\tTHIS.\r\n\r\n")
   end,
------------------------- 
   [rUserDefined.rView] = function(u)
      local x = "*** Word Replacce Bot "..rVer.." ***\r\n\r\n"..
         "\t\t-=Current Words List=-\r\n"..
         "\t  Word\t\t-\t  Replace Word\r\n"..
         "\t------------------------------------------------------------\r\n"
      for k,v in rTable do
         if string.len(k) >= 7 then
            x = x.."\t"..k.."\t-\t"..v.."\r\n"
         else
            x = x.."\t"..k.."\t\t-\t"..v.."\r\n"
         end
      end
      u:SendData(x)
   end
}
-------------------------
local r = rFunctions.VerifyFile(rFileName)
if r ==1 then
   dofile(rFileName)
end

--//Word Replacce Bot v0.3, by BottledHate (22/09/04)

-BH
Homepage: www.bottledhate.webhop.org

Compiling  Lua scripts is LAME!!!!!

Flux

right I really want to use this script but face one problem with this.

I use many scripts but I will tell you the important ones that may have complications with ur script that I face..

LEECHBLOCKER 02
NAMECHECKER 02
Glory Securitaz 1.9(precompiled).td5.lua

when I install ur script and change the command from ! to anything else like @ or + and start the script I face one problem

When I come to register a user strarting with +reg comand it won't work as ur script disables something.

even if i leave ur script command alone.

any ideas what this could be..
? Official HoD Website - http://www.houseofdance.net
? Official HoD Hub Community -  hodhub.dyndns.org:2007

BottledHate

that was my fault.. used a different method in v0.3 to
 replace some words... and it messed up that part...
updated above ... your commands should all go through
fine now.

Thanks alot for testing and reporting back issues and feature requests!

-BH
Homepage: www.bottledhate.webhop.org

Compiling  Lua scripts is LAME!!!!!

Flux

well unfortunately it still disables my reg command I really don't understand why this is really even if I change the reg command it still is disabled from ur script.

Damn this is really annoying me as I do want to use ur script but it just disables my reg command...
? Official HoD Website - http://www.houseofdance.net
? Official HoD Hub Community -  hodhub.dyndns.org:2007

BottledHate

#17
what is your reg command?? i've been able to use all of my hub commands since the updated versoin above.

-BH


edit: i made some more changes to script above .. give it another try if you don't mind... :D -BH
Homepage: www.bottledhate.webhop.org

Compiling  Lua scripts is LAME!!!!!

Flux

Well I have done a quick check with ur latest modification script & it works at last with my reg command...

Now I will add some word replacements and test the script fully and I will get back to you with my final comment ;)

thanx
? Official HoD Website - http://www.houseofdance.net
? Official HoD Hub Community -  hodhub.dyndns.org:2007

Flux

found another prob not with me tho with the script

right i have added a word hi to be replaced with Hi

and also with

lol replaced with laughing out loud

but it turns up like this

laugHing out loud

Can that be rectified
? Official HoD Website - http://www.houseofdance.net
? Official HoD Hub Community -  hodhub.dyndns.org:2007

Madman

remove hi and add *hi and replace it with Hi
The * makes the word absolut
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

Flux

hehehe cheers for that. I am so stupid lol ;)

Anyway it works perfectly now and no more interruptions or complications with other scripts ;)

Thank you once again for making this script as PtokaX inbuilt one on the latest dubug version does not work and I used to use it alot on previous versions of PtokaX.

You see this script helps alot in our hub to make short hand links to big usernames etc...

Thanx Again..
? Official HoD Website - http://www.houseofdance.net
? Official HoD Hub Community -  hodhub.dyndns.org:2007

BottledHate

i'm glad the script is working well for you now.. thankyou for all of the feedback and feature requests, the script wouldn't be what it is without it. :D  If you find any other errors or have any new feature requests please let me know :)


-BH
Homepage: www.bottledhate.webhop.org

Compiling  Lua scripts is LAME!!!!!

VAZ

hi again this script is great bottledhate

it would be nice if it could replace words in e-mail and description 2 and all that stuff like connection and nick!

thanks!

BottledHate

QuoteOriginally posted by VAZ
hi again this script is great bottledhate

it would be nice if it could replace words in e-mail and description 2 and all that stuff like connection and nick!

thanks!

due to restrictions in the scripting api, replacing words in the users description and email would not be 100% accurate.... and even so, the less than perfect way would consume more memory and cpu cycles than this script should.   :D

-BH
Homepage: www.bottledhate.webhop.org

Compiling  Lua scripts is LAME!!!!!

SMF spam blocked by CleanTalk