--[[
IP Range Script [API 2]
Made by speedX (30/05/2009)
Version 2.0
Description:
Displays users of all ranges logged on hub.
10.6.106.xxx --> speedX xcess
10.6.134.xxx --> manu
]]--
sBot = SetMan.GetString(21)
sHub = SetMan.GetString(0)
ipcmd = "iprange"
Permission = {
[-1] = 0, -- Unreg Users
[0] = 1, -- Masters
[1] = 1, -- Operators
[2] = 1, -- VIPs
[3] = 1, -- Regs
}
OnStartup = function()
UserIPs = {}
if sBot ~= SetMan.GetString(21) then Core.RegBot(sBot,"","",true) end
end
UserConnected = function(user)
if Permission[user.iProfile] and Permission[user.iProfile] == 1 then
Core.SendToNick(user.sNick, "$UserCommand 1 3 "..sHub.."\\Show IP-Ranges$<%[mynick]> +"..ipcmd.."|")
end
end
OpConnected,RegConnected = UserConnected,UserConnected
ChatArrival = function(user,data)
local _,_,cmd = string.find(data,"%b<> %p(%S+)|")
if cmd and cmd:lower() == ipcmd:lower() then
if Permission[user.iProfile] and Permission[user.iProfile] == 1 then
UserIPs = {}
for i,v in ipairs(Core.GetOnlineUsers()) do
local _,_,ip = string.find(v.sIP,"(%d+.%d+.%d+).%d+")
if not UserIPs[ip] then
UserIPs[ip] = {}
table.insert(UserIPs[ip],v.sNick)
else
table.insert(UserIPs[ip],v.sNick)
end
end
local count,msg = 0,"\r\n\t"..string.rep("-=",25).."\r\n\tCurrent IP Ranges in the Hub are as Follows:\r\n\t"..string.rep("-=",25).."\r\n"
for i,v in pairs(UserIPs) do
local ip = "\t"..i..".xxx --> "
for _,d in ipairs(v) do
ip = ip.." "..d
end
ip = ip.." [Total: "..#v.."]"
ip = ip.."\r\n"
msg = msg..ip..""
count = count + 1
end
if count > 0 then
return Core.SendToNick(user.sNick,"<"..sBot.."> "..msg), true
end
else
return Core.SendToNick(user.sNick,"<"..sBot.."> You are not allowed to use this command."), true
end
end
end
Thanks for the script.
Good Goinf SpeedX
Can a option be added where in the ranges output i.e 10.6.106.xxx
can also be taken in form of 10.6.xxx.xxx .Using a command in a script where in it will be easy to switch to the desired output rather than changing the script.
Try this:
--[[
IP Range Script [API 2]
Made by speedX (30/05/2009)
Version 3.0
Description:
Displays users of all ranges logged on hub.
10.6.106.xxx --> speedX xcess
10.6.134.xxx --> manu
Changes from 2.0: by speedX
Added: Option to Classify users by different Range-Limit (Requested by ?StIfFLEr??)
]]--
sBot = SetMan.GetString(21)
sHub = SetMan.GetString(0)
ipcmd = "iprange"
Permission = {
[-1] = 0, -- Unreg Users
[0] = 1, -- Masters
[1] = 1, -- Operators
[2] = 1, -- VIPs
[3] = 1, -- Regs
}
-- Classify by Range-Limit: true:(10.6.106.xxx)/false:(10.6.xxx.xxx)
bRange = true
OnStartup = function()
UserIPs = {}
if sBot ~= SetMan.GetString(21) then Core.RegBot(sBot,"","",true) end
end
UserConnected = function(user)
Core.SendToNick(user.sNick,"<"..sBot.."> Welcome "..user.sNick..", speedX's IP-Range 3.0 is enabled. RightClick for menu.")
if Permission[user.iProfile] and Permission[user.iProfile] == 1 then
Core.SendToNick(user.sNick, "$UserCommand 1 3 "..sHub.."\\Show IP-Ranges$<%[mynick]> +"..ipcmd.."|")
end
end
OpConnected,RegConnected = UserConnected,UserConnected
ChatArrival = function(user,data)
local _,_,cmd = string.find(data,"%b<> %p(%S+)|")
if cmd and cmd:lower() == ipcmd:lower() then
if Permission[user.iProfile] and Permission[user.iProfile] == 1 then
UserIPs = {}
local ip
for i,v in ipairs(Core.GetOnlineUsers()) do
if bRange then
local _,_,ip2 = string.find(v.sIP,"(%d+.%d+.%d+).%d+")
ip = ip2
else
local _,_,ip2 = string.find(v.sIP,"(%d+.%d+).%d+.%d+")
ip = ip2
end
if not UserIPs[ip] then
UserIPs[ip] = {}
table.insert(UserIPs[ip],v.sNick)
else
table.insert(UserIPs[ip],v.sNick)
end
end
local count,msg = 0,"\r\n\t"..string.rep("-=",25).."\r\n\tCurrent IP Ranges in the Hub are as Follows:\r\n\t"..string.rep("-=",25).."\r\n"
for i,v in pairs(UserIPs) do
if bRange then
ip = "\t"..i..".xxx --> "
else
ip = "\t"..i..".xxx.xxx --> "
end
for _,d in ipairs(v) do
ip = ip.." "..d
end
ip = ip.." [Total: "..#v.."]"
ip = ip.."\r\n"
msg = msg..ip..""
count = count + 1
end
if count > 0 then
Core.SendToNick(user.sNick,"<"..sBot.."> "..msg)
Clear()
return true
end
else
Core.SendToNick(user.sNick,"<"..sBot.."> You are not allowed to use this command.")
return true
end
end
end
Clear = function()
collectgarbage("collect")
io.flush()
end
Quote
-- Classify by Range-Limit: true:(10.6.106.xxx)/false:(10.6.xxx.xxx)
bRange = true
Good going buddy... u saved me from editing the script again and again :P
Quote from: ?StIfFLEr?? on 16 June, 2009, 15:42:13
Good going buddy... u saved me from editing the script again and again :P
No Probs mate...
was a bit busy so couldn't reply before.
Requesting for a Lazy RC
the Function
Quote-- Classify by Range-Limit: true:(10.6.106.xxx)/false:(10.6.xxx.xxx)
bRange = true
Can it be Brought into right click.So that From the hub itself i can Update the output as needed from time to time.