Help me with this download block 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

Help me with this download block script

Started by Djdirect, 22 February, 2007, 21:10:53

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Djdirect

Bonjour a vous

I need right click menu please for !block  !delblock  and  !blocklist ex: menu=Block user and submenu = commands

merci

--[[
		Download Blocker v1.0a by [AT]conejodelmal Lua 5.1
		
	Blocks users by nick
		Commands:
			!block <nick> - Blockes nick
			!delblock <nick> - Unblok nick
			!blocklist - Blocklist
]]--

  
sBot = frmHub:GetHubBotName() 
  
arrBlock = {}   
 
fBlock = "logs/block.dat"  
 

AllowedProfiles = { 
	[0] = 1,   -- Master
	[1] = 1,   -- OP
	[2] = 0,   -- VIP
	[3] = 0,   -- Reg
	[4] = 1,   -- Moderator
	[5] = 1,   -- Net Founder
	[6] = 1,   -- Owner

}

function Main()  
	LoadFromFile(fBlock)  
end  
 
function OnExit()  
	SaveToFile(fBlock , arrBlock , "arrBlock")  
end  
  
function ChatArrival(user, data)  
	if (AllowedProfiles[user.iProfile] == 1) then
		data = string.sub(data,1,string.len(data)-1)   
		s,e,cmd = string.find(data, "%b<>%s+(%S+)")   
		if (cmd == "!block") then   
			BlockUser(user, data)   
			return 1   
		elseif (cmd == "!delblock") then   
			RemoveBlock(user, data)   
			return 1   
		elseif (cmd == "!blocklist") then   
			BlockList(user)   
			return 1   
		end  
	end  
end  
  
ToArrival = ChatArrival  
  
function BlockUser(user, data)   
	local s,e,nick = string.find(data, "%b<>%s+%S+%s+(%S+)")   
	if (nick == nil) then   
		user:SendData(sBot, "Syntax Error, !block <nick>. You got to type a nick.")   
		return 1
		end
	if (arrBlock[string.lower(nick)] ~= nil) then   
		user:SendData(sBot, "User "..nick.." is already BLOCKED.") 
		return 1
	else     
		arrBlock[string.lower(nick)] = user.sName 
		user:SendData(sBot, "User "..nick.." is now being BLOCKED.")  
		SaveToFile(fBlock , arrBlock , "arrBlock")  
		return 1
	end
end   
  
function RemoveBlock(user, data)   
	local s,e,nick = string.find(data, "%b<>%s+%S+%s+(%S+)")   
	if (nick == nil) then   
		user:SendData(sBot, "Syntax Error, !delblock <nick>. You got to type a nick")  
		return 1
		end
	if (arrBlock[string.lower(nick)] == nil) then   
		user:SendData(sBot, "User "..nick.." isn't blocked.") 
		return 1
	else 
		arrBlock[string.lower(nick)] = nil  
		user:SendData(sBot, "User "..nick.." was UNBLOCKED")   
		SaveToFile(fBlock , arrBlock , "arrBlock")  
		return 1
	end   
end   
  
function BlockList(user)   
	local sTmp,op,usr = "List of users that are being blocked:\r\n\r\n"   
	for usr in pairs(arrBlock) do   
		sTmp = sTmp.."\t\tUser: "..usr.."\r\n"
	end  
	user:SendPM(sBot, sTmp)   
end   
  
function ConnectToMeArrival(user, data)
	local data = string.sub(data,1,-2);
	local s,e,nick = string.find(data,"%S+%s+(%S+)");
	nick = GetItemByName(nick);
	if (nick == nil) then
		return 1
	else
		if (arrBlock[string.lower(user.sName)] ~= nil) then
			return 1
		end
	end
end


RevConnectToMeArrival = ConnectToMeArrival

 
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 pairs(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

SMF spam blocked by CleanTalk