Ip-segment's in description
 

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

Ip-segment's in description

Started by TyShkan, 21 August, 2004, 19:00:29

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

TyShkan

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?

nErBoS

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
--## nErBoS Spot ##--

TyShkan

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? :))

nErBoS

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
--## nErBoS Spot ##--

TyShkan

Hi! Great work! But showing only info on join...showing info in description don't working ?(

nErBoS

#5
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
--## nErBoS Spot ##--

TyShkan

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
;(

nErBoS

Hi,

Sorry forgot to remove that i made that to help me out. Script above edited.

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

TyShkan

And now only onjoin...

SMF spam blocked by CleanTalk