friendly wordreplacer
 

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

friendly wordreplacer

Started by -Dan-, 14 November, 2005, 12:34:41

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

-Dan-

could anyone help me fix this, so i can get it to reg in

user list again i removed it some time ago but i am now

using it again but it wont show up in user list :(

anyways here's the script i have--

-- word replacer script.
-- includes !me in pm.
-- all commands work in any pm window.
-- for PtokaX 0.3.3.0 16.06 and later.
-- version 1.2 public.
-- by plop

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

-- maximum lines stored in the chat history.
iHistory = 50

-- name of the bot.
sBot = '(BOT)'

-- regbot in the user list.
-- iRegBot = 1

-- prefixes table, allowed for me.
-- also used 2 bypase commands from other scripts.
tPre = { 
   ["+"] = 1,
   ["!"] = 1,
   ["/"] = 1,
   ["-"] = 1
}

tHistory = {}

tCommands = {

   ["showwords"] = {
	fCom = function(user, data)
	   local line = "\r\n\r\n\t\twords\r\n"
	   for a,b in tBadWords do
		line = line.."   "..a.."\t"..b.."\r\n"
	   end
	   line = line.."\r\n\t\tfunctions\r\n"
	   for a,b in tBadFuncs do
		line = line.."   "..a.."\r\n"
	   end
	   return line
	end,
	sHelp = "\t\t- shows all words which are replaced and for what.",
	tLevels = {
	   [0] = 1,
	   [1] = 1
	},
   },

   ["history"] = {
	fCom = function(user, data)
	   local sText = "\r\n\r\n"
	   for i=1,table.getn(tHistory) do
		sText = sText..tHistory[i].."\r\n"
	   end
	   return sText
	end,
	sHelp = "\t\t\t- shows the chat history.",
	tLevels = {
	   [0] = 1,
	   [1] = 1,
	   [2] = 1,
	   [3] = 1,
	   [-1] = 1,
	},
   },

   ["addword"] = {
	fCom = function(user,data)
	   local s,e, word, replaced = string.find(data, "%b<>%s*%S+%s*(%S*)%s*(.*)")
	   if word == "" then
		return "No word??"
	   elseif replaced == "" then
		return "replace "..word.." for what??"
	   elseif string.find(word, "plop") then
		user:Disconnect()
	   else
		word = Format(word)
		replaced = Format(replaced)
		tBadWords[word] = replaced
		Save(tBadWords, "tBadWords")
		return word.." will be replaced for "..replaced
	   end
	end,
	sHelp = "<word> <replaced>\t- adds the word and replaces it for replaced.",
	tLevels = {
	   [0] = 1,
	   [1] = 1,
	},
   },

   ["delword"] = {
	fCom = function(user,data)
	   local s,e, word = string.find(data, "%b<>%s*%S+%s*(%S*)")
	   if word == "" then
		return "No word??"
	   elseif not tBadWords[word] then
		return word.." didn't excist in the word replacer"
	   else
		tBadWords[word] = nil
		Save(tBadWords, "tBadWords")
		return word.." removed from the word replacer"
	   end
	   return 1
	end,
	sHelp = "<word>\t\t- removes the word from the replacer.",
	tLevels = {
	   [0] = 1,
	   [1] = 1,
	},
   },

   ["wordreplacer"] = {
	fCom = function(user,data)
	   local sText = "\r\n\r\n"
	   local iProf = user.iProfile
	   for a,b in tCommands do
		if b.tLevels[iProf] then
		   sText = sText.."\t!"..a.." "..b.sHelp.."\r\n"
		end
	   end
	   return sText
	end,
	sHelp = "\t\t- this help menu.",
	tLevels = {
	   [0] = 1,
	   [1] = 1,
	   [2] = 1,
	   [3] = 1,
	   [-1] = 1,
	},
   },
}

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

   --dofile("wordreplace/tLadys.lua")
   dofile("wordreplace/tBadWords.lua")
   dofile("wordreplace/tBadFunctions.lua")
   local fFile = io.open("wordreplace/tHistory.lua")
   if fFile then
	dofile("wordreplace/tHistory.lua")
	fFile:close()
   end
   if iRegBot then
	frmHub:RegBot(sBot, 1, "friendly wordreplacer<[URL]www.plop.nl[/URL]>", "lua.plop.nl")
   end
end

function CheckWord(word)
   local wordl = string.lower(word)
   if tBadWords[wordl] then
      return tBadWords[wordl]
   elseif tBadFuncs[wordl] then
      return tBadFuncs[wordl]()
   elseif tonumber(word) or string.find(word, "%W") then
      return word
   else
      return word
   end
end

function addHistory(text)
   if table.getn(tHistory) > iHistory then
      table.remove(tHistory, 1)
   end
   table.insert(tHistory, text)
end

function ChatArrival(user, data) 
   local data = string.sub(data, 1, (string.len(data)-1))
   local s,e,cmd = string.find(data, "%b<>%s+%p(%S+)")
   if cmd and tCommands[cmd] then 
	if tCommands[cmd].tLevels[user.iProfile] then
	   user:SendData(sBot, tCommands[cmd].fCom(unpack({user, data})) )
	   return 1
	else
	   user:SendData(sBot, "no acces!!")
	   return 1
	end
   end
   if FilterMain then
	local s,e,data =string.find(data, "%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)(%w+)")
	if pre and cmd and tPre[pre] then
	   if cmd == "me" then
		local sText = "* "..user.sName.." "..string.sub(data, 5, string.len(data))
		SendToAll(sText)
		addHistory("["..os.date("%X").."] "..sText)
		return 1
	   else
		return 0
	   end
	else
	   local sText = "<"..user.sName.."> "..data
	   SendToAll(sText)
	   addHistory("["..os.date("%X").."] "..sText)
	   return 1
	end
   end
end


function ToArrival(user, data)
   local data = string.sub(data, 1, (string.len(data)-1))
   local s,e,cmd = string.find(data, "%$%b<>%s+%p(%S+)")
   local s,e,whoto = string.find(data, "%S+%s*(%S+)")
   local usr = GetItemByName(whoto)
   if cmd and tCommands[cmd] then
	if tCommands[cmd].tLevels[user.iProfile] then
	   if usr then
		user:SendData("$To: "..user.sName.." From: "..usr.sName.." $"..sBot.." "..tCommands[cmd].fCom(unpack({user, data})).."|")
	   else
		user:SendPM(sBot, tCommands[cmd].fCom(unpack({user, data})) )
	   end
	   return 1
	else
	   user:SendPM(sBot, "no acces!!")
	   return 1
	end
   end
   if FilterPm then
	if usr then
	   local sName = user.sName
	   local s,e,data = string.find(data, "$%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 pre and tPre[pre] then
		if cmd == "me" then
		   data = string.sub(data, 4, string.len(data))
		   usr:SendData("$To: "..usr.sName.." From: "..sName.." $* "..sName.." "..data.."|")
		   return 1
		else
		   return 0
		end
	   else
		usr:SendData("$To: "..usr.sName.." From: "..sName.." $<"..sName.."> "..data.."|")
		return 1
	   end
	end
   end
end

function OnError(ErrorMsg)
   SendToOps(sBot, ErrorMsg)
   local fFile = io.open("error/wordreplacer.lst", "a+")
   fFile:write(ErrorMsg.."\n")
   fFile:close()
end

function Save(tTable, name)
   local fFile = io.open("wordreplace/"..name..".lua", "w+")
   fFile:write(name.."={")
   for a,b in tTable do
	fFile:write("\t["..string.format("%q", a).."] = "..string.format("%q", b)..",\n")
   end
   fFile:write("\n}\n\n--plopyrights reserved")
   fFile:close()
   return "Done"
end

function OnExit()
   local fFile = io.open("wordreplace/tHistory.lua", "w+")
   fFile:write("tHistory={\n")
   for i=1,table.getn(tHistory) do
	fFile:write("\t"..string.format("%q", tHistory[i])..",\n")
   end
   fFile:write("\n}\n\n--plopyrights reserved")
   fFile:close()
end

function Format(sText)
   local sText = string.format("%q", sText)
   sText , iSlash = string.gsub(sText, "\\", "\r\n")
   sText = string.sub(sText, 2, (string.len(sText)-1))
   return sText
end


thanx..

Dessamator

#1
change this
sBot = '(BOT)'

-- regbot in the user list. 
-- iRegBot = 1

to this :
sBot ="(BOT)"
-- regbot in the user list. 
iRegBot = 1
Ignorance is Bliss.

-Dan-

sorted thanx m8

thats done the job  ;-)

Dessamator

Ignorance is Bliss.

SMF spam blocked by CleanTalk