Hi! I'm finding the script, which showing ip-segment of user from list, such as:
255.255.255.* - "Admin's Segment"
100.100.100.* - "Simple"
213.33.*.* - "UltraNet"
etc.
When user join hub, bot, which showing onjoin info:
Bot = "::[X]::"
function NewUserConnected(user)
local myinfo = user.sMyInfoString
local _, _, desc, speed, email, share = strfind(myinfo, "$ALL %S+ (.*)%$ %$(.+)%$(.*)%$(%d+)%$")
if (share == nil) then
share = 0
end
share = share/1024/1024/1024
share = format("%0.2f", share)
ip = tohostname(user.sIP)
if not (ip) then
ip = user.sIP
end
login = "::["..user.sName.."]::["..ip.."]::["..share.." Gb]::"
SendToAll(login)
end
OpConnected = NewUserConnected
function Round(iNumber)
assert(type(iNumber) == "number");
return floor(iNumber + 0.5);
end
This script must also showing info about ip-segment:
"::["..user.sName.."]::["..ip.."]::["..segment.."]::["..share.." Gb]::"
And in user-description this script must showing, such as:
"::["..segment.."]::["..user_description
Example:
::[TyShkan]::[255.255.255.3]::[Admin's Segment]::[100Gb]::
or:
::[TyShkan]::[213.33.33.33]::[UltraNet]::[0Gb]::
Who can make this script?
Hi,
It's possible to add the description but the IP-Segment has some disadvantages, because we need to access a page to know his Host-Rank (would take much bandwith), what can be done to turn up the subject his to add a table with all Ip-Ranges and their Host-Rank.
Best regards, nErBoS
You don't misunderstood me. The name of a segment's is seted by me...
For example: my ip is 10.5.2.16, it's in 10.5.2.* segment.
Name of 10.5.2.* segment is "Segment #1"
On join users would see:
::[TyShkan]::[10.5.2.16]::[Segment #1]::[100Gb]::
Do you understand me? :))
Hi,
I beleive is this then...
--## Made by nErBoS
--## Based in a script given by TyShkan
--## Requested by TyShkan
sBot = "Login"
--## Configuration ##--
arrIP = {
["255.255.255."] = "Admin's Segment",
["100.100.100."] = "Simple",
["213.33."] = "UltraNet",
}
uLaterPtokax = 0 -- Choose 0 if you are using a Ptokax version 0.3.3.0 or higher
-- Choose 1 if you are using a Ptokax version lower then 0.3.3.0
--## END ##--
arrExtraInfo = {}
fExtraInfo = "info.dat"
function Main()
frmHub:RegBot(sBot)
frmHub:EnableFullData(1)
LoadFromFile(fExtraInfo)
Refresh()
end
function OnExit()
SaveToFile(fExtraInfo , arrExtraInfo , "arrExtraInfo")
end
function NewUserConnected(user)
local s,e,desc,share,segment = strfind(user.sMyInfoString, "$MyINFO%s+$ALL%s+%S+%s+(.+)%$.+%$(%d+)%$")
if (share == nil or tonumber(share) == nil) then
share = 0
else
share = tonumber(share)
share = format("%0.0f", share/(1024*1024*1024))
end
segment = CheckIP(user.sIP)
arrExtraInfo[user.sName] = "::["..segment.."]::["
SendToAll(sBot, "::["..user.sName.."]::["..user.sIP.."]::["..segment.."]::["..share.."Gb]::")
end
function UserDisconnected(user)
arrExtraInfo[user.sName] = nil
end
OpConnected = NewUserConnected
OpDisconnected = UserDisconnected
function DataArrival(user, data)
if (strsub(data,1,7) == "$MyINFO") then
local s,e,info = strfind(data, "$MyINFO%s+$ALL%s+%S+%s+(.+)")
if (arrExtraInfo[user.sName] == nil) then
local segment = CheckIP(user.sIP)
arrExtraInfo[user.sName] = "::["..segment.."]::["
SendToAll("$MyINFO $ALL "..user.sName.." ::["..segment.."]::["..info)
if (uLaterPtokax == 1) then
OnExit()
end
else
SendToAll("$MyINFO $ALL "..user.sName.." "..arrExtraInfo[user.sName]..info)
end
return 1
end
if (strsub(data,1,12) == "$GetNickList") then
SendInfo(user)
return 1
end
end
function CheckIP(sIP)
local ip,seg
for ip, seg in arrIP do
if (ip == strsub(sIP,1,strlen(ip))) then
return seg
end
end
return "NONE"
end
function SendInfo(user)
local usr,seg
for usr, seg in arrExtraInfo do
if (GetItemByName(usr) ~= nil and GetItemByName(usr).sMyInfoString ~= nil) then
local s,e,info = strfind(GetItemByName(usr).sMyInfoString, "$MyINFO%s+$ALL%s+%S+%s+(.+)")
user:SendData("$MyINFO $ALL "..GetItemByName(usr).sName.." "..arrExtraInfo[GetItemByName(usr).sName]..info)
elseif (GetItemByName(usr) == nil) then
arrExtraInfo[usr] = nil
end
end
if (uLaterPtokax == 1) then
OnExit()
end
end
function Refresh()
local usr,aux
for usr, seg in arrExtraInfo do
if (GetItemByName(usr) == nil) then
arrExtraInfo[usr] = nil
end
end
if (uLaterPtokax == 1) then
OnExit()
end
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
sTmp = sTmp..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
Hi! Great work! But showing only info on join...showing info in description don't working ?(
Hi,
Try out this one...
--## Made by nErBoS
--## Based in a script given by TyShkan
--## Requested by TyShkan
sBot = "Login"
--## Configuration ##--
arrIP = {
["255.255.255."] = "Admin's Segment",
["100.100.100."] = "Simple",
["213.33."] = "UltraNet",
}
uLaterPtokax = 0 -- Choose 0 if you are using a Ptokax version 0.3.3.0 or higher
-- Choose 1 if you are using a Ptokax version lower then 0.3.3.0
--## END ##--
arrExtraInfo = {}
fExtraInfo = "info.dat"
function Main()
frmHub:RegBot(sBot)
frmHub:EnableFullData(1)
LoadFromFile(fExtraInfo)
Refresh()
end
function OnExit()
SaveToFile(fExtraInfo , arrExtraInfo , "arrExtraInfo")
end
function NewUserConnected(user)
local s,e,desc,share,segment = strfind(user.sMyInfoString, "$MyINFO%s+$ALL%s+%S+%s+(.+)%$.+%$(%d+)%$")
if (share == nil or tonumber(share) == nil) then
share = 0
else
share = tonumber(share)
share = format("%0.0f", share/(1024*1024*1024))
end
segment = CheckIP(user.sIP)
arrExtraInfo[user.sName] = "::["..segment.."]::["
SendToAll(sBot, "::["..user.sName.."]::["..user.sIP.."]::["..segment.."]::["..share.."Gb]::")
end
function UserDisconnected(user)
arrExtraInfo[user.sName] = nil
end
OpConnected = NewUserConnected
OpDisconnected = UserDisconnected
function DataArrival(user, data)
if (strsub(data,1,8) == "$GetINFO") then
SendInfo()
return 1
end
if (strsub(data,1,7) == "$MyINFO") then
local s,e,nick,info = strfind(data, "%$MyINFO%s+%$ALL%s+(%S+)%s+(.+)")
if (arrExtraInfo[nick] == nil) then
local segment = CheckIP(GetItemByName(nick).sIP)
arrExtraInfo[nick] = "::["..segment.."]::["
if (uLaterPtokax == 1) then
OnExit()
end
end
SendInfo()
return 1
end
end
function CheckIP(sIP)
local ip,seg
for ip, seg in arrIP do
if (ip == strsub(sIP,1,strlen(ip))) then
return seg
end
end
return "NONE"
end
function SendInfo()
local usr,seg
for usr, seg in arrExtraInfo do
if (GetItemByName(usr) ~= nil and GetItemByName(usr).sMyInfoString ~= nil) then
local s,e,info = strfind(GetItemByName(usr).sMyInfoString, "$MyINFO%s+$ALL%s+%S+%s+(.+)")
SendToAll("$MyINFO $ALL "..GetItemByName(usr).sName.." "..arrExtraInfo[GetItemByName(usr).sName]..info)
elseif (GetItemByName(usr) == nil) then
arrExtraInfo[usr] = nil
end
end
if (uLaterPtokax == 1) then
OnExit()
end
end
function Refresh()
local usr,aux
for usr, seg in arrExtraInfo do
if (GetItemByName(usr) == nil) then
arrExtraInfo[usr] = nil
end
end
if (uLaterPtokax == 1) then
OnExit()
end
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
sTmp = sTmp..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
Sometimes fails, just refresh the user list and all be solved.
Best regards, nErBoS
This send's to me:
[22:13:53] <::[X]::> Data: $Key ?w?sEg???qD?"???af?&0b?/%DCN000%/%?????!????Ò??v???7
[22:13:53] <::[X]::> Data: $ValidateNick TyShkan
[22:13:53] <::[X]::> Data: $MyPass ***
[22:13:53] <::[X]::> Data: $Version 1,0091
[22:13:53] <::[X]::> Data: $GetNickList
;(
Hi,
Sorry forgot to remove that i made that to help me out. Script above edited.
Best regards, nErBoS
And now only onjoin...