Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

string match syntax

Status
Not open for further replies.
Nov 27, 2010
2
BR
Hello,

I have an eggdrop TCL that I use to find users Ip addresses on the network.

If I type !ip 0.0.0.0, for example, it returns the user online in that ip address.

The problem is that if I type !ip 0.*, it searches everyone in that class and shows. I don't want that.

I was thinking in a string mach, to make it return no answer when * is included on the parameter, but having some problems.

If someone could help me, I'd be very grateful. I tried to find examples, but didn't understand them.

Here is the code:

---------------------------------------------

#Flag permitida para usar o comando via pvt
set nivel ""

#Canal onde o bot vai atuar
set bchan "#Age_of_empires_2"

set coringa "*"

bind msg $nivel !ip bwhois:view

proc bwhois:view {nick uhost hand args} {

global rnick ip bwhoisinfo notfound

set rnick $nick
set ip $args

foreach item [array names bwhoisinfo] {
unset bwhoisinfo($item)
}

puthelp "WHOIS *@$args"
set notfound "1"

}

bind raw - "311" raw:bwhois:process
bind raw - "319" raw:bwhois:process
bind raw - "401" raw:bwhois:process
bind raw - "318" raw:bwhois:process

proc raw:bwhois:process {from keyword args} {

global rnick bchan ip bwhoisinfo bnick notfound

if {$keyword == 311} {
set bnick [lrange [lindex $args 0] 1 1]
}

switch $keyword {
311 {
set bwhoisinfo($bnick,nick) $bnick
set bwhoisinfo($bnick,banmask) "*!*@[lrange [lindex $args 0] 3 3]"
}
401 {
set notfound "*** Não foi encontrado nenhum usuário no IP: \002$ip\002"
}
318 {
if {$notfound == 1} {
set count "0"
foreach item [array names bwhoisinfo "*,nick"] {
if {[onchan $bwhoisinfo($item) $bchan]} {
incr count
}
}
if {$count >= 0} {
if {string match $coringa $string == 0} {
if {[array exists bwhoisinfo]} {
foreach item [array names bwhoisinfo "*,nick"] {
set bnick $bwhoisinfo($item)
putserv "PRIVMSG $rnick :*** IP: $ip Nick: $bwhoisinfo($item) "
}
}
}
} else {
}
} else {
}

}
}

}

putlog "Cmd Anti-Smurf - Loaded"

------------------------------------------

But I get the following error:

[11:12] Tcl error [raw:bwhois:process]: invalid bareword "string" in expression "string match $coringa $strin..."; should be "$string" or "{string}" or "string(...)" or ...

Thank you.
 
Hello Bernardo,

Should it not be:
if {[string match $coringa $string] == 0} {

instead of
if {string match $coringa $string == 0} {

thacoda.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top