i would like to request a little script that logs all ip who entered the hub, and you can search for an ip among the logged ip?s and get the users nick too
-- IPLog/IPsearch Script [API 2]
-- Made by speedX (Requested by ExtreeM)
-- includes jiten's serialize function and some code bits from Mutor's scripts
-- Added Rightclick menu (Requested by ExtreeM)
-- File Name
fIPFile = "IPLog.tbl"
-- Bot Name
sBot = SetMan.GetString(21)
-- Search Command
IPsearch = "ip"
OnStartup = function()
if loadfile(fIPFile) ~= nil then dofile(fIPFile)
else
UserIP = {}
SaveToFile(fIPFile, UserIP, "UserIP")
end
if sBot ~= SetMan.GetString(21) then Core.RegBot(sBot,"","",true) end
end
UserConnected = function(user)
Core.SendToNick(user.sNick,"<"..sBot.."> Welcome "..user.sNick..", speedX's IPLog 1.0 is enabled. RightClick for menu.")
UserIP[string.lower(user.sNick)] = {user.sIP}
SaveToFile(fIPFile, UserIP, "UserIP")
if tCommands[IPsearch].tLevels[user.iProfile] then
Core.SendToNick(user.sNick,"$UserCommand 1 3 IPLog\\Search IP$<%[mynick]> +"..IPsearch.." %[line:Nick/IP]||")
end
end
OpConnected = UserConnected
RegConnected = UserConnected
ChatArrival = function(user,data)
local _,_,to = string.find(data,"^$To:%s(%S+)%s+From:")
local _,_,cmd = string.find(data,"%b<> %p(%w+)")
if cmd and tCommands[cmd:lower()] then
cmd = cmd:lower()
if tCommands[cmd].tLevels[user.iProfile] then
if to and to == sBot then
return Core.SendPmToNick(user.sNick,sBot,tCommands[cmd].sFunction(user,data)), true
else
return Core.SendToNick(user.sNick,"<"..sBot.."> "..tCommands[cmd].sFunction(user,data)), true
end
else
if to and to == sBot then
return Core.SendPmToNick(user.sNick,sBot, "*** Error: You are not allowed to use this command!"), true
else
return Core.SendToNick(user.sNick,"<"..sBot.."> Error: You are not allowed to use this command!"), true
end
end
end
end
ToArrival = ChatArrival
tCommands = {
[IPsearch] = {
sFunction = function(user,data)
local msg = ""
local _,_,arg = string.find(data,"%b<> %p%w+ (%S+)|")
if arg then
if CheckUser(arg) then
msg = "Nick: "..arg.."\tIP: "..CheckUser(arg)[1]
return msg
else
for i,v in pairs(UserIP) do
if v[1] == arg then
msg = msg.."\r\n\tNick: "..i.."\tIP: "..v[1]
end
end
if msg == "" then
return "Invalid string. Not found in Database"
else
return msg
end
end
else
return "Use +ip <nick/ip>"
end
end,
tLevels = {[-1] = false,[0] = true,[1] = true,[2] = true,[3] = false},
}
}
CheckUser = function(arg)
for i,v in pairs(UserIP) do
if i:lower() == arg:lower() then
return UserIP[i]
end
end
end
Serialize = function(tTable,sTableName,hFile,sTab)
sTab = sTab or "";
hFile:write(sTab..sTableName.." = {\n");
for key,value in pairs(tTable) do
if (type(value) ~= "function") then
local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key);
if(type(value) == "table") then
Serialize(value,sKey,hFile,sTab.."\t");
else
local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value);
hFile:write(sTab.."\t"..sKey.." = "..sValue);
end
hFile:write(",\n");
end
end
hFile:write(sTab.."}");
end
SaveToFile = function(file,table,tablename)
local hFile = io.open(file,"w+") Serialize(table,tablename,hFile); hFile:close()
end
Tell me if it suits your request....
looks fine and thx for the very quick script speedx :)
i have some small changes
RC commands
and just to be sure, the script doesnt delete all ip after reboot??
Quote from: ExtreeM on 07 February, 2008, 20:05:24
RC commands
will be added in next version
Quote from: ExtreeM on 07 February, 2008, 20:05:24
and just to be sure, the script doesnt delete all ip after reboot??
Do you want it to delete all ip's after reboot?? Currently it doesn't..
Thanks alot good work