Script, which show all ip's on hub
 

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

Script, which show all ip's on hub

Started by (!(Tys?kan)=), 14 April, 2004, 08:33:53

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

(!(Tys?kan)=)

Exmpl:
!showips

PM to User by Bot:
Name: ip
Name1: ip
Name2: ip
Name3: ip
etc.

Who's want to help me?
--Ty--

nErBoS

#1
Hi,

Hope it helps...

--Requested by (!(Tys?kan)=)
--Made by nErBoS

sBot = "IP-ALL"

loggintxt = "loggin.txt" -- Will be created in the script folder

function Main()
	frmHub:RegBot(sBot)
end

function OnExit()
	remove(loggintxt)
end

function NewUserConnected(user, data)
	OnlineUser(user)
end

function UserDisconnected(user, data)
	OfflineUser(user)
end

OpConnected = NewUserConnected
OpDisconnected = UserDisconnected

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=="!showips") then
			ShowIp(user)
			return 1
		end
	end
end

function OnlineUser(user)
local tmp = ""
local time = 0
	if (readfrom(loggintxt) == nil) then
		writeto(loggintxt)
		write(user.sName)
		writeto()
	else
		readfrom(loggintxt)
		while 1 do
			local line = read()
			if (line == nil) then
				if (time == 0) then
					tmp = tmp..user.sName.."\r\n"
				end
				break
			elseif (line == "") then
				tmp = tmp..user.sName.."\r\n"
				time = 1
			else
				tmp = tmp..line.."\r\n"
			end
		end
		readfrom()
		writeto(loggintxt)
		write(tmp)
		writeto()
	end
end	

function OfflineUser(user)
local tmp = ""
	if (readfrom(loggintxt) ~= nil) then
		readfrom(loggintxt)
		while 1 do
			local line = read()
			if (line == nil) then
				break
			else
				local s,e,who = strfind(line, "(%S+)")
				if (who ~= user.sName) then
					tmp = tmp..line.."\r\n"
				end
			end
		end
		readfrom()
		writeto(loggintxt)
		write(tmp)
		writeto()
	end
end	

function ShowIp(user)
local tmp = ""
tmp = tmp.."All IPS from the HUB:\r\n\r\n"
	if (readfrom(loggintxt) ~= nil) then
		readfrom(loggintxt)
		while 1 do
			local line = read()
			if (line == nil) then
				break
			else
				local s,e,who = strfind(line, "(%S+)")
				if (GetItemByName(who) ~= nil) then
					tmp = tmp.."Name :"..who.." IP: "..GetItemByName(who).sIP.."\r\n"
				end
			end
		end
		readfrom()
	end
	user:SendPM(sBot, tmp)
end

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

(!(Tys?kan)=)

#2
10x, but it is possible in fact to scan a server on names and to see at them ip-addresses, as in a script showing free slot's -- without temp files
--Ty--

nErBoS

Hi,

It?s only possible to call registered user the non-registered the only way is to create a file or table with all users, i have created a file because with a table when you restart the script or hub all will be lost.

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

pHaTTy

little tip forif ya using 0.330, save em allin a table, then use

function OnExit();

to write then in a table on file, then it can be re-asserted ;-)
Resistance is futile!

(!(Tys?kan)=)

This script have bug=)
When the hub gone down and starting table started copying names on hub:

[07:56] All IPS from the HUB:

Name :=Lis= IP: ***.***.**.**
Name :(!(Tys?kan)=) IP: ***.***.**.**
Name :=Lis= IP: ***.***.**.**
Name :Roman(Festi) IP: ***.***.**.**
Name :Faby{10.5.68.53} IP: ***.***.**.**
Name :[??????????]Liar IP: ***.***.**.**
Name :[??????]?FLOOD? IP: ***.***.**.**
Name :[??????]Xirtam IP: ***.***.**.**
Name :WEREWOLF IP: ***.***.**.**
Name :[??????]AlexG IP: ***.***.**.**
Name :Wizard IP: ***.***.**.**
--Ty--

nErBoS

Hi,

Try this one....

--Requested by (!(Tys?kan)=)
--Made by nErBoS

sBot = "IP-ALL"

loggintxt = "loggin.txt" -- Will be created in the script folder

function Main()
	frmHub:RegBot(sBot)
end

function OnExit()
	remove(loggintxt)
end

function NewUserConnected(user, data)
	OnlineUser(user)
end

function UserDisconnected(user, data)
	OfflineUser(user)
end

OpConnected = NewUserConnected
OpDisconnected = UserDisconnected

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=="!showips") then
			ShowIp(user)
			return 1
		end
	end
end

function OnlineUser(user)
local tmp = ""
local time = 0
	if (readfrom(loggintxt) == nil) then
		writeto(loggintxt)
		write(user.sName)
		writeto()
	else
		readfrom(loggintxt)
		while 1 do
			local line = read()
			if (line == nil) then
				if (time == 0) then
					tmp = tmp..user.sName.."\r\n"
				end
				break
			else
				local s,e,who = strfind(line, "(%S+)")
				if (who == user.sName) then
					time = 1
					tmp = tmp..line.."\r\n"
				else
					tmp = tmp..line.."\r\n"
				end
			end
		end
		readfrom()
		writeto(loggintxt)
		write(tmp)
		writeto()
	end
end	

function OfflineUser(user)
local tmp = ""
	if (readfrom(loggintxt) ~= nil) then
		readfrom(loggintxt)
		while 1 do
			local line = read()
			if (line == nil) then
				break
			else
				local s,e,who = strfind(line, "(%S+)")
				if (who ~= user.sName) then
					tmp = tmp..line.."\r\n"
				end
			end
		end
		readfrom()
		writeto(loggintxt)
		write(tmp)
		writeto()
	end
end	

function ShowIp(user)
local tmp = ""
tmp = tmp.."All IPS from the HUB:\r\n\r\n"
	if (readfrom(loggintxt) ~= nil) then
		readfrom(loggintxt)
		while 1 do
			local line = read()
			if (line == nil) then
				break
			else
				local s,e,who = strfind(line, "(%S+)")
				if (GetItemByName(who) ~= nil) then
					tmp = tmp.."Name :"..who.." IP: "..GetItemByName(who).sIP.."\r\n"
				end
			end
		end
		readfrom()
	end
	user:SendPM(sBot, tmp)
end

Phatty OnExit() is only done when the hub is going to be shut down or restart right ?? If yes don?t see the advantage :P, i don?t used table because of the restart script, or i could use but would always been saving in the file when a new user gets connected and disconnected.

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

pHaTTy

onexit is done when scripts restarted or hub closed, meaning instead of using hdd life, u can keep everything in tables, until u restart then it can write everything at once and reload them, saving cpu time also ;-)
Resistance is futile!

nErBoS

Hi,

Thought that OnExit() was only to hub closed, thanks phatty. Tomorrow i do a rewrite of the script today i am to tired :)

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

(!(Tys?kan)=)

10x, script is working :D
--Ty--

nErBoS

Hi,

Try this one then..

--Requested by (!(Tys?kan)=)
--Made by nErBoS

sBot = "IP-ALL"

connectuser = {}
onlinetxt = "online.txt"

function Main()
	frmHub:RegBot(sBot)
end

function OnExit()
	SaveToFile(onlinetxt , connectuser , "connectuser")
end	

function NewUserConnected(user, data)
	if (connectuser[1] == nil and readfrom(onlinetxt) ~= nil) then
		LoadFromFile(onlinetxt)
	end
	
	local pos = 0
	for i=1, getn(connectuser) do
		if (connectuser[i] == user.sName) then
			break
		end
		pos = pos + 1
	end
	connectuser[pos+1] = user.sName
end

OpConnected = NewUserConnected

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=="!showips") then
			ShowIp(user)
			return 1
		end
	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
			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

function ShowIp(user)
local tmp = ""
tmp = tmp.."All IPS from the HUB:\r\n\r\n"
	if (connectuser[1] == nil and readfrom(onlinetxt) ~= nil) then
		LoadFromFile(onlinetxt)
	end

	for i=1, getn(connectuser) do
		if (GetItemByName(connectuser[i]) ~= nil) then
			tmp = tmp..connectuser[i]..": "..GetItemByName(connectuser[i]).sIP.."\r\n"
		end
	end
user:SendPM(sBot, tmp)
end

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

SMF spam blocked by CleanTalk