PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: D-J Valhala on 04 July, 2004, 17:49:11

Title: HELP!!!
Post by: D-J Valhala on 04 July, 2004, 17:49:11
i need stand aloun script ASAP!!!
+ip will show me all IP's that connected to the hub
thanks :D
Title:
Post by: nErBoS on 05 July, 2004, 02:38:08
Hi,

Hope it helps...

--#############################################################################--
--## Nick and IP logger                                                      ##--
--## Requested by D-J Valhala                                                ##--
--## Made by nErBoS                                                          ##--
--## Command:     ##--
--## +ip - Will show the nicks and ips of all connected users     ##--
--#############################################################################--

sBot = "IP-Logger"

arrIP = {}
fileIP = "ip.log"

--## Configuration ##--

uLaterPtokax = 0 --## If you are using ptokax 0.3.30 or higher choose 0
--## If you are using lower versions then ptokax 0.3.3.0 choose 1

fileIP = "ip.log" --## This file will be created to save the users and ips

--## End of Configuration ##--

function Main()
LoadFromFile(fileIP)
CheckForUser()
end

function OnExit()
SaveToFile(fileIP , arrIP , "arrIP")
end

function NewUserConnected(user)
arrIP[user.sName] = user.sIP
end

function UserDisconnected(user)
arrIP[user.sName] = nil
if (uLaterPtokax == 1) then
SaveToFile(fileIP , arrIP , "arrIP")
end
end

NewUserConnected = OpConnected
UserDisconnected = OpDisconnected

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 == "+ip" and user.bOperator) then
local sTmp,usr,ip = "Connected User's and their IP's:\r\n\r\n"
for usr, ip in arrIP do
sTmp = sTmp.."User: "..usr.."\tIP: "..ip.."\r\n"
end
user:SendPM(sBot, sTmp)
return 1
end
end
end

function CheckForUser()
local usr,ip
for usr, ip in arrIP do
if (GetItemByName(usr) == nil) then
arrIP[usr] = nil
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

Best regards, nErBoS
Title:
Post by: D-J Valhala on 05 July, 2004, 03:08:13
hehehehe crazy dude :P
thank you again lol talk to you in my hub :P
i haven't test it yet with users but i'm sure it will work good... :)
Title:
Post by: D-J Valhala on 10 July, 2004, 21:45:01
nErBoS wazzzzzap? :)
the Bot is working but it wont show the IP's :\
Title:
Post by: Snooze on 10 July, 2004, 22:24:43
I noted this part of the script ...

--## Configuration ##--

uLaterPtokax = 0 --## If you are using ptokax 0.3.30 or higher choose 0
--## If you are using lower versions then ptokax 0.3.3.0 choose 1

fileIP = "ip.log" --## This file will be created to save the users and ips

--## End of Configuration ##--

Have you made the correct config ?


**Snooze
Title:
Post by: nErBoS on 11 July, 2004, 01:22:36
Hi,

Little Bug corrected and tested...

--## Nick and IP logger                                              
--## Requested by D-J Valhala                                        
--## Made by nErBoS                                                    
--## Command:  
--## +ip - Will show the nicks and ips of all connected users  

sBot = "IP-Logger"

arrIP = {}
fileIP = "ip.log"

--## Configuration ##--

uLaterPtokax = 0 --## If you are using ptokax 0.3.30 or higher choose 0
--## If you are using lower versions then ptokax 0.3.3.0 choose 1

fileIP = "ip.log" --## This file will be created to save the users and ips

--## End of Configuration ##--

function Main()
frmHub:RegBot(sBot)
LoadFromFile(fileIP)
CheckForUser()
end

function OnExit()
SaveToFile(fileIP , arrIP , "arrIP")
end

function NewUserConnected(user)
arrIP[user.sName] = user.sIP
end

function UserDisconnected(user)
arrIP[user.sName] = nil
if (uLaterPtokax == 1) then
SaveToFile(fileIP , arrIP , "arrIP")
end
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 == "+ip" and user.bOperator) then
local sTmp,usr,ip = "Connected User's and their IP's:\r\n\r\n"
for usr, ip in arrIP do
sTmp = sTmp.."User: "..usr.."\tIP: "..ip.."\r\n"
end
user:SendPM(sBot, sTmp)
return 1
end
end
end

function CheckForUser()
local usr,ip
for usr, ip in arrIP do
if (GetItemByName(usr) == nil) then
arrIP[usr] = nil
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

Best regards, nErBoS
Title:
Post by: blackwings on 11 July, 2004, 06:03:08
could you add number on each side of the User+IP, I mean like this =

(4) User: tester   IP: 213.114.174.138 (4)

Because then it will be easier when you look at the log
Title:
Post by: witch on 11 July, 2004, 12:38:31
I did test it.....works Fine!

Thanx nErBoS! Good work man  :P
Title:
Post by: D-J Valhala on 11 July, 2004, 14:54:23
PERFECT!!!  :D
Title:
Post by: NightLitch on 11 July, 2004, 15:04:48
try change Nerbos DataArrival 2 this one:

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 == "+ip" and user.bOperator) then
local sTmp,usr,ip = "Connected User's and their IP's:\r\n\r\n"
local Temp = {}
for usr, ip in arrIP do
tinsert(Temp, {usr,ip})
end
for i=1,getn(Temp) do
sTmp = sTmp.."("..i..") User: "..Temp[i][1].."\tIP: "..Temp[i][2].." ("..i..")\r\n"
end
user:SendPM(sBot, sTmp)
return 1
end
end
end

/NL
Title:
Post by: D-J Valhala on 11 July, 2004, 16:53:17
Done! :)
thank you to mate!
Title:
Post by: nErBoS on 12 July, 2004, 11:35:51
Hi,

Filling some requests...

--## Nick and IP logger
--## Added Number to Loggers                                            
--## Requested by D-J Valhala                                        
--## Made by nErBoS                                                    
--## Command:  
--## +ip - Will show the nicks and ips of all connected users
--## +getip - Will give you the ip of the nick

sBot = "IP-Logger"

arrIP = {}

--## Configuration ##--

uLaterPtokax = 0 --## If you are using ptokax 0.3.30 or higher choose 0
--## If you are using lower versions then ptokax 0.3.3.0 choose 1

fileIP = "ip.log" --## This file will be created to save the users and ips

--## End of Configuration ##--

function Main()
frmHub:RegBot(sBot)
LoadFromFile(fileIP)
CheckForUser()
end

function OnExit()
SaveToFile(fileIP , arrIP , "arrIP")
end

function NewUserConnected(user)
arrIP[user.sName] = user.sIP
end

function UserDisconnected(user)
arrIP[user.sName] = nil
if (uLaterPtokax == 1) then
SaveToFile(fileIP , arrIP , "arrIP")
end
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 == "+ip" and user.bOperator) then
local sTmp,count,usr,ip = "Connected User's and their IP's:\r\n\r\n",0
for usr, ip in arrIP do
count = count + 1
sTmp = sTmp.."("..count..") User: "..usr.."\tIP: "..ip.." ("..count..")\r\n"
end
user:SendPM(sBot, sTmp)
return 1
elseif (cmd == "+getip" and user.bOperator) then
local s,e,usr = strfind(data, "%b<>%s+%S+%s+(%S+)")
if (usr == nil) then
user:SendPM(sBot, "Syntax Error, !getip , you must write a nick.")
elseif (GetItemByName(usr) == nil) then
user:SendPM(sBot, "The user "..usr.." isn't online.")
else
user:SendPM(sBot, "The user "..GetItemByName(usr).sName.." ip is: "..GetItemByName(usr).sIP)
end
return 1
end
end
end

function CheckForUser()
local usr,ip
for usr, ip in arrIP do
if (GetItemByName(usr) == nil) then
arrIP[usr] = nil
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

Best regards, nErBoS
Title:
Post by: witch on 12 July, 2004, 12:02:18
..hmmm it didn't show all ip's now  :rolleyes:
Title:
Post by: NightLitch on 12 July, 2004, 12:13:46
You are welcome trying my IP-Bot that have been around for sometime:

LINK (http://board.univ-angers.fr/thread.php?threadid=1600&boardid=12&styleid=1&sid=044a6e8071971bf8d7c0501669535bf4)

You can view all namnes and all ips over users.

ex.

Nick > 5 ips,  IP > 8 nicks


/NL
Title:
Post by: witch on 12 July, 2004, 12:36:59
Thanx NightLitch dude!

i will give a try...  :))
Title:
Post by: D-J Valhala on 12 July, 2004, 13:33:28
hehehe cooL mate :) work perfect  :D
Title:
Post by: nErBoS on 12 July, 2004, 23:00:15
Hi,

Quote..hmmm it didn't show all ip's now

Try to delete the old ip.log and restart the Hub. Made also a little fix in the last script.

Best regards, nErBoS
Title:
Post by: witch on 13 July, 2004, 12:40:06
Done! Works fine!

Thanx nErBoS dude  :)
Title:
Post by: D-J Valhala on 13 July, 2004, 15:29:20
hehe
nErBoS = The BEST Scripter in the world :P
make all my hub bot's perfect :)
ahh BTW nErBoS please let me know if you find your server :P
Title:
Post by: nErBoS on 14 July, 2004, 01:53:00
Hi,

It will be hard, but thanks for the help :)

Best regards, nErBoS
Title:
Post by: D-J Valhala on 14 July, 2004, 13:19:59
i hope you will be the best :) coz for me you are the best! :D