a little change on a download blocker script
 

a little change on a download blocker script

Started by HaL, 03 January, 2004, 04:15:20

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

HaL

code:



    aNicks = {
    ["Nick1"] = 1,
    ["Nick2"] = 1,
    ["Nick3"] = 1,
    }


    function Main()
    frmHub:EnableFullData(1)
    end

    function DataArrival(curUser, data)
    if (strsub(data, 1, 1) == "$" and strfind(data, "ConnectToMe") and not aNicks[curUser.sName]) then
    return 1
    end
    end


could someone change this script (original by chilla)
that the list of aNicks is in an extra file like xNicks.txt
so that the list of nicks could managed with cmd?s like

!addnick Fart  

and

!listnicks

and

!delnick Fart

this board is great and his posters are greater
thx 4 all your work
greetz HaL

NightLitch

#1
Here you go, Hope you like it...

Download it here to:

Download

-- By NightLitch 2004
-- Create a folder namned ( nicks )
-- File will be created by it self when adding users...
-----------------------------------------------------
-- Set BotName
BotName = "Samus"
-- Set File Name
File = "nicks/aNick.txt"
-- Set Prefix
Prefix = "!"
-- Set Commands
cmd1 = Prefix.."addnick"
cmd2 = Prefix.."delnick"
cmd3 = Prefix.."listnicks"
-----------------------------------------------------
-- Tables
aNicks = { }
-- Main
function Main() 
	LoadTable(aNicks,File)
	frmHub:EnableFullData(1) 
end 
-- Data Arrival
function DataArrival(curUser, data) 
	if (strsub(data, 1, 1) == "$" and strfind(data, "ConnectToMe") and not aNicks[curUser.sName]) then 
		return 1 
	elseif (strsub(data, 1, 1) == "<" ) then 
		data=strsub(data,1,strlen(data)-1) 
		local _,_,cmd=strfind(data, "%b<>%s+(%S+)") 
		if not cmd then cmd = "0" end 
		cmd = strlower(cmd) 
		if (cmd == cmd1) then
			DoAddNick(curUser,data)
			return 1
		elseif (cmd == cmd2) then
			DoDelNick(curUser,data)
			return 1
		elseif (cmd == cmd3) then
			DoShowNicks(curUser,data)
			return 1
		end
	end
end 
--------------[ Add Nick to File/Table
function DoAddNick(curUser,data)
	local _,_,Name =strfind(data, "%b<>%s+%S+%s+(%S+)") 
	if Name == nil or Name == "" then
		curUser:SendData(BotName,"Usage: !addnick ")
		return 1
	else
		aNicks[Name] = 1
		local handle = openfile(File, "a")
		write(handle,Name.."\n")
		closefile(handle)
		curUser:SendData(BotName,"You have added: "..Name.." to aNick List")
	end
end
--------------[ Del Nick from File/Table
function DoDelNick(curUser,data)
	s,e,Name = strfind( data, "%b<>%s+%S+%s+(%S+)" )
	if Name == nil or Name == "" then
		curUser:SendData(BotName,"Usage: !delnick ")
	else
		if aNicks[Name] then
			aNicks[Name]=nil
			local handle = openfile(File, "w")
			for Nick, space in aNicks do
				write(handle,Nick.."\r\n")
			end
			closefile(handle)
			curUser:SendData(BotName,"You have deleted: "..Name.." from aNick List")
		else
			curUser:SendData(BotName,"Nick: "..Name.." is not found in aNick List")
		end
	end
end
--------------[ Show Nick List
function DoShowNicks(curUser,data)
	curUser:SendData(BotName,"	           aNick List         ")
	curUser:SendData(BotName,"	--===================--")
	local temp = {}
	for nick, id in aNicks do
		tinsert(temp, nick)
	end
	sort(temp)
	for i=1,getn(temp) do 
		local _,_,Names = strfind(temp[i],"(%S+)")
		curUser:SendData(BotName,"   "..i..".  "..Names)
	end
	curUser:SendData(BotName,"	--===================--")
end
--------------[ Load File/Table
function LoadTable(table,file)
	local handle = openfile(file, "r")
	if (handle) then
    		local line = read(handle)
    		while line do
			s,e,Name = strfind( line, "(.*)")
			table[Name]=1
			line = read(handle)
    		end
  		closefile(handle)
	end
end
-- NightLitch 2004
//NL

HaL

Yes it?s great NightLitch !

Thx 4 your time...

SMF spam blocked by CleanTalk