Terms & Conditions
 

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

Terms & Conditions

Started by CrazyGuy, 31 July, 2006, 14:47:47

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

CrazyGuy

--- This script forces connected people to agree with Terms & Conditions before they can do certain actions
--- Written by CrazyGuy
--- version 1.0
--- LUA 5.1
--- July 31st 2006
--- Please only edit lines in Settings part
--- Thnx to plop, Mutor for Serialize function

fPassed = "TCUserDB.tbl"
tPassed = {}
sAcceptDecline = " is disabled until you agree to the hub's Terms & Conditions\n\n\t\tType !accept to Accept , !decline to Decline or !terms to read them again"

-- Settings

fTerms = "terms.txt"		? -- name of file holding the Terms & Conditions
bCanSearch = 0			? -- 0 for disable, any other value for enable Search
bCanPM = 0			? -- 0 for disable, any other value for enable PM
bCanMainChat = 0		? -- 0 for disable, any other value for enable MainChat
bCanDownload = 0		? -- 0 for disable, any other value for enable Download
OpConnected = NewUserConnected?? ?-- remove this to exclude OPs from Terms & Conditions

-- End Settings

function Main()
	SetTimer(21600000)
	StartTimer()
	local fileUsers = io.open(fPassed)
	if fileUsers ~= nil then
		tPassed.items = dofile(fPassed)
		fileUsers:close()
	end
end

function NewUserConnected(curUser)
	if tPassed[curUser.sName] == nil then
		ShowTerms(curUser.sName)
	end
end


function ToArrival(User, Data)
	if tPassed[User.sName] == nil then
		if bCanPM == 0 then
			User:SendPM(frmHub:GetHubBotName(), "Private Message"..sAcceptDecline)
			return 1
		else
			return 0
		end
	else
		return 0
	end
end


function ConnectToMeArrival(User, Data)
	if tPassed[User.sName] == nil then
		if bCanDownload == 0 then
			User:SendPM(frmHub:GetHubBotName(), "Downloading"..sAcceptDecline)
			return 1
		else
			return 0
		end
	else
		return 0
	end
end

MultiConnectToMeArrival = ConnectToMeArrival
RevConnectToMeArrival = ConnectToMeArrival


function SearchArrival(User, Data)
if tPassed[User.sName] == nil then
		if bCanSearch == 0 then
			User:SendPM(frmHub:GetHubBotName(), "Searching"..sAcceptDecline)
			return 1
		else
			return 0
		end
	else
		return 0
	end
end


function ChatArrival(User, Data)
	if tPassed[User.sName] == nil then
		Data = string.sub(Data, 1, string.len(Data)-1)
		local _,_,cmd = string.find(Data, "%b<>%s+(%S+)")
		if cmd == "!accept" then
			User:SendData(frmHub:GetHubBotName(), "Thank you for agreeing to the hub's Terms & Conditions. Enjoy your stay")
			tPassed[User.sName] = 1
			return 1
		elseif cmd == "!decline" then
			User:SendData(frmHub:GetHubBotName(), "We are sorry to hear that you have decided to decline this hub's Terms & Conditions. You will now be disconnected")
			User:Disconnect()
			return 1
		elseif cmd == "!terms" then
			ShowTerms(User.sName)
			return 1
		else
			if bCanMainChat == 0 then
				User:SendData(frmHub:GetHubBotName(), "Participation in mainchat"..sAcceptDecline)
				return 1
			else
				return 0
			end
		end
	else
		return 0
	end
end

function ShowTerms(sNick)
	local fileTerms = io.open(fTerms)
	if fileTerms ~= nil then
		local sTerms = fileTerms:read("*a")
		fileTerms:close()
		SendToNick(sNick, sTerms)
		SendToNick(sNick, "Type !accept to Accept , !decline to Decline or !terms to read them again")
	else
		SendToAll(frmHub:GetHubBotName(), "An error occurred opening the Terms & Conditions. For safety purposes, all options will be unblocked")
		bCanSearch = 1
		bCanPM = 1
		bCanMainChat = 1
		bCanDownload = 1
	end
end

function OnExit()
	local fTCUserDB = io.open(fPassed, "w+")
	Save_Serialize(tPassed, "tPassed", fTCUserDB)
	fTCUserDB:close()
end

OnTimer = OnExit

Save_Serialize = function(tTable, sTableName, hFile, sTab)
	sTab = sTab or "";
	hFile:write(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
			Save_Serialize(value, sKey, hFile, sTab.."\t")
		else
			local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value)
			hFile:write( sTab.."\t"..sKey.." = "..sValue)
		end
		hFile:write( ",\n")
	end
	hFile:write( sTab.."}")
end


Make a file in Notepad first that holds you hub's Terms & Conditions. The default filename is terms.txt but you can change this by changing fTerms

Nor-Hand

ii got this message in main    An error occurred opening the Terms & Conditions. For safety purposes, all options will be unblocked

CrazyGuy

Quote
ii got this message in main? ? An error occurred opening the Terms & Conditions. For safety purposes, all options will be unblocked

Have you created a seperate text file that contains the Terms & Conditions ??

Quote
Make a file in Notepad first that holds you hub's Terms & Conditions. The default filename is terms.txt but you can change this by changing fTerms

Nor-Hand


CrazyGuy

ur welcome  :)  is it working now ?  ???

Nor-Hand


Herodes

[...]
function ToArrival(User, Data)
	if tPassed[User.sName] == nil and bCanPM == 0 then
		User:SendPM(frmHub:GetHubBotName(), "Private Message"..sAcceptDecline)
		return 1
	end
	return 0
end


function ConnectToMeArrival(User, Data)
	if tPassed[User.sName] == nil and bCanDownload == 0 then
		User:SendPM(frmHub:GetHubBotName(), "Downloading"..sAcceptDecline)
		return 1
	end
	return 0
end

MultiConnectToMeArrival = ConnectToMeArrival
RevConnectToMeArrival = ConnectToMeArrival


function SearchArrival(User, Data)
	if tPassed[User.sName] == nil and bCanSearch == 0 then
		User:SendPM(frmHub:GetHubBotName(), "Searching"..sAcceptDecline)
		return 1
	end
	return 0
end
[...]
Look those kind of having your script operate in a short-way logic...

CrazyGuy

true, I added the boolean's later but thinking it over, you're right.  ;D

Here's new complete code:

--- This script forces connected people to agree with Terms & Conditions before they can do certain actions
--- Written by CrazyGuy
--- version 1.1
--- LUA 5.1
--- July 31st 2006
--- Please only edit lines in Settings part
--- Thnx to plop, Mutor for Serialize function
--- Thnx to Herodes for pointing out a simplification

fPassed = "TCUserDB.tbl"
tPassed = {}
sAcceptDecline = " is disabled until you agree to the hub's Terms & Conditions\n\n\t\tType !accept to Accept , !decline to Decline or !terms to read them again"

-- Settings

fTerms = "terms.txt"		-- name of file holding the Terms & Conditions
bCanSearch = 1			-- 0 for disable, any other value for enable Search
bCanPM = 0			-- 0 for disable, any other value for enable PM
bCanMainChat = 0		-- 0 for disable, any other value for enable MainChat
bCanDownload = 0		-- 0 for disable, any other value for enable Download
OpConnected = NewUserConnected  -- remove this to exclude OPs from Terms & Conditions

-- End Settings

function Main()
	SetTimer(21600000)
	StartTimer()
	local fileUsers = io.open(fPassed)
	if fileUsers ~= nil then
		tPassed.items = dofile(fPassed)
		fileUsers:close()
	end
end

function NewUserConnected(curUser)
	if tPassed[curUser.sName] == nil then
		ShowTerms(curUser.sName)
	end
end


function ToArrival(User, Data)
	if tPassed[User.sName] == nil and bCanPM == 0 then
		User:SendPM(frmHub:GetHubBotName(), "Private Message"..sAcceptDecline)
		return 1
	else
		return 0
	end
end


function ConnectToMeArrival(User, Data)
	if tPassed[User.sName] == nil and bCanDownload == 0 then
		User:SendPM(frmHub:GetHubBotName(), "Downloading"..sAcceptDecline)
		return 1
	else
		return 0
	end
end

MultiConnectToMeArrival = ConnectToMeArrival
RevConnectToMeArrival = ConnectToMeArrival


function SearchArrival(User, Data)
	if tPassed[User.sName] == nil and bCanSearch == 0 then
		User:SendPM(frmHub:GetHubBotName(), "Searching"..sAcceptDecline)
		return 1
	else
		return 0
	end
end


function ChatArrival(User, Data)
	if tPassed[User.sName] == nil then
		Data = string.sub(Data, 1, string.len(Data)-1)
		local _,_,cmd = string.find(Data, "%b<>%s+(%S+)")
		if cmd == "!accept" then
			User:SendData(frmHub:GetHubBotName(), "Thank you for agreeing to the hub's Terms & Conditions. Enjoy your stay")
			tPassed[User.sName] = 1
			return 1
		elseif cmd == "!decline" then
			User:SendData(frmHub:GetHubBotName(), "We are sorry to hear that you have decided to decline this hub's Terms & Conditions. You will now be disconnected")
			User:Disconnect()
			return 1
		elseif cmd == "!terms" then
			ShowTerms(User.sName)
			return 1
		else
			if bCanMainChat == 0 then
				User:SendData(frmHub:GetHubBotName(), "Participation in mainchat"..sAcceptDecline)
				return 1
			else
				return 0
			end
		end
	else
		return 0
	end
end

function ShowTerms(sNick)
	local fileTerms = io.open(fTerms)
	if fileTerms ~= nil then
		local sTerms = fileTerms:read("*a")
		fileTerms:close()
		SendToNick(sNick, sTerms)
		SendToNick(sNick, "Type !accept to Accept , !decline to Decline or !terms to read them again")
	else
		SendToAll(frmHub:GetHubBotName(), "An error occurred opening the Terms & Conditions. For safety purposes, all options will be unblocked")
		bCanSearch = 1
		bCanPM = 1
		bCanMainChat = 1
		bCanDownload = 1
	end
end

function OnExit()
	local fTCUserDB = io.open(fPassed, "w+")
	Save_Serialize(tPassed, "tPassed", fTCUserDB)
	fTCUserDB:close()
end

OnTimer = OnExit

Save_Serialize = function(tTable, sTableName, hFile, sTab)
	sTab = sTab or "";
	hFile:write(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
			Save_Serialize(value, sKey, hFile, sTab.."\t")
		else
			local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value)
			hFile:write( sTab.."\t"..sKey.." = "..sValue)
		end
		hFile:write( ",\n")
	end
	hFile:write( sTab.."}")
end

Herodes

--- This script forces connected people to agree with Terms & Conditions before they can do certain actions
--- Written by CrazyGuy
--- version 1.2
--- LUA 5.1
--- July 31st 2006
--- Please only edit lines in Settings part
--- Thnx to plop, Mutor for Serialize function
--- Thnx to Herodes for pointing out a simplification
--- touched by Herodes himself...

fPassed = "TCUserDB.tbl"
tBlocked = {}
sAcceptDecline = " is disabled until you agree to the hub's Terms & Conditions\n\n\t\tType !accept to Accept , !decline to Decline or !terms to read them again"

-- Settings

fTerms = "terms.txt"   -- name of file holding the Terms & Conditions
bCanSearch = 0   -- 0 for disable, any other value for enable Search
bCanPM = 0   -- 0 for disable, any other value for enable PM
bCanMainChat = 0   -- 0 for disable, any other value for enable MainChat
bCanDownload = 0   -- 0 for disable, any other value for enable Download
OpConnected = NewUserConnected    -- remove this to exclude OPs from Terms & Conditions

-- End Settings

function Main()
	SetTimer(21600000)
	StartTimer()
	local fileUsers = io.open(fPassed)
	if fileUsers then
		tPassed.items = dofile(fPassed)
		fileUsers:close()
	end
end

function NewUserConnected( user )
	if not tPassed[user.sName] then ShowTerms(user.sName) end
end


function ToArrival(user, data)
	return BlockUser( user, bCanPM, "Private Message"..sAcceptDecline )
end


function ConnectToMeArrival(user, data)
	return BlockUser( user, bCanDownload, "Downloading"..sAcceptDecline )
end

MultiConnectToMeArrival = ConnectToMeArrival
RevConnectToMeArrival = ConnectToMeArrival


function SearchArrival(user, data)
	return BlockUser( user, bCanSearch, "Searching"..sAcceptDecline )
end

function BlockUser( user, block_what, msg )
	if ( (not tPassed[user.sName]) and (block_what == 0) ) then
		user:SendPM( frmHub:GetHubBotName(), msg);
		return 1;
	end
	return 0;
end

function ChatArrival(user, data)
	if not tPassed[user.sName] then
		data = string.sub( data, 1, -1)
		local _,_,cmd = string.find(data, "%b<>%s+%!(%S+)")
		local tCmds = {
			"accept" = function( user )
					user:SendData( fmrHub:GetHubBotName(), "Thank you for agreeing to the hub's Terms & Conditions. Enjoy your stay")
					tPassed[user.sName] = nil;return 1
				end,
			"decline" = function( user ) 	
					user:SendData(frmHub:GetHubBotName(), "We are sorry to hear that you have decided to decline this hub's Terms & Conditions. You will now be disconnected")
					user:Disconnect();return 1;
				end,
			"terms" = function(user) 
					ShowTerms(user.sName);return 1;
				end
			}
		if tCmds[cmd] then
			return tCmds[cmd](user);
		end
		if not bCanMainChat then
			user:SendData( frmHub:GetHubBotName(), "Participation in mainchat"..sAcceptDecline);return 1;
		end
	end
end


function ShowTerms(sNick)
	local fileTerms = io.open(fTerms)
	if fileTerms ~= nil then
		local sTerms = fileTerms:read("*a")
		fileTerms:close()
		SendToNick(sNick, sTerms)
		SendToNick(sNick, "Type !accept to Accept , !decline to Decline or !terms to read them again")
	else
		SendToAll(frmHub:GetHubBotName(), "An error occurred opening the Terms & Conditions. For safety purposes, all options will be unblocked")
		bCanSearch = 1
		bCanPM = 1
		bCanMainChat = 1
		bCanDownload = 1
	end
end

function OnExit()
	local f = io.open(fPassed, "w+")
	Save_Serialize(tPassed, "tPassed", f)
	f:close()
end

OnTimer = OnExit

Save_Serialize = function(tTable, sTableName, hFile, sTab)
	sTab = sTab or "";
	hFile:write(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
			Save_Serialize(value, sKey, hFile, sTab.."\t")
		else
			local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value)
			hFile:write( sTab.."\t"..sKey.." = "..sValue)
		end
		hFile:write( ",\n")
	end
	hFile:write( sTab.."}")
end

CrazyGuy

hmm,

I tried myself making something like that BlockUser function but i didn't get that to work properly on all functions.
But, if you did, then good  ;D

Herodes

I want to point out that it is way of separating normal users from whatever crawls DC takes some more effort than simply having them respond with "!accept" ...

...try searching in Lawmaker by bastya_elvtars and find the way for registering users with an account.
I have a snippet of code that creates passwords whenever a user doesn't enter one for his account.

Use that for making up the word that the users must type in.

Be sure to give them 3 or 5 tries to get it right...

This way is similar to the way some websites are validating the users from webspiders - bots.... and imho it is quite succesful...

Herodes

I don't think that you need all that to distinuish human from bots,...

the following should do the job cleanly enough:
function GenSmallPass()
	local s = ''
	for i = 1, 4 do
		str = str..math.random(1, 8)
	end
	return s;
end

SMF spam blocked by CleanTalk