+eban (Stand-alone)
 

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

+eban (Stand-alone)

Started by D-J Valhala, 14 May, 2004, 08:37:32

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

D-J Valhala

hi all :)
need one more script :)
+eban = E-Mail Ban
it will kick him from the hub but the user will never know the his e-mail is banned he will think the IP or Nick he can change the nick + ip but will not can connect coz the e-mail is banned :P
10x :D
My PsyIsrael Network
==================
--=[PsyIsrael DC Hub]=--
--=[PsyIsrael Website]=--
==================

nErBoS

#1
Hi,

Added also a cmd to unban the email, hope it helps..

--Requested by D-J Valhala
--Made by nErBoS

sBot = "eBanner"
eban = {}
ebansv = "eban.dat"

function Main()
	frmHub:RegBot(sBot)
	LoadFromFile(ebansv)
end

function OnExit()
	SaveToFile(ebansv , eban , "eban")
end

function NewUserConnected(user)
	if (CheckForMailBan(user) == 1) then
		user:SendPM(sBot, "You are banned from this HUB.")
		user:Ban()
	end
end

function DataArrival(user, data)
	if (strsub(data,1,1) == "<" or strsub(data,1,5+strlen(sBot)) == "$To: "..sBot) then
		data = strsub(data,1,strlen(data)-1)
		s,e,cmd = strfind(data, "%b<>%s+(%S+)")
		if (cmd == "!eban" and user.bOperator) then
			local s,e,email = strfind(data, "%b<>%s+%S+%s+(%S+)")
			if (email == nil) then
				user:SendPM(sBot, "Syntax Error, !eban , you must write a email.")
			else
				if (eban[strlower(email)] ~= nil) then
					user:SendPM(sBot, "This email is already banned.")
				else
					eban[strlower(email)] = 1
					user:SendPM(sBot, "The email "..email.." has been banned.")
				end
			end
			return 1
		elseif (cmd == "!deleban" and user.bOperator) then
			local s,e,email = strfind(data, "%b<>%s+%S+%s+(%S+)")
			if (email == nil) then
				user:SendPM(sBot, "Syntax Error, !deleban , you must write a email.")
			else
				if (eban[strlower(email)] == nil) then
					user:SendPM(sBot, "This email is not banned.")
				else
					eban[strlower(email)] = nil
					user:SendPM(sBot, "The email "..email.." has been unbanned.")
				end
			end
			return 1
		end
	end
end

function CheckForMailBan(user)
	local found = 0
	local s,e,usrMail = strfind(user.sMyInfoString, "$MyINFO $ALL [^$]+$ $[^$]*$([^$]*)$[^$]+")
	if (usrMail ~= nil and usrMail ~= "") then
		for mail, aux in eban do
			if (strlower(mail) == strlower(usrMail)) then
				found = 1
				break
			end
		end
	end
	return found
end

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 format("[%q]",key) or format("[%d]",key);

		if(type(value) == "table") then
			Serialize(value, sKey, sTab.."\t");
		else
			local sValue = (type(value) == "string") and 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)
	writeto(file)
	write(Serialize(table, tablename))
	writeto()
end

function LoadFromFile(file)
	if (readfrom(file) ~= nil) then
		readfrom(file)
		dostring(read("*all"))
		readfrom()
	end
end

Best regards, nErBoS
--## nErBoS Spot ##--

D-J Valhala

nope not working...
My PsyIsrael Network
==================
--=[PsyIsrael DC Hub]=--
--=[PsyIsrael Website]=--
==================

nErBoS

Hi,

Sorry i has comparing the wrong mail, the script above have been edited and fixed.

Best regards, nErBoS
--## nErBoS Spot ##--

D-J Valhala

#4
nope steel not working...
and maybe you can add on the script
!ebanlist?
and it will show it like that...
"aaa@aaa.com" (Username)
10x :D
My PsyIsrael Network
==================
--=[PsyIsrael DC Hub]=--
--=[PsyIsrael Website]=--
==================

nErBoS

Hi,

I have tested the script and its working, are you trying with to enter the Hub as a OP or User ?? If you are entering as a OP will not check if the mail is ban.

Here is the script with your request...

--Requested by D-J Valhala
--Made by nErBoS

sBot = "eBanner"
eban = {}
ebansv = "eban.dat"

function Main()
	frmHub:RegBot(sBot)
	LoadFromFile(ebansv)
end

function OnExit()
	SaveToFile(ebansv , eban , "eban")
end

function NewUserConnected(user)
	if (CheckForMailBan(user) == 1) then
		user:SendPM(sBot, "You are banned from this HUB.")
		user:Ban()
	end
end

function DataArrival(user, data)
	if (strsub(data,1,1) == "<" or strsub(data,1,5+strlen(sBot)) == "$To: "..sBot) then
		data = strsub(data,1,strlen(data)-1)
		s,e,cmd = strfind(data, "%b<>%s+(%S+)")
		if (cmd == "!eban" and user.bOperator) then
			local s,e,email = strfind(data, "%b<>%s+%S+%s+(%S+)")
			if (email == nil) then
				user:SendPM(sBot, "Syntax Error, !eban , you must write a email.")
			else
				if (eban[strlower(email)] ~= nil) then
					user:SendPM(sBot, "This email is already banned.")
				else
					eban[strlower(email)] = 1
					user:SendPM(sBot, "The email "..email.." has been banned.")
				end
			end
			return 1
		elseif (cmd == "!deleban" and user.bOperator) then
			local s,e,email = strfind(data, "%b<>%s+%S+%s+(%S+)")
			if (email == nil) then
				user:SendPM(sBot, "Syntax Error, !deleban , you must write a email.")
			else
				if (eban[strlower(email)] == nil) then
					user:SendPM(sBot, "This email is not banned.")
				else
					eban[strlower(email)] = nil
					user:SendPM(sBot, "The email "..email.." has been unbanned.")
				end
			end
			return 1
		elseif (cmd == "!ebanlist" and user.bOperator) then
			MailBanList(user)
			return 1
		end
	end
end

function CheckForMailBan(user)
	local found = 0
	local s,e,usrMail = strfind(user.sMyInfoString, "$MyINFO $ALL [^$]+$ $[^$]*$([^$]*)$[^$]+")
	if (usrMail ~= nil and usrMail ~= "") then
		for mail, aux in eban do
			if (strlower(mail) == strlower(usrMail)) then
				found = 1
				break
			end
		end
	end
	return found
end

function MailBanList(user)
	local sTmp = "The Mails that are ban in this Hub:\r\n\r\n"
	for mail, aux in eban do
		sTmp = sTmp..mail.."\r\n"
	end
	user:SendPM(sBot, sTmp)
end

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 format("[%q]",key) or format("[%d]",key);

		if(type(value) == "table") then
			Serialize(value, sKey, sTab.."\t");
		else
			local sValue = (type(value) == "string") and 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)
	writeto(file)
	write(Serialize(table, tablename))
	writeto()
end

function LoadFromFile(file)
	if (readfrom(file) ~= nil) then
		readfrom(file)
		dostring(read("*all"))
		readfrom()
	end
end

Best regards, nErBoS
--## nErBoS Spot ##--

D-J Valhala

damm you are good man! :D
the script work PERFECT!!! like all your scripts :)
thank you mate keep up the GooD work !:)
My PsyIsrael Network
==================
--=[PsyIsrael DC Hub]=--
--=[PsyIsrael Website]=--
==================

D-J Valhala

#7
lil bug...
if the hub soft stop runing the hub or whan i restarted the scripts it dont saves the e-mail banneds
My PsyIsrael Network
==================
--=[PsyIsrael DC Hub]=--
--=[PsyIsrael Website]=--
==================

nErBoS

Hi,

I have tested and is saving if you restart the Hub or scripts, or shuting down the Hub.

Best regards, nErBoS
--## nErBoS Spot ##--

D-J Valhala

it wont save the banned Emails man look i ban a@a.com
1 restart the scripts and the hub and...

<-=<[LsD_-_BoT]>=-> The email a@a.com has been banned.
<-=<[LsD_-_BoT]>=-> The Mails that are ban in this Hub:


^^^^ you see it wont save it...
My PsyIsrael Network
==================
--=[PsyIsrael DC Hub]=--
--=[PsyIsrael Website]=--
==================

nErBoS

Hi,

I have tested this script by restarting the Hub , the script and is saving the mails. Did you modified anything on the script ???

Best regards, nErBoS
--## nErBoS Spot ##--

D-J Valhala

My PsyIsrael Network
==================
--=[PsyIsrael DC Hub]=--
--=[PsyIsrael Website]=--
==================

nErBoS

Hi,

Ban some mails and then shut down the HUB them go to the folder script and open the eban.dat and see if the mails that you banned is there. If yes the BOT is working OK.

Best regards, nErBoS
--## nErBoS Spot ##--

D-J Valhala

i dont have eban.dat...
My PsyIsrael Network
==================
--=[PsyIsrael DC Hub]=--
--=[PsyIsrael Website]=--
==================

nErBoS

Hi,

So that is what is bugging your script, what version of ptokax are you using ??? The eban.dat should appear in "...ptokax\scripts\eban.dat".

Best regards, nErBoS
--## nErBoS Spot ##--

D-J Valhala

i use PtokaX-0.326.TestDrive4
and i know it should appear but i dont know why he not appear...
My PsyIsrael Network
==================
--=[PsyIsrael DC Hub]=--
--=[PsyIsrael Website]=--
==================

nErBoS

Hi,

OK, its explain you are using TD4, doesn't have the function OnExit that saves the ebans when restarting or closing the Hub.

Try out this on...

--Requested by D-J Valhala
--Made by nErBoS
--For TD4

sBot = "eBanner"
eban = {}
ebansv = "eban.dat"

function Main()
	frmHub:RegBot(sBot)
	LoadFromFile(ebansv)
end

function NewUserConnected(user)
	if (CheckForMailBan(user) == 1) then
		user:SendPM(sBot, "You are banned from this HUB.")
		user:Ban()
	end
end

function DataArrival(user, data)
	if (strsub(data,1,1) == "<" or strsub(data,1,5+strlen(sBot)) == "$To: "..sBot) then
		data = strsub(data,1,strlen(data)-1)
		s,e,cmd = strfind(data, "%b<>%s+(%S+)")
		if (cmd == "!eban" and user.bOperator) then
			local s,e,email = strfind(data, "%b<>%s+%S+%s+(%S+)")
			if (email == nil) then
				user:SendPM(sBot, "Syntax Error, !eban , you must write a email.")
			else
				if (eban[strlower(email)] ~= nil) then
					user:SendPM(sBot, "This email is already banned.")
				else
					SaveToFile(ebansv , eban , "eban")
					eban[strlower(email)] = 1
					user:SendPM(sBot, "The email "..email.." has been banned.")
				end
			end
			return 1
		elseif (cmd == "!deleban" and user.bOperator) then
			local s,e,email = strfind(data, "%b<>%s+%S+%s+(%S+)")
			if (email == nil) then
				user:SendPM(sBot, "Syntax Error, !deleban , you must write a email.")
			else
				if (eban[strlower(email)] == nil) then
					user:SendPM(sBot, "This email is not banned.")
				else
					SaveToFile(ebansv , eban , "eban")
					eban[strlower(email)] = nil
					user:SendPM(sBot, "The email "..email.." has been unbanned.")
				end
			end
			return 1
		elseif (cmd == "!ebanlist" and user.bOperator) then
			MailBanList(user)
			return 1
		end
	end
end

function CheckForMailBan(user)
	local found = 0
	local s,e,usrMail = strfind(user.sMyInfoString, "$MyINFO $ALL [^$]+$ $[^$]*$([^$]*)$[^$]+")
	if (usrMail ~= nil and usrMail ~= "") then
		for mail, aux in eban do
			if (strlower(mail) == strlower(usrMail)) then
				found = 1
				break
			end
		end
	end
	return found
end

function MailBanList(user)
	local sTmp = "The Mails that are ban in this Hub:\r\n\r\n"
	for mail, aux in eban do
		sTmp = sTmp..mail.."\r\n"
	end
	user:SendPM(sBot, sTmp)
end

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 format("[%q]",key) or format("[%d]",key);

		if(type(value) == "table") then
			Serialize(value, sKey, sTab.."\t");
		else
			local sValue = (type(value) == "string") and 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)
	writeto(file)
	write(Serialize(table, tablename))
	writeto()
end

function LoadFromFile(file)
	if (readfrom(file) ~= nil) then
		readfrom(file)
		dostring(read("*all"))
		readfrom()
	end
end

Best regards, nErBoS
--## nErBoS Spot ##--

D-J Valhala

there is now eban.dat but whan i stop the hub it wont save the email...
My PsyIsrael Network
==================
--=[PsyIsrael DC Hub]=--
--=[PsyIsrael Website]=--
==================

nErBoS

#18
Hi,

The script will save the mails when added and removed. Try to add some mails then close the software hub and then check out eban.dat.

Best regards, nErBoS
--## nErBoS Spot ##--

D-J Valhala

<-=<[LsD_-_BoT]>=-> The email a@a.com has been banned.


FROM eban.dat

eban = {
}
it wont save
My PsyIsrael Network
==================
--=[PsyIsrael DC Hub]=--
--=[PsyIsrael Website]=--
==================

nErBoS

Hi,

Sorry my bad, fixed...

--Requested by D-J Valhala
--Made by nErBoS
--For TD4

sBot = "eBanner"
eban = {}
ebansv = "eban.dat"

function Main()
	frmHub:RegBot(sBot)
	LoadFromFile(ebansv)
end

function NewUserConnected(user)
	if (CheckForMailBan(user) == 1) then
		user:SendPM(sBot, "You are banned from this HUB.")
		user:Ban()
	end
end

function DataArrival(user, data)
	if (strsub(data,1,1) == "<" or strsub(data,1,5+strlen(sBot)) == "$To: "..sBot) then
		data = strsub(data,1,strlen(data)-1)
		s,e,cmd = strfind(data, "%b<>%s+(%S+)")
		if (cmd == "!eban" and user.bOperator) then
			local s,e,email = strfind(data, "%b<>%s+%S+%s+(%S+)")
			if (email == nil) then
				user:SendPM(sBot, "Syntax Error, !eban , you must write a email.")
			else
				if (eban[strlower(email)] ~= nil) then
					user:SendPM(sBot, "This email is already banned.")
				else
					eban[strlower(email)] = 1
					user:SendPM(sBot, "The email "..email.." has been banned.")
					SaveToFile(ebansv , eban , "eban")
				end
			end
			return 1
		elseif (cmd == "!deleban" and user.bOperator) then
			local s,e,email = strfind(data, "%b<>%s+%S+%s+(%S+)")
			if (email == nil) then
				user:SendPM(sBot, "Syntax Error, !deleban , you must write a email.")
			else
				if (eban[strlower(email)] == nil) then
					user:SendPM(sBot, "This email is not banned.")
				else
					eban[strlower(email)] = nil
					user:SendPM(sBot, "The email "..email.." has been unbanned.")
					SaveToFile(ebansv , eban , "eban")
				end
			end
			return 1
		elseif (cmd == "!ebanlist" and user.bOperator) then
			MailBanList(user)
			return 1
		end
	end
end

function CheckForMailBan(user)
	local found = 0
	local s,e,usrMail = strfind(user.sMyInfoString, "$MyINFO $ALL [^$]+$ $[^$]*$([^$]*)$[^$]+")
	if (usrMail ~= nil and usrMail ~= "") then
		for mail, aux in eban do
			if (strlower(mail) == strlower(usrMail)) then
				found = 1
				break
			end
		end
	end
	return found
end

function MailBanList(user)
	local sTmp = "The Mails that are ban in this Hub:\r\n\r\n"
	for mail, aux in eban do
		sTmp = sTmp..mail.."\r\n"
	end
	user:SendPM(sBot, sTmp)
end

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 format("[%q]",key) or format("[%d]",key);

		if(type(value) == "table") then
			Serialize(value, sKey, sTab.."\t");
		else
			local sValue = (type(value) == "string") and 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)
	writeto(file)
	write(Serialize(table, tablename))
	writeto()
end

function LoadFromFile(file)
	if (readfrom(file) ~= nil) then
		readfrom(file)
		dostring(read("*all"))
		readfrom()
	end
end

Best regards, nErBoS
--## nErBoS Spot ##--

SMF spam blocked by CleanTalk