leechbot
 

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

leechbot

Started by johny, 22 March, 2005, 00:04:50

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

johny

ok guy's i tryed to confert this script but i ended up with a total fucked up script.
plz help me out with this script.
--100% Blocker by chill
--Table Load and Save (added by nErBoS)

sBot = "[fow]-Leech"

cmd1 = "!block"
cmd2 = "!unblock"
cmd3 = "!laatzien"


BlockedNicks = {}
fBlock = "block.dat"
OpChatName = frmHub:GetOpChatName()	--Use this line for inbuilt Px opchat


--## Configuration ##--

uLaterPtokax = 0	-- Choose 0 if you are using Ptokax Version 0.3.3.0 or higher
			-- Choose 1 if you are using Ptokax Version lower then 0.3.3.0

--## END ##--

function Main()
--	frmHub:RegBot(sBot)
	frmHub:EnableFullData(1) 
	LoadFromFile(fBlock)
end

function OnExit()
	SaveToFile(fBlock , BlockedNicks , "BlockedNicks")
end

BlockTriggs = {
	["$Rev"] = 1,
	["$Con"] = 2,
}

function DataArrival(curUser,data)
	if strsub(data,1,1) == "$" then
		local str1 = strsub(data,1,4)
		if BlockTriggs[str1] then
			if BlockedNicks[strlower(curUser.sName)] then
				curUser:SendData("*** You are not authorized to download.")
				return 1
			else if BlockTriggs[str1] == 1 then
				local _,_,conNick = strfind(data,"(%S+)|$")
				if BlockedNicks[strlower(conNick)] then
					curUser:SendData("*** The user "..conNick.." you are trying to download from is not authorized to upload.")
					return 1
				end
			else if BlockTriggs[str1] == 2 then
				local _,_,conNick = strfind(strsub(data,14,strlen(data)),"^(%S+)")
				if BlockedNicks[strlower(conNick)] then
					curUser:SendData("*** The user "..conNick.." you are trying to download from is not authorized to upload.")
					return 1
				end
			end
			end
			end
		end
	end
--	if (strsub(data,1,1) == "<" or strsub(data,1,5+strlen(sBot)) == "$To: "..sBot) and curUser.iProfile == 5 or curUser.iProfile == 0 then
	if (strsub(data,1,1) == "<" or strsub(data,1,5+strlen(sBot)) == "$To: "..sBot) and curUser.bOperator then
		data = strsub(data,1,strlen(data)-1)
		local _,_,cmd = strfind(data,"%b<>%s+(%S+)")
		local _,_,nick = strfind(data,"%b<>%s+%S+%s+(%S+)")
		if cmd and cmd == cmd2 and nick then
			if BlockedNicks[strlower(nick)] then
				BlockedNicks[strlower(nick)] = nil
				SendPmToOps(OpChatName, nick.." is now unblocked.")
				return 1
			end
		elseif cmd and cmd == cmd1 then
			if BlockedNicks[strlower(nick)] == 1 then
				curUser:SendPM(sBot, nick.." is already blocked. Use !unblock  to unblock this user.")
				return 1 
			else
				BlockedNicks[strlower(nick)] = curUser.sName
				SendPmToOps(OpChatName, nick.." is now blocked.") 
				return 1
			end
			if (uLaterPtokax == 1) then
				OnExit()
			end
				
			return 1  -- TELLS THE HUB TO STOP PROCESSING THE DATA
		elseif (cmd and cmd == cmd3 and curUser.bOperator) then
			local sTmp,aux,nick = "Users Blocked in this HUB:\r\n\r\n"
			for nick, aux in BlockedNicks do
				sTmp = sTmp.."User:-->> "..nick.."\t Was Blocked by: "..aux.."\r\n"
			end
			--curUser:SendPM(sBot, sTmp)
			SendPmToOps(OpChatName, sTmp) 
			return 1		
		end
	end
end



function Serialize(tTable, sTableName, sTab)
	assert(tTable, "tTable equals nil");
	assert(sTableName, "sTableName equals nil");
	assert(type(tTable) == "table", "tTable must be a table!");
	assert(type(sTableName) == "string", "sTableName must be a string!");
	sTab = sTab or "";
	sTmp = ""
	sTmp = sTmp..sTab..sTableName.." = {\n"
	for key, value in tTable do
		local sKey = (type(key) == "string") and format("[%q]",key) or format("[%d]",key);
		if(type(value) == "table") then
			sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
		else
			local sValue = (type(value) == "string") and format("%q",value) or tostring(value);
			sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
		end
		sTmp = sTmp..",\n"
	end
	sTmp = sTmp..sTab.."}"
	return sTmp
end

function SaveToFile(file , table , tablename)
	writeto(file)
	write(Serialize(table, tablename))
	writeto()
end

function LoadFromFile(file)
	if (readfrom(file) ~= nil) then
		readfrom(file)
		dostring(read("*all"))
		readfrom()
	end
end

jiten

#1
Try this one:

--100% Blocker by chill
-- converted to LUA 5 by jiten
--Table Load and Save (added by nErBoS)


sBot = "[fow]-Leech"

cmd1 = "!block"
cmd2 = "!unblock"
cmd3 = "!laatzien"


BlockedNicks = {}
fBlock = "block.dat"
OpChatName = frmHub:GetOpChatName()	--Use this line for inbuilt Px opchat


--## Configuration ##--

uLaterPtokax = 0	-- Choose 0 if you are using Ptokax Version 0.3.3.0 or higher
			-- Choose 1 if you are using Ptokax Version lower then 0.3.3.0

--## END ##--

function Main()
	frmHub:RegBot(sBot)
	LoadFromFile(fBlock)
end

function OnExit()
	SaveToFile(fBlock , BlockedNicks , "BlockedNicks")
end

BlockTriggs = {
	["$Rev"] = 1,
	["$Con"] = 2,
}

function ChatArrival(curUser,data)
	if string.sub(data,1,1) == "$" then
		local str1 = string.sub(data,1,4)
		if BlockTriggs[str1] then
			if BlockedNicks[string.lower(curUser.sName)] then
				curUser:SendData("*** You are not authorized to download.")
				return 1
			else if BlockTriggs[str1] == 1 then
				local _,_,conNick = string.find(data,"(%S+)|$")
				if BlockedNicks[string.lower(conNick)] then
					curUser:SendData("*** The user "..conNick.." you are trying to download from is not authorized to upload.")
					return 1
				end
			else if BlockTriggs[str1] == 2 then
				local _,_,conNick = string.find(string.sub(data,14,string.len(data)),"^(%S+)")
				if BlockedNicks[string.lower(conNick)] then
					curUser:SendData("*** The user "..conNick.." you are trying to download from is not authorized to upload.")
					return 1
				end
			end
			end
			end
		end
	end
--	if (string.sub(data,1,1) == "<" or string.sub(data,1,5+string.len(sBot)) == "$To: "..sBot) and curUser.iProfile == 5 or curUser.iProfile == 0 then
	if string.sub(data,1,1) == "<" and curUser.bOperator then
		data = string.sub(data,1,string.len(data)-1)
		local _,_,cmd = string.find(data,"%b<>%s+(%S+)")
		local _,_,nick = string.find(data,"%b<>%s+%S+%s+(%S+)")
		if cmd and cmd == cmd2 and nick then
			if BlockedNicks[string.lower(nick)] then
				BlockedNicks[string.lower(nick)] = nil
				SendPmToOps(OpChatName, nick.." is now unblocked.")
				return 1
			end
		elseif cmd and cmd == cmd1 then
			if BlockedNicks[string.lower(nick)] == 1 then
				curUser:SendPM(sBot, nick.." is already blocked. Use !unblock  to unblock this user.")
				return 1 
			else
				BlockedNicks[string.lower(nick)] = curUser.sName
				SendPmToOps(OpChatName, nick.." is now blocked.") 
				return 1
			end
			if (uLaterPtokax == 1) then
				OnExit()
			end
				
			return 1  -- TELLS THE HUB TO STOP PROCESSING THE DATA
		elseif (cmd and cmd == cmd3 and curUser.bOperator) then
			local sTmp,aux,nick = "Users Blocked in this HUB:\r\n\r\n"
			for nick, aux in BlockedNicks do
				sTmp = sTmp.."User:-->> "..nick.."\t Was Blocked by: "..aux.."\r\n"
			end
			--curUser:SendPM(sBot, sTmp)
			SendPmToOps(OpChatName, sTmp) 
			return 1		
		end
	end
end

function ToArrival(curUser,data)
	if string.sub(data,1,5+string.len(sBot)) == "$To: "..sBot and curUser.bOperator then
		data = string.sub(data,1,string.len(data)-1)
		local _,_,cmd = string.find(data,"%b<>%s+(%S+)")
		local _,_,nick = string.find(data,"%b<>%s+%S+%s+(%S+)")
		if cmd and cmd == cmd2 and nick then
			if BlockedNicks[string.lower(nick)] then
				BlockedNicks[string.lower(nick)] = nil
				SendPmToOps(OpChatName, nick.." is now unblocked.")
				return 1
			end
		elseif cmd and cmd == cmd1 then
			if BlockedNicks[string.lower(nick)] == 1 then
				curUser:SendPM(sBot, nick.." is already blocked. Use !unblock  to unblock this user.")
				return 1 
			else
				BlockedNicks[string.lower(nick)] = curUser.sName
				SendPmToOps(OpChatName, nick.." is now blocked.") 
				return 1
			end
			if (uLaterPtokax == 1) then
				OnExit()
			end
				
			return 1  -- TELLS THE HUB TO STOP PROCESSING THE DATA
		elseif (cmd and cmd == cmd3 and curUser.bOperator) then
			local sTmp,aux,nick = "Users Blocked in this HUB:\r\n\r\n"
			for nick, aux in BlockedNicks do
				sTmp = sTmp.."User:-->> "..nick.."\t Was Blocked by: "..aux.."\r\n"
			end
			--curUser:SendPM(sBot, sTmp)
			SendPmToOps(OpChatName, sTmp) 
			return 1		
		end
	end
end

function Serialize(tTable, sTableName, sTab)
        assert(tTable, "tTable equals nil");
        assert(sTableName, "sTableName equals nil");

        assert(type(tTable) == "table", "tTable must be a table!");
        assert(type(sTableName) == "string", "sTableName must be a string!");

        sTab = sTab or "";
        sTmp = ""

        sTmp = sTmp..sTab..sTableName.." = {\n"

        for key, value in tTable do
                local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key);

                if(type(value) == "table") then
                        sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
                else
                        local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value);
                        sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
                end

                sTmp = sTmp..",\n"
        end

        sTmp = sTmp..sTab.."}"
        return sTmp
end

function SaveToFile(file , table , tablename)
	local handle = io.open(file,"w+")
        handle:write(Serialize(table, tablename))
	handle:flush()
        handle:close()
end

function LoadFromFile(file)
	local handle = io.open(file,"r")
	if (handle ~= nil) then
                dofile(file)
		handle:flush()
		handle:close()
        end
end


Best regards.

johny

#2
thanks man, dunno what i did wrong but it works.
but there is just one lil prob.
it's only been written to the file after i blokked one and did a restartscript's.
 and it seems too that the one who is set as blocked is not blocked at all.

metallic

i have the same problem and i already had it done so far but dunno how to fix it :S it doesnt block and it doesnt report it in the .dat file only when i restart script and then it isnt in the !laatzien command  ;(

Greetz Metallic

jiten

I'm gonna have a look at it later...
Meanwhile, check these related scripts Here, here, and here.

Best regards.

johny

#5
hehehe, ok sir seen them all now but these files are not what we had in mind, this bot works differend from the others.

metallic

have looked at the scripts but those scripts are already in robocop 10.01b so dont need them thanks anyway.

Greetz Metallic

jiten

Well, conversion complete.
Check this thread .

Cheers

johnynl

Wheeeee man thanks now it work perfect again
Yeah yeah ok
I am alway\'s running the latest Robocop version.
Im running Ptokax 0.3.3.0 build 17.05[debug]
Powered by: Robocop RCv10.01e

plz visit our hub at cccl-nl.no-ip.org:411

jiten


SMF spam blocked by CleanTalk