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 

Help with restrict.tcl

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases
View previous topic :: View next topic  
Author Message
anotheregglover
Voice


Joined: 13 Jan 2005
Posts: 38

PostPosted: Thu Apr 14, 2005 5:54 pm    Post subject: Help with restrict.tcl Reply with quote

I am using the restrict.tcl script to restrict access to one of my channels. I only have it loaded on one bot, but whenever a user(me on a different host in this case) enters, a random bot kicks him and it messes up the count. I tried taking out the newchanban part and having it just putserv the kick and ban, but it still doesnt work. Here is the script if anybody can help me with this:


Code:
# Restricted access TCL V1.4
# by quantum @ dalnet

# what it does:

# k/b's anyone who's not in the bot's userfile and puts a kick counter in the message

####################################
#  Values to modify
####################################

# What chan to restrict?
set r_chan "#electronica"

# Duration of ban in minutes (0 for perm)
set r_time 60

# File to add kick messages to
set r_msg "rkickmsgs"

# Flag needed to add msgs
set addflag "m"

# Flag required to msgs
set delflag "m"

###################################
#  You may not modify it
##################################

bind join -|- "$r_chan *!*@*" r_kick
bind pub $addflag !addkickmsg r_addmsg
bind pub $delflag !delkickmsg r_delmsg

proc r_kick { nick uhost hand chan } {
   global r_ban r_time r_chan r_msg

# create random kick number file and random kick msg file if not otherwise created (lazy bastard)

   if {![file exists restrictkick]} {
   set rnum [open restrictkick w]
   puts $rnum "0"
   close $rnum
    }

   if {![file exists r_msg]} {
   set rmsg [open r_msg w]
   puts $rnum "thou hast been neutralized"
   putlog "*** Restrict 1.3 - Restrict Kick Msg File created with 1 default kick msg.  Type !addkickmsg <msg> to add more."
   close $rmsg
    }

# get random kick msg

#   if {[lindex [split $arg] 0] != ""} { set chan [lindex [split $arg] 0] }
   if {(![file exists $r_msg]) || (![file readable $r_msg])} {
      putserv "NOTICE $nick :Unable to read from file $r_msg."
   } else {
      set kmsg [r_getmsg]
   }


   if { ![validuser $hand] } {

   set rnum [open restrictkick r]
   gets $rnum knum
   close $rnum
   set cnum [expr $knum + 1]
   set rnum [open restrictkick w]
   puts $rnum "$cnum"
   close $rnum
---------------------this is the part i changed to putserv kick and mode +b, but a random bot still kicks the user-------------------
   newchanban $chan [string trimleft [maskhost [getchanhost $nick $chan]] ~] neutralized " $kmsg \[\002\037$cnum\002\037|\002\037$r_chan\002\037\]" $r_time

   }
}

# Get random msg from file

proc r_getmsg { } {
global r_msg
set kmsg ""
   set fd [open $r_msg r]
   while {![eof $fd]} {
      gets $fd text
      if {$text != ""} {
         lappend kmsg $text
      }
   }
   close $fd
   return [lindex $kmsg [rand [llength $kmsg]]]
}


# Add an msg

proc r_addmsg {nick uhost hand chan arg}  {
global r_msg
set kmsg [join [lrange [split $arg] 0 end]]
   if {$kmsg == ""} {
      putserv "NOTICE $nick :Usage: !addkickmsg <kick msg>"
   } else {
      if {[prc_addmsg $kmsg]} {
         putserv "NOTICE $nick :An msg msg was added to $r_msg."
      } else {
         putserv "NOTICE $nick :Unable to add msg to $r_msg."
      }
   }
return 1
}

# Delete an msg

proc r_delmsg {nick uhost hand chan arg} {
global r_msg
set kmsg [join [lrange [split $arg] 0 end]]
   if {(![file exists $r_msg]) || (![file readable $r_msg])} {
      putserv "NOTICE $nick :Unable to read from file $r_msg."
   } else {
      if {$kmsg == ""} {
         putserv "NOTICE $nick :Usage: !delkickmsg <kick msg>"
      } else {
         if {[prc_delmsg $kmsg]} {
            putserv "NOTICE $nick :An was deleted from $r_msg."
         } else {
            putserv "NOTICE $nick :Unable to delete msg from $r_msg."
         }
      }
   }
return 1
}

proc prc_addmsg {kmsg} {
global r_msg
   if {[catch {open $r_msg a} fd]} {
      return 0
   } else {
      puts $fd $kmsg
      close $fd
      return 1
   }
}

proc prc_delmsg {kmsg} {
global r_msg
set what ""
set msgrem 0
   if {[catch {open $r_msg r} fd]} {
      return 0
   } else {
      while {![eof $fd]} {
         gets $fd text
         if {[string tolower $text] != [string tolower $kmsg]} {
            append what "$text\n"
         } else {
            set msgrem 1
         }
      }
      close $fd
      if {[catch {open $r_msg w} fd]} {
         return 0
      } else {
         puts $fd $what
         close $fd
         return $msgrem
      }
   }
}

### End
putlog "Restrict 1.4 loaded <\037\002quantum\037\002>"

### Create kickmsg file if it doesn't exist

if {![file exists $r_msg]} {
   set rmsg [open $r_msg w]
   puts $rmsg "thou hast been neutralized"
   putlog "*** Restrict 1.4 - Restrict Kick Msg File created with 1 default kick msg.  Type !addkickmsg <msg> to add more."
   close $rmsg
}
Back to top
View user's profile Send private message
metroid
Owner


Joined: 16 Jun 2004
Posts: 771

PostPosted: Fri Apr 15, 2005 1:29 am    Post subject: Reply with quote

Try my keepout script, It works fine and won't mess up.

http://v1per.servicez.org/scripts/keepout.tcl
Back to top
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Fri Apr 15, 2005 5:49 am    Post subject: Reply with quote

Why don't you first contact the author regarding any issues with the script?
_________________
Once the game is over, the king and the pawn go back in the same box.
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 -> Script Support & Releases 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