i bild a script ho make log whit user ip
not finish yet
i have one little problem
log ip dont work like i expected
if user have a nik whitout [] work ok
but if fave a nik like [dsl]dief
in this section :
if string.find(line,usernam) then
local _,_,des = string.find(line,"%b==(%d+)")
des = des + 1
count = 1
ma = ma..""..usernam.."=="..des.."\r\n"
else
ma = ma..line.."\r\n"
end
string.find not detect the to be this string in the line (user.sname)
some one whit some ideea
like usually i`m not a good writer .. sorry , and hope some one understand
final script posted at
http://forum.ptokax.org/index.php?topic=6421.0
%b== shouldn't work....
cause it needs <>, (), [] or {}
please give the format of the logs...
what is an example line that the string.find(line,"%b==(%d+)") should match ?
Something noticable in the script of yours is this:
if io.open(pathIp.."/"..userip..ext) == nil then io.open(pathIp.."/"..userip..ext,"w") end
nice thinking ;) I'll do some testing but I think it should be ok,... have you checked that this behaves as expected ?
the ideea work it to count the number o how many time
a user from ip x.x.x.x log on the hub and
and see what nick it used most
in theat section of script string.find
dont match the line ho it read ok
for example :
read value of line it - [dsl]dief==1
when make if string.find(line,usernam) then
where usernam = [dsl]dief
string.find return nil :(
in rest the script work ok
and the log are ok beside that little problem above
no error return from the hub
then try changing
local s,e, des= string.find(line,"%b==(%d+)")
to
local s,e, des = string.find( line, "%=%=(%d+)$" )
if you are on lua 5.1 then try changing string.find with string.match since it saves you from using the s,e variables..
local des = string.match( line, "%=%=(%d+)$")
i whil ...
and post the result after testing
no change ,
but ho i wrote above the problem it not at
local s,e, des= string.find(line,"%b==(%d+)") |
i change the line but the problem it not gone
the problem persist
and like i write above it if user have thei nickname letter like []
read value of line it - [dsl]dief==1 when make if string.find(line,usernam) then where usernam = [dsl]dief string.find return nil
|
if i change whit string.match
no change :((
modify the first post
it at most final version
after i solve the above problem :( :'(
This is what you posted
if string.find(line,usernam) then
local _,_,des = string.find(line,"%b==(%d+)")
des = des + 1
count = 1
ma = ma..""..usernam.."=="..des.."\r\n"
else
ma = ma..line.."\r\n"
end
Try this one, read the comments,... ;)
--- use this function for making the usernam variable (a string) pure since the regular expression in the string.find is a string too
local function Purify( s )
local t, r = { ['['] = 1, [']'] = 1, ['?'] = 1, ['+'] = 1, ['*'] = 1, ['.'] = 1, ['-'] = 1, ['%'] = 1, ['$'] = 1, ['^'] = 1, ['('] = 1, [')'] = 1, ['{'] = 1, ['}'] =1 }, ''
for char in string.gmatch( s, '(.)' ) do
local esc = ''
if t[char] then esc = '%' end
r = r..esc..char
end
return r
end
--- now your piece of script looks like this ... string.match applied..
if string.find(line, Purify(usernam) ) then
local des = string.match( line, "%S+==(%d+)" )
des = des + 1
count = 1
ma = ma..usernam.."=="..des.."\r\n"
else
ma = ma..line.."\r\n"
end
also you could do the following,...
if ( string.sub(line, 1, string.len(usernam) ) == usernam ) then
local des = string.match ( line, "%S+%=%=(%d+)$" )
des = des + 1
count = 1
ma = ma..usernam.."=="..des.."\r\n"
else
ma = ma..line.."\r\n"
end
i will test first
if ( string.sub(line, 1, string.len(usernam) ) == usernam ) then
local des = string.match ( line, "%S+%=%=(%d+)$" )
des = des + 1
count = 1
ma = ma..usernam.."=="..des.."\r\n"
else
ma = ma..line.."\r\n"
end
and post the result after
now work ok
but i have one question
why string.find or string.match return nil ... ???
10x a lot for help
Quote from: dragos_sto on 22 September, 2006, 12:11:01
now work ok
but i have one question
why string.find or string.match return nil ... ???
10x a lot for help
because they don't find anything that matches the regular expression we provide it with...
- check what the 'line' var is just before it goes into the string.find/match
- check the regular expression with a sample target string,... in this case do a
local line = "nick==4"
the file log look the same like for other ip
when sendtoall the line to se what value return
in front of the nick appear "-" from nowhere
Maybe trying "(%d+)$" instead of "%S+%=%=(%d+)$" will help,... it means : the number(s) at the end of the string
I have a problem ..
This script is startng and working fine only for some time with ptokex 0.3.6. after some time (approx 1 min) ,
It is giving an error
UserInfo.lua:103: bad argument #1 to 'lines' (UserInfo/skamslast.log: No such file or directory)
and it is not working anymore.. ???
Some body help!!!!!!
By skamlast I mean.. It is a user.. wvrytime some diferent name is coming , which is basicaly name of any user..
skamslast.log exist in userinfo folder ?
delete the file and see if the error ocure
I m using Rincefield IP log now .. SO i havnt tried. :)