is it possible to get word replace script?
because word replace manager does not work on my ptokax soft.. :(
thanks in advance.
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
Cool it works great thnx alot :]
wery nice script
no problem... glad i could put it together for you.. if you have any feature requests for it, feel free to ask...
-BH
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
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
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
i fixed it i guess, wont post here.
Link:
http://rnrdoctor.sytes.net/replace_fix.lua
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
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
Hi!
Very nice script!
Hmmm can you modify it so it also replaces words in PM chats?
Thx in advance!
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...
Sorry wrong thread [EDIT]
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
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..
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
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...
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
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
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
remove hi and add *hi and replace it with Hi
The * makes the word absolut
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..
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
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!
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
new version... 0.4
+abilty to turn main chat or pm wordreplace on or off...
+changed code around a bit... hopefully more efficient.
+added global bot on or off.
+something else i'm sure but i forget :D
--//Word Replace Bot v0.4
--//By: BottledHate
--//Requested by: VAZ
--//23/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 only the stuff in quotes to your liking:
--//(****COMMANDS are for OPS ONLY****)
aWord = "!aword", --// --//add a to the repace list. a "*" in front of the makes it absolute.
rWord = "!rword", --// --//remove a from the replace list.
rHelp = "!rhelp", --//displays the help list
rView = "!rview", --//displays the current list of replace words.
BotOnOff = "!rbot", --//toggle Word Replace Bot ON or OFF.
MainOnOff = "!rmain", --//toggle main chat word replace ON or OFF.
PmOnOff = "!rpm", --//toggle PM word replace ON or OFF.
--//OK STOP EDITING!
}
----------------------------------------
rFileName = "ReplaceBot.dat"
rSFileName = "ReplaceBotSet.dat"
rTable = {}
rSTable = {}
rSTable = {["MainOnOff"] = 1, ["PmOnOff"] = 0, ["BotOnOff"] = 1}
rVer = "v0.4"
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
------------
if rSTable.BotOnOff == 0 then return end
if rSTable.MainOnOff == 0 then return end
local x = nil
local _,_,data = strfind(data, "%b<>%s?(.*)")
data = string.lower(data)
x = rFunctions.doStuff(data)
if x then
SendToAll(user.sName, x)
return 1
end
elseif strsub(data, 1, 5) == "$To: " then
if rSTable.BotOnOff == 0 then return end
if rSTable.PmOnOff == 0 then return end
local s,e,to = strfind(data, "$To: (%S+)")
local x=nil
local _,_,to,d =string.find(data, "$To:%s(%S+)%sFrom:%s%S+%s%$%b<> (.*)|")
x = rFunctions.doStuff(d)
if x then
GetItemByName(to):SendData("$To: "..to.." From: "..user.sName.." $<"..user.sName.."> "..x.."|")
return 1
end
end
end
-------------------------
rFunctions = {
doStuff = function(d)
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
return reply
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)
local txtT = {[0] = "OFF", [1] = "ON"}
u:SendData("*** Word Replacce Bot "..rVer.." ***\r\n\r\n"..
"\t\t\t\t-=Bot Status=-\r\n\r\n"..
"\tThe Word Replace Bot is currently: "..txtT[rSTable.BotOnOff].." (global)\r\n"..
"\tMain Chat Word Replace Bot is currently: "..txtT[rSTable.MainOnOff].."\r\n"..
"\tPrivate Message Word Replace Bot is currently: "..txtT[rSTable.PmOnOff].."\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.BotOnOff.."\t\t\t\tToggles Word Replace Bot "..rVer.." ON or OFF. (settings are not changed)\r\n"..
"\t"..rUserDefined.MainOnOff.."\t\t\t\tToggles Main Chat word replace ON or OFF.\r\n"..
"\t"..rUserDefined.PmOnOff.."\t\t\t\tToggles Private Message word replace ON or OFF.\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,
-------------------------
[rUserDefined.BotOnOff] = function(u)
if rSTable.BotOnOff == 1 then
rSTable.BotOnOff = 0
u:SendData("*** Word Replacce Bot "..rVer..": Is now completly *OFF*. ***")
else
rSTable.BotOnOff = 1
u:SendData("*** Word Replacce Bot "..rVer..": Is now *ON*. ***")
end
rFunctions.saveData(rSTable,"rSTable",rSFileName)
end,
-------------------------
[rUserDefined.MainOnOff] = function(u)
if rSTable.MainOnOff == 1 then
rSTable.MainOnOff = 0
u:SendData("*** Word Replacce Bot "..rVer..": Main Chat toggled *OFF*. ***")
else
rSTable.MainOnOff = 1
u:SendData("*** Word Replacce Bot "..rVer..": Main Chat toggled *ON*. ***")
end
rFunctions.saveData(rSTable,"rSTable",rSFileName)
end,
-------------------------
[rUserDefined.PmOnOff] = function(u)
if rSTable.PmOnOff == 1 then
rSTable.PmOnOff = 0
u:SendData("*** Word Replacce Bot "..rVer..": PM toggled *OFF*. ***")
else
rSTable.PmOnOff = 1
u:SendData("*** Word Replacce Bot "..rVer..": PM Chat toggled *ON*. ***")
end
rFunctions.saveData(rSTable,"rSTable",rSFileName)
end,
}
-----------------------------------
local r = rFunctions.VerifyFile(rFileName)
if r ==1 then
dofile(rFileName)
end
local r = rFunctions.VerifyFile(rSFileName)
if r ==1 then
dofile(rSFileName)
end
--//Word Replacce Bot v0.4, by BottledHate (23/09/04)
-BH
hehe ok i understand.
Hello BH..
I found a little bug.. Dont know if anything u can do about it though...
Okey.. some background info.. Me and a freind got a hub each.. And i got a multi hub prg.. So our mainchats act as one..
This prg has to be a op.. i named it Multi..
My hub is called D1 and hes D2
Okey now to the bug... it is kind of the same bug i reported last.. ;p
I write this in D2
[23:03:39] <[DN]Madman> test av script... adn dide , sunis aaa
And in D1 is comes up as this
[23:03:41] {d2•[dn]madman } test av script... and Didde , Sunnis Japp
As u can see my named got smal letters again.... and D2 is writen in smal chars...
Can u fix it? or is the only way to tell my freind to use the script to?
*edit*
• is suposed to be a some kind of dot... It is the forum that dosn't support it..
Thanx in advance //Madman
the reason it does that is because it considers anything after the name to be text.... if you both ran the bot, it would solve that problem.... because the text will get fixed in the appropriate hub, before getting sent out to multi hub.
-BH
Okey.. Thats what i thought =) just had to ask...
or if you don't want to run it in both hubs.. here is a modded versoin for your multi hub based on the sample text provided above....
this version works as normal if you don't use multi hub.... only thing that is different is if it finds "{nick}" at the beginning of the text, it leaves it alone.
--//Word Replace Bot v0.4(multi)
--//By: BottledHate
--//Requested by: VAZ
--//25/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 only the stuff in quotes to your liking:
--//(****COMMANDS are for OPS ONLY****)
aWord = "!aword", --// --//add a to the repace list. a "*" in front of the makes it absolute.
rWord = "!rword", --// --//remove a from the replace list.
rHelp = "!rhelp", --//displays the help list
rView = "!rview", --//displays the current list of replace words.
BotOnOff = "!rbot", --//toggle Word Replace Bot ON or OFF.
MainOnOff = "!rmain", --//toggle main chat word replace ON or OFF.
PmOnOff = "!rpm", --//toggle PM word replace ON or OFF.
--//OK STOP EDITING!
}
----------------------------------------
rFileName = "ReplaceBot.dat"
rSFileName = "ReplaceBotSet.dat"
rTable = {}
rSTable = {}
rSTable = {["MainOnOff"] = 1, ["PmOnOff"] = 0, ["BotOnOff"] = 1}
rVer = "v0.4(multi)"
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*)")
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
------------
if rSTable.BotOnOff == 0 then return end
if rSTable.MainOnOff == 0 then return end
local x = nil
local multi = nil
local _,_,text = strfind(data, "%b<>%s?(.*)")
if string.sub(text, 1,1) == "{" then
_,_,multi,text = string.find(data,"%b<> (%bxy)%s?(.*)")
end
text = string.lower(text)
x = rFunctions.doStuff(text)
if x then
if multi then
SendToAll(user.sName, multi.." "..x)
return 1
else
SendToAll(user.sName, x)
return 1
end
end
elseif strsub(data, 1, 5) == "$To: " then
if rSTable.BotOnOff == 0 then return end
if rSTable.PmOnOff == 0 then return end
local s,e,to = strfind(data, "$To: (%S+)")
local x=nil
local _,_,to,d =string.find(data, "$To:%s(%S+)%sFrom:%s%S+%s%$%b<> (.*)|")
x = rFunctions.doStuff(d)
if x then
GetItemByName(to):SendData("$To: "..to.." From: "..user.sName.." $<"..user.sName.."> "..x.."|")
return 1
end
end
end
-------------------------
rFunctions = {
doStuff = function(d)
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
return reply
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)
local txtT = {[0] = "OFF", [1] = "ON"}
u:SendData("*** Word Replacce Bot "..rVer.." ***\r\n\r\n"..
"\t\t\t\t-=Bot Status=-\r\n\r\n"..
"\tThe Word Replace Bot is currently: "..txtT[rSTable.BotOnOff].." (global)\r\n"..
"\tMain Chat Word Replace Bot is currently: "..txtT[rSTable.MainOnOff].."\r\n"..
"\tPrivate Message Word Replace Bot is currently: "..txtT[rSTable.PmOnOff].."\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.BotOnOff.."\t\t\t\tToggles Word Replace Bot "..rVer.." ON or OFF. (settings are not changed)\r\n"..
"\t"..rUserDefined.MainOnOff.."\t\t\t\tToggles Main Chat word replace ON or OFF.\r\n"..
"\t"..rUserDefined.PmOnOff.."\t\t\t\tToggles Private Message word replace ON or OFF.\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,
-------------------------
[rUserDefined.BotOnOff] = function(u)
if rSTable.BotOnOff == 1 then
rSTable.BotOnOff = 0
u:SendData("*** Word Replacce Bot "..rVer..": Is now completly *OFF*. ***")
else
rSTable.BotOnOff = 1
u:SendData("*** Word Replacce Bot "..rVer..": Is now *ON*. ***")
end
rFunctions.saveData(rSTable,"rSTable",rSFileName)
end,
-------------------------
[rUserDefined.MainOnOff] = function(u)
if rSTable.MainOnOff == 1 then
rSTable.MainOnOff = 0
u:SendData("*** Word Replacce Bot "..rVer..": Main Chat toggled *OFF*. ***")
else
rSTable.MainOnOff = 1
u:SendData("*** Word Replacce Bot "..rVer..": Main Chat toggled *ON*. ***")
end
rFunctions.saveData(rSTable,"rSTable",rSFileName)
end,
-------------------------
[rUserDefined.PmOnOff] = function(u)
if rSTable.PmOnOff == 1 then
rSTable.PmOnOff = 0
u:SendData("*** Word Replacce Bot "..rVer..": PM toggled *OFF*. ***")
else
rSTable.PmOnOff = 1
u:SendData("*** Word Replacce Bot "..rVer..": PM Chat toggled *ON*. ***")
end
rFunctions.saveData(rSTable,"rSTable",rSFileName)
end,
}
-----------------------------------
local r = rFunctions.VerifyFile(rFileName)
if r ==1 then
dofile(rFileName)
end
local r = rFunctions.VerifyFile(rSFileName)
if r ==1 then
dofile(rSFileName)
end
--//Word Replacce Bot v0.4(multi), by BottledHate (25/09/04)
-BH
Yup it left the text alone.. so now if i write in D2 all in D1 will see how bad speller i'm... lol
if you put the script on both hubs and just give the "ReplaceBot.dat" to the other hub.. it contains all of your replace words.. then everything will be the same.
i hope everything works out ok... :D
-BH
Found a little bug...
We added hammarby and replaced it with AIK
The a clever Op realiced that if he wrote h-a-m-m-a-r-b-y it would get replaced.. so we added h-a-m-m-a-r-b-y to...
But beacuse of that every time someone wrote a y it was replaced with a AIK
*edit*
Found another bug..
the word scruffy is replaced with Scruffy
then if i use the the command !kenny
!kenny [OP]Scruffy
it shows !kenny [op]Scruffy in main.. and he does'nt get kennyed...
*edit 2*
Damm... The little letters are evil....
I wrote this..
[20:44:45] <[DN]Madman> nej d?.. bara onykter.....*ljuger*
and then a bart copyed it
[20:49:02] <[OP]Bart_simpson> "<[dn]Madman> nej d?.. bara onykter.....*ljuger*"
as u can see the my nick got [dn] again..
ok.. i completly redid the word replaceing function itself... and it should be all good now. it should effect any other words than the replace words....
--//Word Replace Bot v0.5
--//By: BottledHate
--//Requested by: VAZ
--//25/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 only the stuff in quotes to your liking:
--//(****COMMANDS are for OPS ONLY****)
aWord = "!aword", --// --//add a to the repace list. a "*" in front of the makes it absolute.
rWord = "!rword", --// --//remove a from the replace list.
rHelp = "!rhelp", --//displays the help list
rView = "!rview", --//displays the current list of replace words.
BotOnOff = "!rbot", --//toggle Word Replace Bot ON or OFF.
MainOnOff = "!rmain", --//toggle main chat word replace ON or OFF.
PmOnOff = "!rpm", --//toggle PM word replace ON or OFF.
--//OK STOP EDITING!
}
----------------------------------------
rFileName = "ReplaceBot.dat"
rSFileName = "ReplaceBotSet.dat"
rTable = {}
rSTable = {}
rSTable = {["MainOnOff"] = 1, ["PmOnOff"] = 0, ["BotOnOff"] = 1}
rVer = "v0.5"
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*)")
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
------------
if rSTable.BotOnOff == 0 then return end
if rSTable.MainOnOff == 0 then return end
local x = nil
local multi = nil
local _,_,text = strfind(data, "%b<>%s?(.*)")
if string.sub(text, 1,1) == "{" then
_,_,multi,text = string.find(data,"%b<> (%b{})%s?(.*)")
end
x = rFunctions.doStuff(text)
if x then
if multi then
SendToAll(user.sName, multi.." "..x)
return 1
else
SendToAll(user.sName, x)
return 1
end
end
elseif strsub(data, 1, 5) == "$To: " then
if rSTable.BotOnOff == 0 then return end
if rSTable.PmOnOff == 0 then return end
local s,e,to = strfind(data, "$To: (%S+)")
local x=nil
local _,_,to,d =string.find(data, "$To:%s(%S+)%sFrom:%s%S+%s%$%b<> (.*)|")
x = rFunctions.doStuff(d)
if x then
GetItemByName(to):SendData("$To: "..to.." From: "..user.sName.." $<"..user.sName.."> "..x.."|")
return 1
end
end
end
-------------------------
rFunctions = {
doStuff = function(d)
local reply = d
r = nil
for k,v in rTable do
x = k
if string.sub(x,1,1) =="*" then
x = string.sub(k,2)
reply = string.gsub(reply,"(%S+)",
function(w)
if string.lower(w) == x then
r = 1
return rTable["*"..x]
else
return w
end
end)
else
WRcnt = 0
local m = gsub(string.lower(reply),"(%S+)",
function (w)
if string.find(w,x) then
WRcnt = WRcnt + 1
end
end)
for y = -1,WRcnt do
local s,e = nil,nil
s,e = string.find(string.lower(reply), x)
if s then
r = 1
reply = string.sub(reply,1,s-1)..v..string.sub(reply,e+1)
end
end
end
end
if r then
return reply
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)
local txtT = {[0] = "OFF", [1] = "ON"}
u:SendData("*** Word Replacce Bot "..rVer.." ***\r\n\r\n"..
"\t\t\t\t-=Bot Status=-\r\n\r\n"..
"\tThe Word Replace Bot is currently: "..txtT[rSTable.BotOnOff].." (global)\r\n"..
"\tMain Chat Word Replace Bot is currently: "..txtT[rSTable.MainOnOff].."\r\n"..
"\tPrivate Message Word Replace Bot is currently: "..txtT[rSTable.PmOnOff].."\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.BotOnOff.."\t\t\t\tToggles Word Replace Bot "..rVer.." ON or OFF. (settings are not changed)\r\n"..
"\t"..rUserDefined.MainOnOff.."\t\t\t\tToggles Main Chat word replace ON or OFF.\r\n"..
"\t"..rUserDefined.PmOnOff.."\t\t\t\tToggles Private Message word replace ON or OFF.\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,
-------------------------
[rUserDefined.BotOnOff] = function(u)
if rSTable.BotOnOff == 1 then
rSTable.BotOnOff = 0
u:SendData("*** Word Replacce Bot "..rVer..": Is now completly *OFF*. ***")
else
rSTable.BotOnOff = 1
u:SendData("*** Word Replacce Bot "..rVer..": Is now *ON*. ***")
end
rFunctions.saveData(rSTable,"rSTable",rSFileName)
end,
-------------------------
[rUserDefined.MainOnOff] = function(u)
if rSTable.MainOnOff == 1 then
rSTable.MainOnOff = 0
u:SendData("*** Word Replacce Bot "..rVer..": Main Chat toggled *OFF*. ***")
else
rSTable.MainOnOff = 1
u:SendData("*** Word Replacce Bot "..rVer..": Main Chat toggled *ON*. ***")
end
rFunctions.saveData(rSTable,"rSTable",rSFileName)
end,
-------------------------
[rUserDefined.PmOnOff] = function(u)
if rSTable.PmOnOff == 1 then
rSTable.PmOnOff = 0
u:SendData("*** Word Replacce Bot "..rVer..": PM toggled *OFF*. ***")
else
rSTable.PmOnOff = 1
u:SendData("*** Word Replacce Bot "..rVer..": PM Chat toggled *ON*. ***")
end
rFunctions.saveData(rSTable,"rSTable",rSFileName)
end,
}
-----------------------------------
local r = rFunctions.VerifyFile(rFileName)
if r ==1 then
dofile(rFileName)
end
local r = rFunctions.VerifyFile(rSFileName)
if r ==1 then
dofile(rSFileName)
end
--//Word Replacce Bot v0.5, by BottledHate (26/09/04)
-BH
Okey.. i will give it a try efter school tomorrow.. i'm going to bed now...
Nope... It dont work... =(
[16:12] <[DN]Madman> [16:11] <[dn]Madman> test av script japp Con Didde Sunnis madman and Bart
my bad... forgot to remove one line. edited above.. and working now :D
-BH
Yes, working great.. Thankx =)
Hi gentlemen, I have been trying to use this word replace bot but with no success. Is it possble to post a biref explanation on how to install and acitvate this bot?
I am using ptokax 0.3.3.2.21 and a 0.3.3.0 build 15.25
I have made the modification suggested for use in Pto with LUA 5. I have placed replaceobt.dat in de root directory of ptokax and in the scrits directory along with the bot, what is it that I am doing wrong?
Thaks for you help