AntiReg
 

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

AntiReg

Started by Madman, 27 February, 2006, 00:50:37

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Madman

-- AntiReg by Madman
-- On request by Q??K, 21.01.06
-- Added: Showall cmd, 25.01.06

Bot = "AntiReg"
File = "AntiReg.txt"
-- Cmd's
NoReReg = "norereg"
ShowNoReReg = "shownorereg"
ShowAll = "showall"

function Main()
	frmHub:RegBot(Bot)
	local file = io.open(File)
	if file then
		file:close()
	else
		local file = io.open(File, "w+")
		file:write("AntiReg = {\n}")
		file:close()
	end
	LoadFromFile(File)
end

function ChatArrival(curUser, data)
	local data = string.sub(data, 1, -2)
	local s,e,prfx,cmd = string.find(data, "%b<>%s+(%p)(%S+)")
	if cmd and curUser.bOperator then
		local tCmds = {
		[NoReReg] = function(curUser, data)
			local s,e,Nick,Reason = string.find(data, "%b<>%s+%S+%s+(%S+)%s+(.+)")
			if Nick and Reason then
				Nick = string.lower(Nick)
				if AntiReg[Nick] == nil then
					AntiReg[Nick] = {}
					AntiReg[Nick]["Reason"] = {}
					AntiReg[Nick]["AddBy"] = {}
					AntiReg[Nick]["Reason"] = Reason
					AntiReg[Nick]["AddBy"] = curUser.sName
					curUser:SendData(Bot, Nick.. " has been added with reason: " ..Reason)
					SaveToFile(File, AntiReg, "AntiReg") return 1
				else
					curUser:SendData(Bot, Nick.. " was allready in the table with the reason: " ..AntiReg[Nick]["Reason"].. " added by " ..AntiReg[Nick]["AddBy"])
				end
			end
			curUser:SendData(Bot, "Syntax: "..prfx..cmd.. " <Nick> <Reason>") return 1
		end,
		[ShowNoReReg] = function(curUser, data)
			local s,e,Nick = string.find(data, "%b<>%s+%S+%s+(%S+)")
			if Nick then
				Nick = string.lower(Nick)
				if AntiReg[Nick] == nil then
					curUser:SendData(Bot, Nick.. " is not in the list") return 1
				else
					curUser:SendData(Bot, Nick.. " is in the list with the reason: " ..AntiReg[Nick]["Reason"].. " addded by " ..AntiReg[Nick]["AddBy"]) return 1
				end
			else
				curUser:SendData(Bot, "Syntax: "..prfx..cmd.. " <Nick>") return 1
			end
		end,
		[ShowAll] = function(curUser, data)
			for i,_ in AntiReg do
				curUser:SendPM(Bot, "Nick: " ..i.. " added by: " ..AntiReg[i]["AddBy"].. " with the reason: " ..AntiReg[i]["Reason"])
			end
			return 1
		end,
		}
		if tCmds[cmd] then
			return tCmds[cmd](curUser, data)
		end
	end
end


-- Serialize by nErBoS
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(filename)
	local f = io.open(filename)
	if f then
		local r = f:read("*a")
		f:flush()
		f:close()
		local func,err = loadstring(r)
		if func then x,err = pcall(func) end
	end
end
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

SMF spam blocked by CleanTalk