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.

auto-voice flood protection

Old posts that have not been replied to for several years.
Locked
User avatar
Dedan
Master
Posts: 260
Joined: Wed Jul 09, 2003 10:50 pm
Location: Memphis

auto-voice flood protection

Post by Dedan »

I am trying to write a small script that
waits to see if there is a join flood or if
the nick has already been +voiced or left
the channel before it tries to +voice him.

Tcl error [auto:voice]:
syntax error in expression "$av_ctr.($chan) >= $av_limit"

This script gives various errors,
I have made many changes without success.
Thank you for any help given.

Dedan

Code: Select all

# Channels you want to auto-voice Nicks on. 
# Multiple channels seperated by spaces.
# set av_chans "#TCLhelp #TCLlovers"
set av_chans "#cGameTesting #dGameTesting"

# Set the Max Number of Joins here
set av_limit 3

# During the Number of Seconds here
set av_sec 13

# Set the Number of Seconds to wait before Voicing the Nick here
set av_offset 7

bind join - * auto:voice
proc auto:voice {nick uhost handle chan} {
  global botnick av_chans av_limit av_sec av_offset
  set chan [string tolower $chan]
  if {[botisop $chan]} {
    foreach c [string tolower $av_chans] {
      if {$c == $chan} { 
        if {![info exists av_ctr.($chan)]} { set av_ctr.($chan) 0 }
        incr av_ctr.($chan) 1
        # trying to see what is happening
        putserv "PRIVMSG $chan :av_ctr.($chan) is $av_ctr.($chan)"
        utimer $av_sec [list av:dec av_ctr.($chan)]
        if {$av_ctr.($chan) >= $av_limit} { 
          return
        } else {
          utimer $av_offset [list av:voice $nick $chan]
          return
        }
      }
    }
  }
}
proc av:dec {ctr} { 
  incr ctr -1 
  # trying to see what is happening
  putserv "PRIVMSG $chan :ctr is $ctr"
}
proc av:voice {vnick vchan} {
  if {[onchan $vnick $vchan] && ![isvoice $vnick $vchan]} {
    pushmode $vchan +v $vnick
  }
}

I once was an intelligent young man, now i am old and i can not remember who i was.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

I've took the liberty to change it a bit, here is the result:

Code: Select all

# Channels you want to auto-voice Nicks on. 
# Multiple channels seperated by spaces. 
# set av_chans "#TCLhelp #TCLlovers" 
set av(chans) "#cGameTesting #dGameTesting" 

# Set the max number of joins during the number of seconds here
set av(stuff) 3:13:7

foreach chan [strlwr $av(chans)] {
  if {![info exists av_ctr([strlwr $chan])] && [botonchan $chan]} {
    set av_ctr([strlwr $chan]) 0
  }
}

bind join - * auto:voice 

proc auto:voice {nick uhost handle chan} { 
global av_ctr
  set chan [strlwr $chan] 
  if {![botisop $chan]} {
    return
  }
  if {![info exists av_ctr($chan)]} {
    set av_ctr($chan) 0
  } 
  incr av_ctr($chan)

  set limit [lindex [split $::av(stuff) ":"] 0]
  set insec [lindex [split $::av(stuff) ":"] 1]
  set offset [lindex [split $::av(stuff) ":"] 2]

  # trying to see what is happening 
  putserv "PRIVMSG $chan :av_ctr($chan) is $av_ctr($chan)" 

  utimer $insec [list av:dec $chan] 
  if {$av_ctr($chan) >= $limit} { 
    return 
    } else { 
    utimer $offset [list av:voice $nick $chan] 
    return 
  } 
}

proc av:dec {chan} { 
  global av_ctr
  incr av_ctr($chan) -1 
  # trying to see what is happening 
  putserv "PRIVMSG $chan :av_ctr is $av_ctr($chan)" 
}

proc av:voice {vnick vchan} { 
  if {[onchan $vnick $vchan] && ![isvoice $vnick $vchan]} { 
    pushmode $vchan +v $vnick 
  } 
} 
Once the game is over, the king and the pawn go back in the same box.
Locked