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.

do not ban ops

Help for those learning Tcl or writing their own scripts.
s
simo
Revered One
Posts: 1090
Joined: Sun Mar 22, 2015 2:41 pm

Re: do not ban ops

Post by simo »

see if this works for you.

Code: Select all





#####################################################
# Opciones:

# Establece los canales en los que quieres comprobar los usuarios
# incluye el "#" y sepáralos con un espacio.  EG set checkchans "#chan1 #chan3 #otherchan"
set checkchans "#mojo-picon"

# Palabras de los canales que serán prohibidos, separadas por un espacio.  Si pones set badchans "badc list" 
# los canales que serán baneados son #badchan #chanbadc #listchan #chanthatlists etc ......
set badchans "#chan #chan1 #chan2 #chan3 #chan3 #chan3"

# Minutos entre cada comprobación completa de un canal.  NOTA - ¡No pongas este valor bajo si tienes mucha gente! 
# Esto es una gran carga para el servidor/bot, así que no seas un idiota y comprueba cada 1 minuto en un canal con 100 personas.  
# El bot se retrasará (o será k-lined)
set intervalcheck 5

# Duración de la prohibición por estar en el canal equivocado (en minutos)
set idiotbantime 720

# La razón que aparece en la lista de baneos.  También se utiliza cuando el bot les manda un mensaje diciendo por cuánto tiempo fueron baneados y por qué.
set banmsg "Actividad no permitida"

#####################################################
# FIN DE LAS OPCIONES
# ¡No edite nada de lo que hay aquí abajo a menos que esté haciendo un cambio de versión!
#####################################################


bind JOIN - * bcjoin
bind RAW - 319 banchan:response
bind RAW - 353 banchan:names

# Triggered on join
 proc bcjoin {nick uhost handle chan} {
      # Check only if user is not halfop or more
      if {[channel get $chan bccheck] && (($handle eq "*") || [matchattr $handle -l|-l $chan])} {
         utimer 2 [list sendwhois $nick $uhost $chan]
      }
}

# Called by the join after 2s
 proc sendwhois {nick uhost chan} {
  global checkchans
  set checkchans [string tolower $checkchans]
  set channel [string tolower $chan]
  set matchpattern "*$channel*"
 if {[string match $matchpattern $checkchans] == 1 && [onchan $nick $chan] && ![isop $nick $channel] && ![ishalfop $nick $channel] && ![isbotnick $nick]} {
         putserv "WHOIS $nick"
      }
   }

 
proc banchan:join {nick uhost handle channel} {
  global checkchans
  set checkchans [string tolower $checkchans]
  set channel [string tolower $channel]
  set matchpattern "*$channel*"
 if {[string match $matchpattern $checkchans] == 1 && ![isop $nick $channel] && ![ishalfop $nick $channel] && ![isvoice $nick $channel] && ![isbotnick $nick] &&     ![matchattr [nick2hand $nick] of|of $channel]} {
    putserv "WHOIS $nick"
    return 0
  } else {
    return 0
  }
}



if {[string match "*banchan:scan*" [timers]] == 0} {
  timer $intervalcheck banchan:scan
}

proc banchan:names {from keyword nicklist} {
  global checkchans
  set nicklist [banchan:charfilter $nicklist]
  set nicklist [lrange $nicklist 3 end]
  set chanfrom ""
  append chanfrom "*" [lindex $nicklist 2] "*"
  set chanfrom [string tolower $chanfrom]
  if {[string match $chanfrom $checkchans]} {
    return 1
  }
  set currnicknum 0
  set currentnick "b4"
  while {$currentnick != ""} {
    set currentnick [lindex $nicklist $currnicknum]
    if {[string range $currentnick 0 0] == "@" || [string range $currentnick 0 0] == "+" || [string range $currentnick 0 0] == ":"} {
      set currentnick [string range $currentnick 1 end]
    }
    if {[string range $currentnick 0 0] == "@" || [string range $currentnick 0 0] == "+" || [string range $currentnick 0 0] == ":"} {
      set currentnick [string range $currentnick 1 end]
    }
    putserv "WHOIS $currentnick"
    incr currnicknum
  }
}

proc banchan:scan { } {
  global checkchans intervalcheck
  set tocheck [string tolower $checkchans]
  set ccnum 0
  set total [llength $tocheck]
  while {$ccnum < $total} {
    putlog "BanChan: Scanning [lindex $tocheck $ccnum]"
    putserv "NAMES [lindex $tocheck $ccnum]"
    incr ccnum
  }
  if {[string match "*banchan:scan*" [timers]] == 0} {
    timer $intervalcheck banchan:scan
  }
}

 
proc banchan:response {from keyword arg} {
  global badchans banmsg idiotbantime checkchans
  set badchans [string tolower $badchans]
  set badchans [concat $badchans]
  set arg [banchan:charfilter $arg]
  set currentchannel "empty"
  set chanlistnum 2
  set nick [lindex $arg 1]
  set matchpattern ""
  while {$currentchannel != ""} {
    set currentchannel [lindex $arg $chanlistnum]
    set currentchannel [string tolower $currentchannel]
    if {$currentchannel == ""} {
      break
    }
    if {$chanlistnum == 2} {
      set currentchannel [string range $currentchannel 1 end]
    }
    if {[string range $currentchannel 0 0] == "@" || [string range $currentchannel 0 0] == "+"} {
      set currentchannel [string range $currentchannel 1 end]
    }
    set currentbannum 0
    while {[llength $badchans] > $currentbannum} {
      set matchpattern "*[lindex $badchans $currentbannum]*"
      if {[string match $matchpattern $currentchannel]} {
      if {[isop $nick $currentchannel] || [ishalfop $nick $currentchannel] || [isvoice $nick $currentchannel] || [isbotnick $nick] || [matchattr [nick2hand $nick] of|of $currentchannel]} { return 0 }
        set uhost [getchanhost $nick]
        if {$uhost == ""} {
           return 0
        }
        set tempi [expr [string first @ $uhost] + 1]
        set uhost "*!*@[string range $uhost $tempi end]"
        set chantomsglist [string tolower $checkchans]
        set chantomsgnum 0
        while {$chantomsgnum < [llength $chantomsglist]} {
          set currentchantomsg [lindex $chantomsglist $chantomsgnum]
          if {[onchan $nick $currentchantomsg] == 1} {
            putserv "PRIVMSG $currentchantomsg"
          }
          incr chantomsgnum
        }
        utimer 5 [banchan:delayedban $uhost]
        putserv "PRIVMSG $nick :no eres bien recibid@ ($currentchannel)."
        return 0
      }
      incr currentbannum
    }
    incr chanlistnum
  }
  return 0
}

proc banchan:delayedban { banhost } {
  global banmsg idiotbantime
  newban $banhost "BanChan3.2" "$banmsg" $idiotbantime
}

proc banchan:charfilter {x {y ""}} { 
 for {set i 0} {$i < [string length $x]} {incr i} { 
  switch -- [string index $x $i] { 
  "\"" {append y "\\\""}
  "\\" {append y "\\\\"}
  "\[" {append y "\\\["}
  "\]" {append y "\\\]"}
  "\{" {append y "\\\{"}
  "\}" {append y "\\\}"}
  default {append y [string index $x $i]} 
  } 
 } 
 return $y 
}

putlog "Anticanales Cargado Correctamente"



User avatar
flink
Halfop
Posts: 80
Joined: Sun Feb 21, 2021 9:27 am
Location: Canarias

Re: do not ban ops

Post by flink »

Hi CrazyCat it wasn't that either, it was just to make things easier, but well, your decision is very respectable. thanks for the help.
Mi ingles: no es el mejor, Manda el traductor... :)
User avatar
flink
Halfop
Posts: 80
Joined: Sun Feb 21, 2021 9:27 am
Location: Canarias

Re: do not ban ops

Post by flink »

simo wrote: Wed May 22, 2024 6:22 pm see if this works for you.

Code: Select all





#####################################################
# Opciones:

# Establece los canales en los que quieres comprobar los usuarios
# incluye el "#" y sepáralos con un espacio.  EG set checkchans "#chan1 #chan3 #otherchan"
set checkchans "#mojo-picon"

# Palabras de los canales que serán prohibidos, separadas por un espacio.  Si pones set badchans "badc list" 
# los canales que serán baneados son #badchan #chanbadc #listchan #chanthatlists etc ......
set badchans "#chan #chan1 #chan2 #chan3 #chan3 #chan3"

# Minutos entre cada comprobación completa de un canal.  NOTA - ¡No pongas este valor bajo si tienes mucha gente! 
# Esto es una gran carga para el servidor/bot, así que no seas un idiota y comprueba cada 1 minuto en un canal con 100 personas.  
# El bot se retrasará (o será k-lined)
set intervalcheck 5

# Duración de la prohibición por estar en el canal equivocado (en minutos)
set idiotbantime 720

# La razón que aparece en la lista de baneos.  También se utiliza cuando el bot les manda un mensaje diciendo por cuánto tiempo fueron baneados y por qué.
set banmsg "Actividad no permitida"

#####################################################
# FIN DE LAS OPCIONES
# ¡No edite nada de lo que hay aquí abajo a menos que esté haciendo un cambio de versión!
#####################################################


bind JOIN - * bcjoin
bind RAW - 319 banchan:response
bind RAW - 353 banchan:names

# Triggered on join
 proc bcjoin {nick uhost handle chan} {
      # Check only if user is not halfop or more
      if {[channel get $chan bccheck] && (($handle eq "*") || [matchattr $handle -l|-l $chan])} {
         utimer 2 [list sendwhois $nick $uhost $chan]
      }
}

# Called by the join after 2s
 proc sendwhois {nick uhost chan} {
  global checkchans
  set checkchans [string tolower $checkchans]
  set channel [string tolower $chan]
  set matchpattern "*$channel*"
 if {[string match $matchpattern $checkchans] == 1 && [onchan $nick $chan] && ![isop $nick $channel] && ![ishalfop $nick $channel] && ![isbotnick $nick]} {
         putserv "WHOIS $nick"
      }
   }

 
proc banchan:join {nick uhost handle channel} {
  global checkchans
  set checkchans [string tolower $checkchans]
  set channel [string tolower $channel]
  set matchpattern "*$channel*"
 if {[string match $matchpattern $checkchans] == 1 && ![isop $nick $channel] && ![ishalfop $nick $channel] && ![isvoice $nick $channel] && ![isbotnick $nick] &&     ![matchattr [nick2hand $nick] of|of $channel]} {
    putserv "WHOIS $nick"
    return 0
  } else {
    return 0
  }
}



if {[string match "*banchan:scan*" [timers]] == 0} {
  timer $intervalcheck banchan:scan
}

proc banchan:names {from keyword nicklist} {
  global checkchans
  set nicklist [banchan:charfilter $nicklist]
  set nicklist [lrange $nicklist 3 end]
  set chanfrom ""
  append chanfrom "*" [lindex $nicklist 2] "*"
  set chanfrom [string tolower $chanfrom]
  if {[string match $chanfrom $checkchans]} {
    return 1
  }
  set currnicknum 0
  set currentnick "b4"
  while {$currentnick != ""} {
    set currentnick [lindex $nicklist $currnicknum]
    if {[string range $currentnick 0 0] == "@" || [string range $currentnick 0 0] == "+" || [string range $currentnick 0 0] == ":"} {
      set currentnick [string range $currentnick 1 end]
    }
    if {[string range $currentnick 0 0] == "@" || [string range $currentnick 0 0] == "+" || [string range $currentnick 0 0] == ":"} {
      set currentnick [string range $currentnick 1 end]
    }
    putserv "WHOIS $currentnick"
    incr currnicknum
  }
}

proc banchan:scan { } {
  global checkchans intervalcheck
  set tocheck [string tolower $checkchans]
  set ccnum 0
  set total [llength $tocheck]
  while {$ccnum < $total} {
    putlog "BanChan: Scanning [lindex $tocheck $ccnum]"
    putserv "NAMES [lindex $tocheck $ccnum]"
    incr ccnum
  }
  if {[string match "*banchan:scan*" [timers]] == 0} {
    timer $intervalcheck banchan:scan
  }
}

 
proc banchan:response {from keyword arg} {
  global badchans banmsg idiotbantime checkchans
  set badchans [string tolower $badchans]
  set badchans [concat $badchans]
  set arg [banchan:charfilter $arg]
  set currentchannel "empty"
  set chanlistnum 2
  set nick [lindex $arg 1]
  set matchpattern ""
  while {$currentchannel != ""} {
    set currentchannel [lindex $arg $chanlistnum]
    set currentchannel [string tolower $currentchannel]
    if {$currentchannel == ""} {
      break
    }
    if {$chanlistnum == 2} {
      set currentchannel [string range $currentchannel 1 end]
    }
    if {[string range $currentchannel 0 0] == "@" || [string range $currentchannel 0 0] == "+"} {
      set currentchannel [string range $currentchannel 1 end]
    }
    set currentbannum 0
    while {[llength $badchans] > $currentbannum} {
      set matchpattern "*[lindex $badchans $currentbannum]*"
      if {[string match $matchpattern $currentchannel]} {
      if {[isop $nick $currentchannel] || [ishalfop $nick $currentchannel] || [isvoice $nick $currentchannel] || [isbotnick $nick] || [matchattr [nick2hand $nick] of|of $currentchannel]} { return 0 }
        set uhost [getchanhost $nick]
        if {$uhost == ""} {
           return 0
        }
        set tempi [expr [string first @ $uhost] + 1]
        set uhost "*!*@[string range $uhost $tempi end]"
        set chantomsglist [string tolower $checkchans]
        set chantomsgnum 0
        while {$chantomsgnum < [llength $chantomsglist]} {
          set currentchantomsg [lindex $chantomsglist $chantomsgnum]
          if {[onchan $nick $currentchantomsg] == 1} {
            putserv "PRIVMSG $currentchantomsg"
          }
          incr chantomsgnum
        }
        utimer 5 [banchan:delayedban $uhost]
        putserv "PRIVMSG $nick :no eres bien recibid@ ($currentchannel)."
        return 0
      }
      incr currentbannum
    }
    incr chanlistnum
  }
  return 0
}

proc banchan:delayedban { banhost } {
  global banmsg idiotbantime
  newban $banhost "BanChan3.2" "$banmsg" $idiotbantime
}

proc banchan:charfilter {x {y ""}} { 
 for {set i 0} {$i < [string length $x]} {incr i} { 
  switch -- [string index $x $i] { 
  "\"" {append y "\\\""}
  "\\" {append y "\\\\"}
  "\[" {append y "\\\["}
  "\]" {append y "\\\]"}
  "\{" {append y "\\\{"}
  "\}" {append y "\\\}"}
  default {append y [string index $x $i]} 
  } 
 } 
 return $y 
}

putlog "Anticanales Cargado Correctamente"



             
hello simo thank you for visiting one of my rooms.
after trying what you recommend, it doesn't ban or send a message. it gives me this partyline error:

Rebujado ¦ BanChan: Scanning #mojo-picon
              Rebujado ¦ Tcl error [banchan:response]: illegal channel: #sexo
Rebujado : Tcl error [bcjoin]: Unknown channel setting.

Mi ingles: no es el mejor, Manda el traductor... :)
User avatar
flink
Halfop
Posts: 80
Joined: Sun Feb 21, 2021 9:27 am
Location: Canarias

Re: do not ban ops

Post by flink »

santo SpiKe^^ cuanta sabiduría ,
ese Sr. ayudaba de verdad. que este descansando en paz
doy por terminada la solicitud de ayuda, gracias a los participantes
Mi ingles: no es el mejor, Manda el traductor... :)
Post Reply