-- PtokaX Lua 5 version by PPK
-- vim:ts=4:sw=4:noet
-- PtokaX OpComExtra.lua 1.1 (Sedulus/20030314) tested on PtokaX 0.3.2.4 IceCube-III-fix3
-- based on OpComExtra.lua for DCH++ by Sedulus
-- created for Cop][Killer of the [TropiCo.se] network
-- no rights reserved (although it would be nice if you kept my name in here)
bot_name = frmHub:GetHubSecAliasName()
max_table_siz = 8 -- the maximum number of nick/times per IP and ip/times per nick stored
max_history_siz = 100 -- the maximum number of last logins recorded
--
-- start
--
IPTable = {} -- store info about IP's here
NickTable = {} -- store info about Nicks here
HistoryTable = {} -- store last logins
-- Gets called upon arrival of a chat or pm message
function clientMessage(client, msg, loc)
if string.sub(msg, 1, 7) == "ipinfo " then
if client.bOperator then
local ip = string.sub(msg, 8)
if IPTable[ip] then
local str = "ipinfo on: "..ip.."\r\n"
for key, elem in IPTable[ip] do
if key ~= "n" then str = str..elem.."\r\n" end
end
messageClient(client, loc, bot_name, str)
else
messageClient(client, loc, bot_name, "no ipinfo on: "..ip)
end
end
return 1
elseif string.sub(msg, 1, 9) == "userinfo " then
if client.bOperator then
local nick = string.sub(msg, 10 )
if NickTable[nick] then
local str = "userinfo on: "..nick.."\r\n"
for key, elem in NickTable[nick] do
if key ~= "n" then str = str..elem.."\r\n" end
end
messageClient(client, loc, bot_name, str)
else
messageClient(client, loc, bot_name, "no userinfo on: "..nick)
end
end
return 1
elseif msg == "history" or string.sub( msg, 1, 8 ) == "history " then
if client.bOperator then
local num = tonumber(string.sub(msg, 10))
local start
local last = table.getn(HistoryTable)
if not num or num <= 0 or num > last then
start = 1
else
start = last - num + 1
end
local str = "last login history:\r\n"
for i = start, last do
str = str..i.."\t"..HistoryTable[i].."\r\n"
end
messageClient(client, loc, bot_name, str)
end
return 1
end
end
-- Gets called when a new user connects
function userConnected(client)
local nick = client.sName
local ip = client.sIP
local level = client.bOperator
if not level then level = 0 else level = 1 end
-- create tables
if not IPTable[ip] then IPTable[ip] = {} end
if not NickTable[nick] then NickTable[nick] = {} end
-- remove first so we scroll (max_table_siz/max_history_siz)
if table.getn(IPTable[ip]) == max_table_siz then table.remove(IPTable[ip], 1) end
if table.getn(NickTable[ nick ] ) == max_table_siz then table.remove(NickTable[nick], 1) end
if table.getn(HistoryTable) == max_history_siz then table.remove(HistoryTable, 1) end
-- add newest entry
table.insert(IPTable[ip], os.date()..": ["..level.."] "..nick )
table.insert(NickTable[nick], os.date()..": "..ip )
table.insert(HistoryTable, os.date()..": ["..level.."] "..nick.." - "..ip )
end
-- Checks if this is a message for us
function isMessageForMe(data)
local ret,c,msg = string.find( data, "^%b<> !(.*)|$" )
if ret then
return msg,0
end
return nil
end
-- Send client a message
function messageClient(client, where, from, msg)
if where == 0 then
client:SendData("<"..from.."> "..msg.."|")
end
end
-- Event: arrival of data
function ChatArrival(curUser, sData)
local msg,loc = isMessageForMe(sData)
if msg then
return clientMessage(curUser, msg, loc)
end
end
-- Event: new user
function NewUserConnected(curUser)
return userConnected(curUser)
end
-- Event: new op
function OpConnected(curUser)
return userConnected(curUser)
end
plop
-- PtokaX Lua 5 version by PPK
-- vim:ts=4:sw=4:noet
-- PtokaX OpComExtra.lua 1.1 (Sedulus/20030314) tested on PtokaX 0.3.2.4 IceCube-III-fix3
-- based on OpComExtra.lua for DCH++ by Sedulus
-- created for Cop][Killer of the [TropiCo.se] network
-- no rights reserved (although it would be nice if you kept my name in here)
-- now saves to files, does some otherstuff and is DSN ready ...uwv
-- usercommands glued in & 5.0.x version by UwV
-- you need the three following files in your script folder : " ntable.tbl " " htable.tbl " and " itable.tbl "
bot_name = frmHub:GetHubSecAliasName() -- botname 1 to react to commands in PM
bot_name2 = "-=Holly=-" -- botname 2 to react to commands in PM
max_table_siz = 7 -- the maximum number of nick/times per IP and ip/times per nick stored
max_history_siz = 604 -- the maximum number of last logins recorded
the next thingy keeps getting messed up when i post it,,
" | " it changes to : " | "
(and this color trick won't work inside code tags)
so please dl the attachement ..
It works now, no errors :-*
thx UwV