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.

blacklisted channel with cron

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
s
simo
Revered One
Posts: 1072
Joined: Sun Mar 22, 2015 2:41 pm

blacklisted channel with cron

Post by simo »

we have been using this tcl for a while and noticed the lappend part ( in proc Xbc_whoisX ) doesnt actually stack the nicks that are found on a blacklisted channel as intented then i took a closer look and it seems the bind raw 319 goes thru the nicks one by one so i was wondering if there would be a way to stack the nicks to send away to the kick poc
BadchanStackKicks

here is the code we work with hopefully someone knows a way to achieve what we desired with it:

Code: Select all

namespace eval whois {


  bind cron - {*/5 * * * *} [namespace current]::whois:cron

  setudef flag stackedwhois


  proc whois:cron {min hour day month weekday} {
    foreach channel [channels] {
      if {![channel get $channel stackedwhois]} continue
      if {![botisop $channel]} continue
      foreach member [chanlist $channel] {
        if {[isbotnick $member]} continue
        if {[isop $member $channel] || [ishalfop $member $channel] || [matchattr [nick2hand $member] fon|fon $channel]} continue
        lappend userList $member
      }
      if {[info exists userList]} { Stack:WHois $channel $userList }
    }
  }


  proc Stack:WHois {chan userList {max 20}} {
    set ::chanxer $chan
    set userList [lsort -unique $userList]
    set count [llength $userList]
    set counter 0
    while {$count > 0} {
      if {$count > $max} {
        set users [join [lrange $userList 0 [expr {$max - 1}]] ","]
        set userList [lreplace $userList 0 [expr {$max -1}]]
        incr count -$max
      } else {
        set users [join $userList ","]
        set count 0
      }
      incr counter 1
      after [expr {$counter*5000}] [list  putserv "Whois :$users"] 
    }
  }

  bind raw - 319 [namespace current]::Xbc_whoisX

  proc whoisXUnbind {from key arg} {
    unbind raw - 319 [namespace current]::Xbc_whoisX
  }


  proc Xbc_whoisX {from key arg} {
    set BadChanList [list]
    set arg [split $arg]
    set nick [lindex $arg 1]
    set chost [getchanhost $nick $::chanxer]
    regsub -all -- ~ $chost "" chost
    set listchans [lrange $arg 2 end]
    regexp -- {^:?(.*)$} [join $listchans] -> text
    set text [split $text]
    set text [regsub -all -- {\s{2,}} [string trim [stripcodes * $text]] { }]
    if {[regexp -nocase {gay|[sf]uck|cam|incest|sex|cum|teenwankin|jackinchat|bdsm|wtf|kcuf|TestChan} $text]} { 
      lappend BadChanList $nick

      if {[string match -nocase "*@*irccloud*" $chost]} { 
        set ident  [lindex [split $chost @] 0]
        set xbmaskx [string map {sid id uid id} $ident]
        set bmask  *!*[string tolower $xbmaskx ]@*
        if {![ischanban $bmask $::chanxer]} { pushmode $::chanxer +b $bmask }
      } elseif {![string match -nocase "*@*irccloud*" $chost] && ![ischanban [maskhost $nick!$chost 2] $::chanxer]} {
        set bmask [maskhost $nick!$chost 2]
        if {![ischanban $bmask $::chanxer]} { pushmode $::chanxer +b $bmask }
      }
    }
    if {[info exists BadChanList]} {[namespace current]::BadchanStackKicks $::chanxer $BadChanList }
  }

  proc BadchanStackKicks {chan kicklist {max 4}} {
    set count [llength $kicklist]
    set counter 0
    while {$count > 0} {
      if {$count > $max} {
        set users [join [lrange $kicklist 0 [expr {$max - 1}]] ","]
        set kicklist [lrange $kicklist $max end]
        incr count -$max
      } else {
        set users [join $kicklist ","]
        set count 0
      }
      incr counter 1
      after [expr {$counter*5000}] [list  putnow "KICK $chan $users :BlackListed CHANNEL DETECTED"] 
       
    }
  }
}


Much appreciated.
Post Reply