PtokaX forum

Development Section => Your Developing Problems => Topic started by: NightLitch on 05 November, 2003, 11:26:17

Title: Getting Double message, becouse of small/big chatacters
Post by: NightLitch on 05 November, 2003, 11:26:17
I Am getting double message's when typing the nicks name in my functions...

!info Nick

shows:

Nick & nick from Banlist

I want it To sense that both is the same.... and only view ONE message line... how do I do that...

this is the code I Am using:

local ViewBanOne = ""
ReadLog(BANMESSAGE,"GR8-files/bans.dat")
for vnick,vmessage in BANMESSAGE do
local _,_,vNICKE,vMESSE = strfind(vnick, "(%S+) (S+)")
if vnick ~= tUser then
curUser:sendmessage(BOTNAME,"Last Ban Message: "..vmessage)
ViewBanOne = 1
end
end
if ViewBanOne == "" then
curUser:sendmessage(BOTNAME,"Last Ban Message: N/A")
end


I get - Last Ban Message - twice- BECOUSE the name is different in the BANLOG....

ex:

Nick ip Reason
nick ip Reason

becouse of  (  N ,  n  )   it show's twice....  any idea...

/NightLitch
Title:
Post by: NightLitch on 05 November, 2003, 11:39:57
plz anyone.... help....

Skrollster.... Tezlo....

/NightLitch
Title:
Post by: OpiumVolage on 05 November, 2003, 11:46:31
In you banlog, add only lowercase nicks, there is where your problem is.
Title:
Post by: NightLitch on 05 November, 2003, 12:00:03
But how Am I supposed to do that...

this is the ban code....

and plz Opium could plz explain why I always get - for no reason- .... I don't get the reason I written(the reason that should be from me...) always get -for no reason-...

but what should be fixed here....

function doBan(curUser, data,cmd)
local _,_,cmd,nick,reason = strfind( data, "%b<>%s+(%S+)%s+(.*)" )
if not nick then
curUser:sendmessage(BOTNAME,"Syntax: !ban [reason]")
return 1
end

local vUser = GetItemByName(nick)
if not vUser then
curUser:sendmessage(BOTNAME,nick.." is not online or wrong name...")
return 1
end
if reason == nil then reason = "for no reason"
else reason = "because "..reason
end

local f = openfile("GR8-files/bans.dat", "a")
if f then
write(f, nick.." "..vUser.sIP.." "..reason.."\r\n")
closefile(f)
end

vUser:SendPM(BOTNAME,"You are being BANNED by "..curUser.sName.." "..reason)
--vUser:Ban()

SendToAll(BOTNAME,"User "..nick.." has been BANNED by "..curUser.sName.." "..reason)
return 1
end


/NightLitch
Title:
Post by: NightLitch on 05 November, 2003, 12:03:01
but It works as I want it to here:

local ViewBanOne = ""
ReadLog(BANMESSAGE,"GR8-files/bans.dat")
for sNICK,sMESS in BANMESSAGE do
local _,_,vNick = strfind(sNICK, "(%S+)")
if nick == sNICK then
curUser:sendmessage(BOTNAME,"Last Ban Message: "..sMESS)
ViewBanOne = 1
end
end
if ViewBanOne == "" then
curUser:sendmessage(BOTNAME,"Last Ban Message: N/A")
end


/NightLitch
Title:
Post by: NightLitch on 05 November, 2003, 12:05:44
But I would like it ro read lowercase only yes...

cause of this I get double of users, deppending on how
you ban/kick the user...

ex:

!kick Nick

then it loggs as ( Nick )  and is taken for Nick

but if

!kick nick

that is to taken as an single user not with Nick...

hope you understand me.... :-)  bad english


/NightLitch
Title:
Post by: NightLitch on 05 November, 2003, 12:10:20
can I affect how the users name is written in log from what the OP is typing from the Client???

ex:

OP = NicK

can be written in script(log) as:

nick

?????


/NightLitch
Title:
Post by: OpiumVolage on 05 November, 2003, 12:15:37
in your ban function, try:

local f = openfile("GR8-files/bans.dat", "a")
if f then
write(f, strlower(nick).." "..vUser.sIP.." "..reason.."\r\n")
closefile(f)
end

Note the strlower() to put all lowercase.
Title:
Post by: NightLitch on 05 November, 2003, 12:19:11
ahh... Thx Opium...
Title:
Post by: NightLitch on 05 November, 2003, 12:21:08
But what is wrong in the:


local _,_,cmd,nick,reason = strfind( data, "%b<>%s+(%S+)%s+(.+)" )


line

Cause can't get reason to work propertly...

only get as above the no reason given....

/NightLitch
Title:
Post by: OpiumVolage on 05 November, 2003, 12:30:55
You are doing 2 captures in 3 vars :)

cmd -> ...(%S+)...

nick -> ...(.+)

reason  -> Nothing

Try something like:

local _,_,cmd,nick,reason = strfind( data, "%b<>%s+(%S+)%s+(%S+)%s+(.+)" )
Title:
Post by: NightLitch on 05 November, 2003, 12:54:30
yes have tried that... BUT!

when doing 3cap 3vars, I MUST enter reason.... or...

cause with this:

local _,_,cmd,nick,reason = strfind( data, "%b<>%s+(%S+)%s+(%S+)%s+(.+)" )
if not nick then
curUser:sendmessage(BOTNAME,"Syntax: !ban [reason]")
return 1
end

local vUser = GetItemByName(nick)
if not vUser then
curUser:sendmessage(BOTNAME,nick.." is not online or wrong name...")
return 1
end
if reason == nil then reason = "for no reason"
else reason = "because "..reason
end

if I write

!ban Nick

I get (  !ban [reason] )

not optional -No Reason Given- Why???

/NightLitch
Title:
Post by: OpiumVolage on 05 November, 2003, 12:59:13
try with your strfind like this:

strfind( data, "%b<>%s+(%S+)%s+(%S+)%s*(.*)" )

because the + means at least 1 char, and * is 0 or more :))

Like this reason can be "" (empty)
Title:
Post by: NightLitch on 05 November, 2003, 13:03:45
thx for the lessons... this is the way I want to be heard and helped... :-)

gonna test...
Title:
Post by: NightLitch on 05 November, 2003, 13:06:31
I get this problem now...

DEBUG
<-Bot->
CMD:!ban
NICK:tester
REASON:because
DEBUG

<-Bot-> User tester has been BANNED by [SU+]NightLitch because


Why is reason being becouse ????

heheh....

This is fun at the same time it is frustrating....


/NightLitch
Title:
Post by: OpiumVolage on 05 November, 2003, 13:21:40
You are capturing nothing (0 chars) with this regex, but reason isn't nil.

QuoteLike this reason can be "" (empty)

try to change if reason == nil by if reason == ""
Title:
Post by: NightLitch on 05 November, 2003, 13:26:46
ahhh... it's so simple... how can I miss that...

Had found my own way around but was alot more "messy" heh...

ThX Opium...  Works great now...
Title:
Post by: tezlo on 06 November, 2003, 13:38:21
the regexp was right in the code i gave you >> (http://www.lua.org/manual/4.0/manual.html#pm)