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.

Make this channel specific?

Help for those learning Tcl or writing their own scripts.
Post Reply
D
DJmart
Voice
Posts: 21
Joined: Wed Mar 08, 2006 8:32 pm

Make this channel specific?

Post by DJmart »

Code: Select all

set badnicks [list "*[censored]*" "*dyn_*" "*dyn_user*"]

bind join - * ban:bnick
bind nick - * ban:bnick

proc ban:bnick {nick uhost hand chan {nn ""}} {
global badnicks
set bbanmask "*!*@[lindex [split $uhost @] 1]"
if {$nn == ""} { set nn $nick }
if {![isbotnick $nick]} {
  foreach badnick $badnicks {
   if {[string match -nocase  $badnick $nn]} {
    putserv "MODE $chan +b $bbanmask"
    putserv "KICK $chan $nick :Please Identify, before you enter this channel, and or make sure you auto-ident when you disconnect This ban will expire in 15 Minutes ."
    break
   }
  }
 }
}
Thats the code, yet, I want this to be for user defined channels such as

Channels: "#lamer" "#Smile"

Thanks!
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

such a feature has been posted like 30 times.

Edit: http://forum.egghelp.org/search.php
Last edited by De Kus on Sun Apr 02, 2006 8:40 am, edited 1 time in total.
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
D
DJmart
Voice
Posts: 21
Joined: Wed Mar 08, 2006 8:32 pm

Post by DJmart »

could you post it?

I am an uber noob with TCL
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

You can create a list of channels

Code: Select all

set bnchans {#chan1 #chan2}
and use

Code: Select all

if {[lsearch -exact $bnchans $chan] == -1} {return 0}
inside your proc(s). Here ofcourse, bnchans should be globalized inside the proc and you would want to make the channels lower-case since [lsearch] is case-sensitive.
D
DJmart
Voice
Posts: 21
Joined: Wed Mar 08, 2006 8:32 pm

Post by DJmart »

Code: Select all

set badnicks [list "*[censored]*" "*dyn_*" "*dyn_user*"]
set bnchans {#aite}

bind join - * ban:bnick
bind nick - * ban:bnick

proc ban:bnick {nick uhost hand chan {nn ""}} {
if {[lsearch -exact $bnchans $chan] == -1} {return 0}
global badnicks
set bbanmask "*!*@[lindex [split $uhost @] 1]"
if {$nn == ""} { set nn $nick }
if {![isbotnick $nick]} {
  foreach badnick $badnicks {
   if {[string match -nocase  $badnick $nn]} {
    putserv "MODE $chan +b $bbanmask"
    putserv "KICK $chan $nick :Please Identify, before you enter this channel, and or make sure you auto-ident when you disconnect This ban will expire in 15 Minutes ."
    break
   }
  }
 }
}
I get an error, is there something I did wrong?

Code: Select all

[08:12] Tcl error [ban:bnick]: can't read "bnchans": no such variable
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

Sir_Fz wrote: you would want to make the channels lower-case since [lsearch] is case-sensitive.
I'd recommned using the same capitalition as the bot knows them (like shown in .status).

DJmart wrote:I get an error, is there something I did wrong?

Code: Select all

[08:12] Tcl error [ban:bnick]: can't read "bnchans": no such variable
Read this again:
Sir_Fz wrote:bnchans should be globalized inside the proc
that means you either add it to the global line or add :: behind the $ for each call to that var within a proc.
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
Post Reply