users and their IPs
 

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

users and their IPs

Started by daft009, 14 March, 2004, 03:33:43

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

daft009

hi,

i've tried searching but couldnt find anything so am posting here.

i would like a simple script which gives me the IPs of all users currently connected to the hub (or IPs of all users registered)

i currently use L.I.S and NXS-3, both of which i dont think can do it.

it should give a result like this.

Quoteusername: IP
username: IP
...
...
...

thanks

nErBoS

Hi,

Hope it helps...

--Requested by daft009
--Made by nErBoS

Bot = "IPs-Connected"

connectedusers = "users.txt"

function Main()
	frmHub:RegBot(Bot)
end

function NewUserConnected(user, data)
	DealUser(user, data, "ADD")
end

function UserDisconnected(user, data)
	DealUser(user, data, "REMOVE")
end

OpConnected = NewUserConnected
OpDisconnected = UserDisconnected

function DataArrival(user, data)
	if (strsub(data,1,1)=="<") or (strsub(data,1,5+strlen(Bot))=="$To: "..Bot) then
	data=strsub(data,1,strlen(data)-1)
	s,e,cmd = strfind(data,"%b<>%s+(%S+)")
		if (cmd=="!allips") then
			user:SendPM(Bot, ReadUser())
			return 1
		end
	end
end

function DealUser(user, data, type)
local tmp = ""
local time = 0
	readfrom(connectedusers)
	while 1 do
	local line = read()
		if (line == nil) then
			if (type == "ADD" and time == 0) then
				tmp = tmp..user.sName.."\r\n"
				break
			elseif (type == "REMOVE") then
				break
			else
				break
			end
		elseif (line == "" and type == "ADD") then
				tmp = tmp..user.sName.."\r\n"
				time = 1
		else
			local s,e,usr = strfind(line, "(%S+)")
			if (type == "ADD") then
				if (usr ~= nil and user.sName == usr) then
					time = 1
				else
					tmp = tmp..line.."\r\n"
				end
			elseif (type == "REMOVE") then
				if (usr ~= nil and usr == user.sName) then
				else
					tmp = tmp..line.."\r\n"
				end
			end
		end
	end
	readfrom()

writeto(connectedusers)
write(tmp)
writeto()
end

function ReadUser()
local tmp = ""
tmp = tmp.."All users connected and their ips: \r\n\r\n"
tmp = tmp.."User: IP\r\n\r\n"
	readfrom(connectedusers)
	while 1 do
	local line = read()
		if (line == nil) then
			break
		else
			local s,e,usr = strfind(line, "(%S+)")
			if (usr ~= nil and GetItemByName(usr) ~= nil) then
				tmp = tmp..usr..": "..GetItemByName(usr).sIP
			end
		end
	end
	readfrom()
return tmp
end

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

daft009

#2
hi nErBoS,

thanks for the fast reply.

i hope i'm not troubling you too much by asking this.

1. is it possible to change it so the script gives me the IPs of whoever is connected at that point in time. (as right now it only gives me the IPs of users who have newly connected)

2. is it possible to make it a hidden bot (so it doesnt appear in the users list)

3. is it possible to make it so only OPs and above can use the command (if that isnt the case already)


EDIT: it seems its not putting new lines after each IP.

the current output is:

Quoteusername: IPusername: IPusername: IP

nErBoS

#3
Hi,

--Requested by daft009
--Made by nErBoS

Bot = "IPs-Connected"

connectedusers = "users.txt" --Will be created in the script folder

function Main()
end

function NewUserConnected(user, data)
	DealUser(user, data, "ADD")
end

function UserDisconnected(user, data)
	DealUser(user, data, "REMOVE")
end

OpConnected = NewUserConnected
OpDisconnected = UserDisconnected

function DataArrival(user, data)
	if (strsub(data,1,1)=="<") or (strsub(data,1,5+strlen(Bot))=="$To: "..Bot) then
	data=strsub(data,1,strlen(data)-1)
	s,e,cmd = strfind(data,"%b<>%s+(%S+)")
		if (cmd=="!allips") then
			if (user.bOperator) then
				user:SendData(Bot, ReadUser())
				return 1
			else
				user:SendData(Bot, "You don?t have permission to use this command.")
			end
		end
	end
end

function DealUser(user, data, type)
local tmp = ""
local time = 0
	readfrom(connectedusers)
	while 1 do
	local line = read()
		if (line == nil) then
			if (type == "ADD" and time == 0) then
				tmp = tmp..user.sName.."\r\n"
				break
			elseif (type == "REMOVE") then
				break
			else
				break
			end
		elseif (line == "" and type == "ADD") then
				tmp = tmp..user.sName.."\r\n"
				time = 1
		else
			local s,e,usr = strfind(line, "(%S+)")
			if (type == "ADD") then
				if (usr ~= nil and user.sName == usr) then
					time = 1
				else
					tmp = tmp..line.."\r\n"
				end
			elseif (type == "REMOVE") then
				if (usr ~= nil and usr == user.sName) then
				else
					tmp = tmp..line.."\r\n"
				end
			end
		end
	end
	readfrom()

writeto(connectedusers)
write(tmp)
writeto()
end

function ReadUser()
local tmp = ""
tmp = tmp.."All users connected and their ips: \r\n\r\n"
tmp = tmp.."User: IP\r\n\r\n"
	readfrom(connectedusers)
	while 1 do
	local line = read()
		if (line == nil) then
			break
		else
			local s,e,usr = strfind(line, "(%S+)")
			if (usr ~= nil and GetItemByName(usr) ~= nil) then
				tmp = tmp..usr..": "..GetItemByName(usr).sIP.."\r\n"
			end
		end
	end
	readfrom()
return tmp
end

1. The script saves in the file all connected users when they leave the HUB they are erased from that file, but if you have put the script when the HUB was runnig you have to start the hub from the begining to write all users.

2. Done

3. Done, sorry i have forgotten that.

About the other porbelm with lines, solved my bad :).

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

daft009

thanks for that. works a treat!

much appreciated  :D

SMF spam blocked by CleanTalk