a little change on a download blocker 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

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