how to ban an IP range whit a command like this:
!baniprange 39.7.192.xxx
?
Here Is one from my Backup.. Try it out and see..
-- Start Copying from this line
--====================--
--= Ip-Boter Light Version =--
--====================--
-- By NightLitch 2003.09.02
--------------------------------------------
-- INFO:
-- Commands are sent to Bot
-- !banrange *.*.* / name
-- !delbanrange *.*.*
-- !showbans
----------------------------------------------------------------------------
--// BotName
Bot = "[Ip-Boter]"
--// Admins that should operate the commands
Admin = {
["[SU]NightLitch"] = "1",
}
----------------------------------------------------------------------------
-- DON'T EDIT BELOW THIS POINT.....
cmd1="banrange"
cmd3="delbanrange"
cmd5="showbans"
File1 = "files/IP-DenyRanges.txt"
BIPRange={}
function Main()
frmHub:RegBot(Bot)
LoadTable(BIPRange,File1)
end
function OpConnected(curUser)
curUser:SendData(Bot, " *** Running IP-Boter Version Light Version By: NightLitch")
end
function NewUserConnected(curUser)
curUser:SendData(Bot, " *** Running IP-Boter Version Light Version By: NightLitch")
v = curUser.sIP
_,_,a,b,c,d = strfind(v, "(%d*).(%d*).(%d*).(%d*)")
if (a ~= nil) then
v1 = a
v2 = a.."."..b
v3 = a.."."..b.."."..c
if BIPRange[v1] or BIPRange[v2] or BIPRange[v3] or BIPRange[v] then
curUser:SendData(Bot, " You're IP Range is Banned on this Hub !!")
curUser:Disconnect()
else
curUser:SendData(Bot, " You're IP Range is Allowed on this Hub !!")
end
end
end
function DataArrival(curUser,data)
if strsub(data, 1, 5) == "$To: " then
local s, e, to = strfind(data, "$To: (%S+%s?%S*)%sFrom:")
if to ~= Bot then
return 0
else
if to == Bot then
return BOTCOMMAND(curUser, data)
end
end
end
end
-------------------------------------------------------------------------------------------------------------------------------------------
function DelRange(curUser,data,table,file,dora)
s,e,cmd,delrange = strfind( data, "%b<>%s+(%S+)%s+(.*)" )
if delrange == nil or deldenyrange == "" then
curUser:SendData("$To: "..curUser.sName.." From: "..Bot.." $No IP-Range given.");
else
if table[delrange] then
table[delrange]=nil
local handle = openfile(file, "w")
for i,v in table do
write(handle,i.." $ "..v.."\r\n")
end
closefile(handle)
curUser:SendData("$To: "..curUser.sName.." From: "..Bot.." $IP-Range "..delrange.." has been removed from "..dora.."list");
else
curUser:SendData("$To: "..curUser.sName.." From: "..Bot.." $IP-Range "..delrange.." is not in "..dora.."list");
end
end
end
-------------------------------------------------------------------------------------------------------------------------------------------
function ShowRange(table,dora)
local TCopy={}
var1 = 0
for i,v in table do
var1 = var1+1
TCopy=v
end
local msgfromtxt ="\r\n"
for i = 1,var1 do
var2 = 0
for i2,v2 in TCopy do
num = gsub(i2,"%p", "")
num = tonumber(num)
if num > var2 then
var2 = num
var3 = i2
name = v2
end
end
rawset (TCopy, var3, nil)
msgfromtxt = msgfromtxt.." # "..i.." - "..dora.." IP-Range: "..var3.." Name: "..name.."\r\n"
end
return msgfromtxt
end
-------------------------------------------------------------------------------------------------------------------------------------------
function LoadTable(table,file)
local handle = openfile(file, "r")
if (handle) then
local line = read(handle)
while line do
s,e,ind,val = strfind( line, "(.*) $ (.*)")
table[ind]=val
line = read(handle)
end
closefile(handle)
end
end
-------------------------------------------------------------------------------------------------------------------------------------------
function BOTCOMMAND(curUser, data)
data=strsub(data,1,strlen(data)-1)
_,_,cmd = strfind(data,"$%b<>%s+(%S+)")
if not cmd then cmd = "0" end
if curUser.bOperator then
if (strsub(cmd, 1, 1) ~= "!" and strsub(cmd, 1, 1) ~= "+") then
return 0
else
cmd = strlower(cmd)
cmd=strsub(cmd,2,strlen(cmd))
local COMMAND = (botcommands(curUser, data, cmd))
if not COMMAND then
return 0
else
return COMMAND
end
end
end
end
function botcommands(curUser, data, cmd)
if (cmd == cmd1 ) then
if (Admin[curUser.sName]) then
s,e,cmd,denyrange,denyname = strfind( data, "%b<>%s+(%S+)%s+(%S+)%s+(.*)" )
if denyrange == nil or denyrange == "" then
curUser:SendData("$To: "..curUser.sName.." From: "..Bot.." $No Deny-IP-Range and Deny-IP-Rangename given.Type: "..cmd1.." [IP-Range] [RangeName]");
elseif BIPRange[denyrange] then
curUser:SendData("$To: "..curUser.sName.." From: "..Bot.." $Deny-IP-Range "..denyrange.." is already in denylist");
else
BIPRange[denyrange]=denyname
local handle = openfile(File1, "a")
write(handle,denyrange.." $ "..denyname.."\r\n")
closefile(handle)
curUser:SendData("$To: "..curUser.sName.." From: "..Bot.." $Deny-IP-Range : "..denyrange.." Name : "..denyname.." , has been added to denylist");
end
end
return 1
elseif (cmd == cmd3 ) then
if(Admin[curUser.sName]) then
DelRange(curUser,data,BIPRange,File1,"Deny")
return 1
end
elseif (cmd == cmd5 ) then
if (Admin[curUser.sName]) then
curUser:SendData("$To: "..curUser.sName.." From: "..Bot.." $ \t\t--------------- Banned IP Range's ---------------");
curUser:SendData("$To: "..curUser.sName.." From: "..Bot.." $ ");
curUser:SendData("$To: "..curUser.sName.." From: "..Bot.." $"..ShowRange(BIPRange, "Deny"))
curUser:SendData("$To: "..curUser.sName.." From: "..Bot.." $ ");
curUser:SendData("$To: "..curUser.sName.." From: "..Bot.." $ \t\t----------------------- End of File ---------------------");
return 1
end
end
end
-- Finish Copying