This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.
For more information, see this announcement post . Click the X in the top right-corner of this box to dismiss this message.
Help for those learning Tcl or writing their own scripts.
simo
Revered One
Posts: 1107 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Sat Apr 30, 2022 1:04 pm
greetingz gentz,
i was trying out this small code wich checks wich nicks will be effected with banmasks on channel currently it outputs :
nick1 nick2 nick3 nick3 nick4
if possible i wanted it to output in the manner of like :
(4) Nicks are effected: (1) nick1 (2) nick2 (3) nick3 (4) nick4
Code: Select all
bind pub n !ipcheck Pub:BanMask-Tester
proc Pub:BanMask-Tester {nick host hand chan text} {
set text [regsub -all -- {\s{2,}} [string trim [stripcodes * $text]] { }]
set target [lindex [split $text] 0]
if { [string first ":" $target] != -1 } { set target [lindex [split $target ":"] 1] }
set users [list]
foreach n [chanlist $chan] {
if {[string match -nocase $target $n![getchanhost $n $chan]]} {
lappend users $n
}
}
if {[llength $users]} { putserv "notice $nick :$users" }
}
thanks gentz,
SpiKe^^
Owner
Posts: 831 Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:
Post
by SpiKe^^ » Sat Apr 30, 2022 9:37 pm
???
Code: Select all
#### Pub: BanMask-Tester v0.2 ####
bind pub n !ipcheck Pub:BanMask-Tester
proc Pub:BanMask-Tester {nick host hand chan text} {
set text [regsub -all -- {\s{2,}} [string trim [stripcodes * $text]] { }]
set target [lindex [split $text] 0]
if {[string first ":" $target] > -1} { set target [lindex [split $target ":"] 1] }
set users [list]
foreach n [chanlist $chan] {
if {[matchaddr $target $n![getchanhost $n $chan]]} { lappend users $n }
}
if {[llength $users]} { set cnt 0 ; set say ""
foreach n $users { append say " ([incr cnt]) $n" }
if {$cnt == 1} { set plural "Nick is" } else { set plural "Nicks are" }
putserv "notice $nick :($cnt) $plural affected:$say"
} else { putserv "notice $nick :No nicks are affected." }
return 0
}
simo
Revered One
Posts: 1107 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Sun May 01, 2022 12:16 am
thanks for the swift reply SpiKe^^
i tested it and it seems to do exactly as expected excellent thanks for that
1 last request if i may , if it would be possible to have the output in alphabetical order as it seems to output in random order atm
thanks in advance,
simo
Revered One
Posts: 1107 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Sun May 01, 2022 12:20 am
i did an attempt it seems to work but im not sure if its the proper way to do it
Code: Select all
bind pub n !ipcheck Pub:BanMask-Tester
proc Pub:BanMask-Tester {nick host hand chan text} {
set text [regsub -all -- {\s{2,}} [string trim [stripcodes * $text]] { }]
set target [lindex [split $text] 0]
if {[string first ":" $target] > -1} { set target [lindex [split $target ":"] 1] }
set users [list]
foreach n [chanlist $chan] {
if {[matchaddr $target $n![getchanhost $n $chan]]} { lappend users $n ; set users [lsort -dictionary $users] }
}
if {[llength $users]} { set cnt 0 ; set say ""
foreach n $users { append say " ([incr cnt]) $n" }
if {$cnt == 1} { set plural "Nick is" } else { set plural "Nicks are" }
putserv "notice $nick :($cnt) $plural affected:$say"
} else { putserv "notice $nick :No nicks are affected." }
return 0
}
SpiKe^^
Owner
Posts: 831 Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:
Post
by SpiKe^^ » Sun May 01, 2022 1:44 am
Well, I don't think I would put the sort in the foreach loop. Try this one...
Code: Select all
#### Pub: BanMask-Tester v0.3 ####
bind pub n !ipcheck Pub:BanMask-Tester
proc Pub:BanMask-Tester {nick host hand chan text} {
set text [regsub -all -- {\s{2,}} [string trim [stripcodes * $text]] { }]
set target [lindex [split $text] 0]
if {[string first ":" $target] > -1} { set target [lindex [split $target ":"] 1] }
set users [list]
foreach n [chanlist $chan] {
if {[matchaddr $target $n![getchanhost $n $chan]]} { lappend users $n }
}
if {[llength $users]} { set cnt 0 ; set say ""
foreach n [lsort -dictionary $users] { append say " ([incr cnt]) $n" }
if {$cnt == 1} { set plural "Nick is" } else { set plural "Nicks are" }
putserv "notice $nick :($cnt) $plural affected:$say"
} else { putserv "notice $nick :No nicks are affected." }
return 0
}
simo
Revered One
Posts: 1107 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Sun May 01, 2022 1:10 pm
Thanks SpiKe^^ for correcting it ive tested it and it seems to work as expected thanks for that much apreciated