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.

Autokick if hostmask not defined in file

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
User avatar
Havok
Voice
Posts: 6
Joined: Sat Dec 08, 2012 2:14 pm
Contact:

Autokick if hostmask not defined in file

Post by Havok »

So, I've been looking for an autokick that kicks nonvoice, nonhops, nonops and so on(normal users) when they try to join the channel, but I haven't found anything :/ So I decided to go here and request something :P
Let's say that I have a staff channel, and ofc, I don't want former staff to be in it, and I don't want to set +i on it. This sort of script would be a great thing to use for that.


An example config of this/something like this:

(I'm looking for one that supports one channel only, feel free to make one that supports more :) )
set channel "#channel"

(the message that will be used when kicking)
set reasonmessage "You don't have the access to be on this channel"

If someone would like to do this, that would be great :D (this is the only thing I need before I start my eggdrop bot :3)
d
doggo
Halfop
Posts: 97
Joined: Tue Jan 05, 2010 7:53 am
Contact:

Post by doggo »

put this together.. not tested but you can do that :D

Code: Select all

# http://forum.egghelp.org/viewtopic.php?t=19197 

set autokick_channels "#chan1 #chan2" 
set autokick_exempts "/home/spunky/bot/text/exempt_hosts_kick_out.txt" 
set autokick_kickmsg "You don't have the access to be on this channel!" 

bind join -|- "*" autokick:protect 
bind pub o|o !addhost autokick:add 

proc autokick:protect { nick uhost hand chan } { 

   global autokick_exempts autokick_kickmsg autokick_channels 
    
   set uhost [string tolower $uhost] 
             
        foreach autokick_channel $autokick_channels { 
         if {$autokick_channel == $chan} { 
         set file [open $autokick_exempts "r"] 
         set text [split [read $file] \n] 
         close $file 
         set found [lsearch -glob $text "$uhost"] 
         if {$found < 0} { 
          
         putserv "KICK $autokick_channel $nick :$autokick_kickmsg"    
          
         } 
      } 
   }          
} 

proc autokick:add { nick uhost hand chan target } { 
   global autokick_exempts autokick_kickmsg autokick_channels 
        
   set uhost_add [lindex [split $target] 0] 
   set uhost_add [string tolower $uhost_add] 

        foreach autokick_channel $autokick_channels { 
         if {$autokick_channel == $chan} { 

         if {$uhost_add == ""} { putserv "privmsg $autokick_channel : \002Usage:\017 !addhost ident@host.name";return }

         set file [open $autokick_exempts "r"] 
         set text [split [read $file] \n] 
         close $file 
         set found [lsearch -glob $text "$uhost_add"] 
         if {$found < 0} { 
          
         set file [open $autokick_exempts "a"] 
         puts $file $uhost_add 
         close $file    
          
         putserv "privmsg $autokick_channel :$uhost_add has been added to the exempt list.. " 

         } else { 
          
         putserv "privmsg $autokick_channel :$uhost_add was already on the exempt list.. " 
          
         } 
      } 
   }          
} 


putlog "autokick:protect.tcl loaded"
whois them and use

!addhost ~foo@bar

let me know how it goes..
User avatar
Havok
Voice
Posts: 6
Joined: Sat Dec 08, 2012 2:14 pm
Contact:

Post by Havok »

It works :D
But the thing is, some of the staff have so their router resets the IP every week, so I have to do that every week. Would be better if it kicked people who wasn't op.
But if you count that out, Thanks mate, it works great :3
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

Exactly how are they getting ops in the staff channel??
If you are using the bots userfile, maybe the script could just be tied to them having +o in the user file?
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
User avatar
Havok
Voice
Posts: 6
Joined: Sat Dec 08, 2012 2:14 pm
Contact:

Post by Havok »

They get OP via chanserv when they identify with nickserv.
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

Then, seems to me, that any kick based on if they have ops in the channel, would need to have a fairly large timer delay from their channel join, to allow chanserv the time to get them opped.

What's going to happen when chanserv is missing??
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
User avatar
Havok
Voice
Posts: 6
Joined: Sat Dec 08, 2012 2:14 pm
Contact:

Post by Havok »

What do you mean by "When chanserv is missing"?
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

You must be on a very small and stable network if you have never seen chanserv missing from the channel:)

On any large network, such as undernet, efnet, dalnet, net splits and other network problems make chanserv unavailable at times.

Also, any eggdrop script that kicks and does not also set a ban, is just begging to get your bot flooded off irc when the user has 'rejoin on kick' enabled.
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
User avatar
Havok
Voice
Posts: 6
Joined: Sat Dec 08, 2012 2:14 pm
Contact:

Post by Havok »

I have experienced a few netsplits, but never that chanserv went missing.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Question: why do you have that "open file, read all lines then close the file" routine in a loop and not outside the loop? The $text variable is still the same, it's different only if it just got changed while the program was looping, and chances for that to happen are slim.
Once the game is over, the king and the pawn go back in the same box.
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

I noticed the code posted above had a few minor issues, but the whole file concept wasn't really working for Havok. Thought maybe the script needed to be attacked by a different route, but am currently working on another post. If this post is still open in a day or 2, I may give it a shot:)

If anyone else wants to give it a shot, I'll stay out of it.
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
User avatar
Get_A_Fix
Master
Posts: 206
Joined: Sat May 07, 2005 6:11 pm
Location: New Zealand

Post by Get_A_Fix »

I have a similar script to this, which I released some time ago.
It basically does exactly what you want, but can also be easily modified if you need.

Code: Select all

# Restricted TCL - istok@IRCSpeed.org
# $Id: restricted.tcl,v1 14/08/2010 02:37:42am GMT +12 (NZST) istok Exp $

# RECOMMENDED
# Please add services to your bot, if you haven't already. (via dcc)
# SYNTAX: .+user serv *!*@services.network.etc
# SYNTAX: .chattr serv +f
# and possibly add a few extra masks...
# SYNTAX: .+host serv nickserv!*@*
# SYNTAX: .+host serv chanserv!*@*

# COMMANDS
# --------
# !restricted on|off <- public command
# /msg botnick restricted #channel on|off <- private command

# Set Global trigger here.
set trig "!"

# Set Global Exempt flags here (default +of (Global Operator, Friend, and above))
set gflags of

# Set Channel Exempt flags here (default +ovfb (Channel Operator, Voice, Friend, Bot, and above))
set cflags ovfb

# Set the banmask to use in banning the IPs  
# Default banmask is set to 1
# 1 - *!*@some.domain.com
# 2 - *!*@*.domain.com
# 3 - *!*ident@some.domain.com
# 4 - *!*ident@*.domain.com
# 5 - *!*ident*@some.domain.com
# 6 - *nick*!*@*.domain.com
# 7 - *nick*!*@some.domain.com
# 8 - nick!ident@some.domain.com
# 9 - nick!ident@*.host.com
# 10 - *!*ident*@*
set bantype 1

# ---------- No need to edit anything else *YAY* ----------
bind pub - ${trig}restricted restrict:pub
bind msg - restricted restrict:msg
bind join - * restrict:join

proc makeTrig {} {
  global trig
  return $trig
}

setudef flag restricted

proc restrict:pub {nick uhost hand chan arg} {
  if {[matchattr [nick2hand $nick] o|n $chan]} {
    if {[lindex [split $arg] 0] == ""} {putquick "PRIVMSG $chan :ERROR: Incorrect Parameters. SYNTAX: [makeTrig]restricted on/off"; return}

    if {[lindex [split $arg] 0] == "on"} {
      if {[channel get $chan restricted]} {putquick "PRIVMSG $chan :ERROR: This setting is already enabled."; return}
      channel set $chan +restricted
      puthelp "PRIVMSG $chan :Enabled Restriction of Users for $chan"
      restrict:chan $chan
    }

    if {[lindex [split $arg] 0] == "off"} {
      if {![channel get $chan restricted]} {putquick "PRIVMSG $chan :ERROR: This setting is already disabled."; return}
      channel set $chan -restricted
      puthelp "PRIVMSG $chan :Disabled Restriction of Users for $chan"
    }
  }
}

proc restrict:msg {nick uhost hand arg} {
  global botnick
  set chan [strlwr [lindex $arg 0]]
  if {[matchattr [nick2hand $nick] o|n $chan]} {
    if {[lindex [split $arg] 0] == ""} {putquick "NOTICE $nick :\037ERROR\037: Incorrect Parameters. \037SYNTAX\037: /msg $botnick restricted #channel on/off"; return}
    if {[lindex [split $arg] 1] == ""} {putquick "NOTICE $nick :\037ERROR\037: Incorrect Parameters. \037SYNTAX\037: /msg $botnick restricted $chan on/off"; return}

    if {[lindex [split $arg] 1] == "on"} {
      if {[channel get $chan restricted]} {putquick "NOTICE $nick :\037ERROR\037: This setting is already enabled."; return}
      channel set $chan +restricted
      putquick "NOTICE $nick :Enabled Restriction of Users for $chan"
      restrict:chan $chan
    }

    if {[lindex [split $arg] 1] == "off"} {
      if {![channel get $chan restricted]} {putquick "NOTICE $nick :\037ERROR\037: This setting is already disabled."; return}
      channel set $chan -restricted
      putquick "NOTICE $nick :Disabled Restriction of Users for $chan"
    }
  }
}

proc restrict:chan {chan} {
  global gflags cflags
  foreach nick [chanlist $chan] {
    if {![isbotnick $nick] && ![matchattr [nick2hand $nick] $gflags|$cflags $chan] && [channel get $chan restricted] && [onchan $nick $chan]} {
      set uhost [getchanhost $nick $chan]
      set banmask [restrict:mask $uhost $nick]
      pushmode $chan +b $banmask
      putquick "KICK $chan $nick :This Channel has been set \002Restricted\002 - You are now Unwelcome."
    }
  }
  flushmode $chan
}

proc restrict:join {nick uhost hand chan} {
  global gflags cflags
  if {![isbotnick $nick] && ![matchattr [nick2hand $nick] $gflags|$cflags $chan] && [channel get $chan restricted] && [onchan $nick $chan]} {
    set banmask [restrict:mask $uhost $nick]
    putquick "MODE $chan +b $banmask"
    putquick "KICK $chan $nick :This is a \002Restricted\002 Channel."
  }
}

proc restrict:mask {uhost nick} {
  global bantype
  switch -- $bantype {
    1 { set mask "*!*@[lindex [split $uhost @] 1]" }
    2 { set mask "*!*@[lindex [split [maskhost $uhost] "@"] 1]" }
    3 { set mask "*!*$uhost" }
    4 { set mask "*!*[lindex [split [maskhost $uhost] "!"] 1]" }
    5 { set mask "*!*[lindex [split $uhost "@"] 0]*@[lindex [split $uhost "@"] 1]" }
    6 { set mask "*$nick*!*@[lindex [split [maskhost $uhost] "@"] 1]" }
    7 { set mask "*$nick*!*@[lindex [split $uhost "@"] 1]" }
    8 { set mask "$nick![lindex [split $uhost "@"] 0]@[lindex [split $uhost @] 1]" }
    9 { set mask "$nick![lindex [split $uhost "@"] 0]@[lindex [split [maskhost $uhost] "@"] 1]" }
    10 { set mask "*!*[lindex [split $uhost "@"] 0]*@*" }
    default { set mask "*!*@[lindex [split $uhost @] 1]" }
    return $mask
  }
}

putlog "Restricted.TCL Loaded. - istok@IRCSpeed.org"
Enjoy.
Last edited by Get_A_Fix on Wed Jan 23, 2013 2:26 am, edited 2 times in total.
We explore.. and you call us criminals. We seek after knowledge.. and you call us criminals. We exist without skin color, without nationality, without religious bias.. and you call us criminals.
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

Hey Havok, are either of those scripts working for you??
If not, I may have a script idea that could be what you are looking for.
Let me know if you are still wanting me to try to write it?
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
User avatar
Havok
Voice
Posts: 6
Joined: Sat Dec 08, 2012 2:14 pm
Contact:

Post by Havok »

Oh, the last one works great.
Thanks buddeh :D
Post Reply