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
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
nope not working...
Hi,
Sorry i has comparing the wrong mail, the script above have been edited and fixed.
Best regards, nErBoS
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
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
damm you are good man! :D
the script work PERFECT!!! like all your scripts :)
thank you mate keep up the GooD work !:)
lil bug...
if the hub soft stop runing the hub or whan i restarted the scripts it dont saves the e-mail banneds
Hi,
I have tested and is saving if you restart the Hub or scripts, or shuting down the Hub.
Best regards, nErBoS
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...
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
nope
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
i dont have eban.dat...
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
i use PtokaX-0.326.TestDrive4
and i know it should appear but i dont know why he not appear...
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
there is now eban.dat but whan i stop the hub it wont save the email...
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
<-=<[LsD_-_BoT]>=-> The email a@a.com has been banned.
FROM eban.dat
eban = {
}
it wont save
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