Author Topic: Getting Double message, becouse of small/big chatacters  (Read 4327 times)

0 Members and 1 Guest are viewing this topic.

Offline NightLitch

  • Emperor
  • **
  • Posts: 1 455
  • Karma: +16/-0
Getting Double message, becouse of small/big chatacters
« 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:

Code: [Select]
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
//NL

PtokaX forum

Getting Double message, becouse of small/big chatacters
« on: 05 November, 2003, 11:26:17 »

Offline NightLitch

  • Emperor
  • **
  • Posts: 1 455
  • Karma: +16/-0
(No subject)
« Reply #1 on: 05 November, 2003, 11:39:57 »
plz anyone.... help....

Skrollster.... Tezlo....

/NightLitch
//NL

Offline OpiumVolage

  • Double Ace
  • *
  • Posts: 101
  • Karma: +1/-0
(No subject)
« Reply #2 on: 05 November, 2003, 11:46:31 »
In you banlog, add only lowercase nicks, there is where your problem is.

Offline NightLitch

  • Emperor
  • **
  • Posts: 1 455
  • Karma: +16/-0
(No subject)
« Reply #3 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....

Code: [Select]
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
« Last Edit: 05 November, 2003, 12:01:15 by NightLitch »
//NL

Offline NightLitch

  • Emperor
  • **
  • Posts: 1 455
  • Karma: +16/-0
(No subject)
« Reply #4 on: 05 November, 2003, 12:03:01 »
but It works as I want it to here:

Code: [Select]
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
//NL

Offline NightLitch

  • Emperor
  • **
  • Posts: 1 455
  • Karma: +16/-0
(No subject)
« Reply #5 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
//NL

Offline NightLitch

  • Emperor
  • **
  • Posts: 1 455
  • Karma: +16/-0
(No subject)
« Reply #6 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
//NL

Offline OpiumVolage

  • Double Ace
  • *
  • Posts: 101
  • Karma: +1/-0
(No subject)
« Reply #7 on: 05 November, 2003, 12:15:37 »
in your ban function, try:

Code: [Select]
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.

Offline NightLitch

  • Emperor
  • **
  • Posts: 1 455
  • Karma: +16/-0
(No subject)
« Reply #8 on: 05 November, 2003, 12:19:11 »
ahh... Thx Opium...
//NL

Offline NightLitch

  • Emperor
  • **
  • Posts: 1 455
  • Karma: +16/-0
(No subject)
« Reply #9 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
//NL

Offline OpiumVolage

  • Double Ace
  • *
  • Posts: 101
  • Karma: +1/-0
(No subject)
« Reply #10 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+(.+)" )

Offline NightLitch

  • Emperor
  • **
  • Posts: 1 455
  • Karma: +16/-0
(No subject)
« Reply #11 on: 05 November, 2003, 12:54:30 »
yes have tried that... BUT!

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

cause with this:

Code: [Select]
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
//NL

Offline OpiumVolage

  • Double Ace
  • *
  • Posts: 101
  • Karma: +1/-0
(No subject)
« Reply #12 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)

Offline NightLitch

  • Emperor
  • **
  • Posts: 1 455
  • Karma: +16/-0
(No subject)
« Reply #13 on: 05 November, 2003, 13:03:45 »
thx for the lessons... this is the way I want to be heard and helped... :-)

gonna test...
//NL

Offline NightLitch

  • Emperor
  • **
  • Posts: 1 455
  • Karma: +16/-0
(No subject)
« Reply #14 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
//NL

Offline OpiumVolage

  • Double Ace
  • *
  • Posts: 101
  • Karma: +1/-0
(No subject)
« Reply #15 on: 05 November, 2003, 13:21:40 »
You are capturing nothing (0 chars) with this regex, but reason isn't nil.

Quote
Like this reason can be "" (empty)

try to change if reason == nil by if reason == ""

Offline NightLitch

  • Emperor
  • **
  • Posts: 1 455
  • Karma: +16/-0
(No subject)
« Reply #16 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...
//NL

Offline tezlo

  • Triple Ace
  • **
  • Posts: 225
  • Karma: +1/-0
(No subject)
« Reply #17 on: 06 November, 2003, 13:38:21 »
the regexp was right in the code i gave you >>

PtokaX forum

(No subject)
« Reply #17 on: 06 November, 2003, 13:38:21 »