egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

change output of banmask checker

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
simo
Owner


Joined: 22 Mar 2015
Posts: 902

PostPosted: Sat Apr 30, 2022 1:04 pm    Post subject: change output of banmask checker Reply with quote

greetingz gentz,

i was trying out this small code wich checks wich nicks will be effected with banmasks on channel currently it outputs :

Quote:
nick1 nick2 nick3 nick3 nick4


if possible i wanted it to output in the manner of like :

Quote:
(4) Nicks are effected: (1) nick1 (2) nick2 (3) nick3 (4) nick4



Code:


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,
Back to top
View user's profile Send private message
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 785
Location: Tennessee, USA

PostPosted: Sat Apr 30, 2022 9:37 pm    Post subject: Pub: BanMask-Tester Reply with quote

???

Code:

####  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
}


_________________
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
Back to top
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 902

PostPosted: Sun May 01, 2022 12:16 am    Post subject: Reply with quote

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,
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 902

PostPosted: Sun May 01, 2022 12:20 am    Post subject: Reply with quote

i did an attempt it seems to work but im not sure if its the proper way to do it

Code:

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
}
Back to top
View user's profile Send private message
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 785
Location: Tennessee, USA

PostPosted: Sun May 01, 2022 1:44 am    Post subject: Pub: BanMask-Tester v0.3 Reply with quote

Well, I don't think I would put the sort in the foreach loop. Try this one...

Code:

####  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
}


_________________
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
Back to top
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 902

PostPosted: Sun May 01, 2022 1:10 pm    Post subject: Reply with quote

Thanks SpiKe^^ for correcting it ive tested it and it seems to work as expected thanks for that much apreciated
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber