Getting Double message, becouse of small/big chatacters
 

Getting Double message, becouse of small/big chatacters

Started by NightLitch, 05 November, 2003, 11:26:17

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

NightLitch

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
//NL

NightLitch

plz anyone.... help....

Skrollster.... Tezlo....

/NightLitch
//NL

OpiumVolage

In you banlog, add only lowercase nicks, there is where your problem is.

NightLitch

#3
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
//NL

NightLitch

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
//NL

NightLitch

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

NightLitch

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

OpiumVolage

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.

NightLitch

ahh... Thx Opium...
//NL

NightLitch

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

OpiumVolage

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+(.+)" )

NightLitch

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
//NL

OpiumVolage

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)

NightLitch

thx for the lessons... this is the way I want to be heard and helped... :-)

gonna test...
//NL

NightLitch

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

OpiumVolage

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 == ""

NightLitch

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

tezlo

the regexp was right in the code i gave you >>

SMF spam blocked by CleanTalk