Reg Online Check
 

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

Reg Online Check

Started by Madman, 27 February, 2006, 01:01:44

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Madman

-- Reg Online Check
-- Made by Madman
-- Requested by TiMeTrAVelleR
-- Added a 2nd Cmd, 29.01.06

-- OBS! Script must be placed above script with the reg command

RegCmd = "regreg" -- Cmd you use to reg with
RegCmd2 = "regvip"  -- Cmd you use to reg with
DelCmd = "delonline" -- Delete user from online check
RegFile = "RegOnline.txt" -- Where to store the Onlinechecks
Bot = frmHub:GetHubBotName() -- Botname
-- Sets who can add regusers
Allowed = {
	[0] = 1,	-- Master
	[1] = 1,	-- Operator
	[2] = 1,	-- VIPs
	[3] = 1,	-- Regs
}

function Main()
	local file = io.open(RegFile) -- There is a file?
	if file then -- Yes
		file:close() -- Good, close it
	else -- Nope
		local file = io.open(RegFile, "w+") -- Create it
		file:write("tRegged = {\n}") -- Write Table in it
		file:close() -- close it
	end
	frmHub:RegBot(Bot) -- Reg bot
	LoadFromFile(RegFile) -- Load table from file
end

function ChatArrival(curUser, data)
	local data = string.sub(data, 1, -2)
	local s,e,cmd = string.find(data, "%b<>%s+[%!%+%?%#](%S+)")
	if cmd then
		tCmds = {
		[RegCmd] = function(curUser, data)
			if Allowed[curUser.iProfile] == 1 then
				local s,e,Nick = string.find(data, "%b<>%s+%S+%s+(%S+)") -- Get Nick
				if Nick and not frmHub:isNickRegged(Nick) then -- We got Nick and Nick is not regged
					Nick = string.upper(Nick)
					if tRegged[Nick] == nil then -- If Nick not in table
						tRegged[Nick] = {} -- Create
						tRegged[Nick] = curUser.sName -- Add op who regs
						SaveToFile(RegFile, tRegged, "tRegged") -- Save
					else
						tRegged[Nick] = curUser.sName
						SaveToFile(RegFile, tRegged, "tRegged")
					end
				end
			end
		end,
		[RegCmd2] = function(curUser, data)
			tCmds[RegCmd](curUser, data)
		end,
		[DelCmd] = function(curUser, data)
			if Allowed[curUser.iProfile] == 1 then
				local s,e,Nick = string.find(data, "%b<>%s+%S+%s+(%S+)") -- Get Nick
				if not Nick then -- No Nick
					curUser:SendData(Bot, "I need a nick to delete from online check") return 1 --- Tell us
				end
				tNick = string.upper(Nick)
				if not tRegged[tNick] then -- Got Nick but Nick was not in table
					curUser:SendData(Bot, Nick.. " was not in online check") return 1
				end
				if tRegged[tNick] then -- Got Nick and was in table
					tRegged[tNick] = nil -- But no more... ;)
					SaveToFile(RegFile, tRegged, "tRegged") -- Save file
					curUser:SendData(Bot, Nick.. " was deleted") return 1 -- Tell us that it was deleted
				end
			end
		end,
		}
		if tCmds[cmd] then
			return tCmds[cmd](curUser, data)
		end
	end
end

function NewUserConnected(curUser)
	Nick = string.upper(curUser.sName)
	if tRegged[Nick] then -- User is in table
		SendPmToOps(Bot,  curUser.sName.. "   Regged By " ..tRegged[Nick].. " Just Went Online For The First Time, Please Check His Share") -- Pm Ops
		tRegged[Nick] = nil -- Delte user from table
		SaveToFile(RegFile, tRegged, "tRegged") -- Save to file
	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