BernardoCR
MIS
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:bwhoisrocess
bind raw - "319" raw:bwhoisrocess
bind raw - "401" raw:bwhoisrocess
bind raw - "318" raw:bwhoisrocess
proc raw:bwhoisrocess {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:bwhoisrocess]: invalid bareword "string" in expression "string match $coringa $strin..."; should be "$string" or "{string}" or "string(...)" or ...
Thank you.
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:bwhoisrocess
bind raw - "319" raw:bwhoisrocess
bind raw - "401" raw:bwhoisrocess
bind raw - "318" raw:bwhoisrocess
proc raw:bwhoisrocess {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:bwhoisrocess]: invalid bareword "string" in expression "string match $coringa $strin..."; should be "$string" or "{string}" or "string(...)" or ...
Thank you.