PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: QuikThinker on 19 May, 2004, 19:59:13

Title: Users registered by who log?
Post by: QuikThinker on 19 May, 2004, 19:59:13
Hey everyone,
   Ma 2 hubs r running with Robocop 6.0d & we use the hub protection option so the users have to reg 2 download or search.
   Ma question is, is it possible 4 when an OP registers a new user there could be a log produced of who exactly registered them? A few users keep comin back & I wanna find out who registers them so I can let em know.

Thanx in advance.
Quik.
Title:
Post by: Optimus on 19 May, 2004, 20:03:56
good idea... i will build that in RC sooner or later
But for now you have to wait for a seperate script writen by some1 else.
Title:
Post by: QuikThinker on 19 May, 2004, 20:16:41
Thanx Opti, i'm glad I could offer a new angle! :D

Can any1 else offer anythin on this?
Title:
Post by: nErBoS on 20 May, 2004, 01:41:03
Hi,

The command that you use to reg users is from robocop ?? what is the command syntax ??

Best regards, nErBoS
Title:
Post by: QuikThinker on 20 May, 2004, 11:16:47
!reguser
Title:
Post by: nErBoS on 20 May, 2004, 12:26:47
Hi,

Try this....

--Requested by QuikThinker
--Made by nErBoS

sBot = "Reg-Logger"

reglog = {}
reglogsv = "reglog.dat"

function Main()
frmHub:RegBot(sBot)
LoadFromFile(reglogsv)
end

function OnExit()
SaveToFile(reglogsv , reglog , "reglog")
end

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 == "!reguser" and user.bOperator) then
local s,e,who,pass = strfind(data, "%b<>%s+%S+%s+(%S+)%s+(%S+)")
if (who ~= nil and pass ~= nil) then
reglog[strlower(who)] = user.sName
end
return 0
elseif (cmd == "!reglog" and user.bOperator) then
RegLog(user)
return 1
end
end
end

function RegLog(user)
local sTmp = "Log of registered users and by who:\r\n\r\n"
local usr,who
for usr, who in reglog do
sTmp = sTmp..usr.."\tRegged by: "..who.."\r\n"
end
user:SendPM(sBot, sTmp)
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

Not sure if it will work since the command is inbuild in RoboCop.

Best regards, nErBoS
Title:
Post by: QuikThinker on 21 May, 2004, 13:01:05
Just got round 2 testin this script mate & it dun seem 2 work. It creates the log file but doesn't add any entries :s
Title:
Post by: nErBoS on 21 May, 2004, 15:01:53
Hi,

That what i was afraid of, it should be working this script only compares the data reciveved by !reg it doesn't block it should be able to robocop deal with. Try to remove the "return 0" on the script.

Best regards, nErBoS