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.

what is the name of the tcl

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
d
demetrius_reis
Halfop
Posts: 42
Joined: Tue Aug 10, 2010 9:54 am

what is the name of the tcl

Post by demetrius_reis »

I'm looking for old tcl it worked like this:

When the user was banned, the BOT will automatically send a code to the user, use to unban yourself.

What is the name of the tcl?
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Code: Select all

bind mode * "% +b" check:ban

proc check:ban {nick uhost handle channel change target} {
	# check if the mask matches the bot's host and return if it doesn't
	if {![string match -nocase $target $::botname]} return

	# do what action/actions you wish as the mask matches his host
	putserv "PRIVMSG $nick :your message in here"
}
This should do what you want.
Once the game is over, the king and the pawn go back in the same box.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

I don't recall such a script, unfortunately..
I did put this little piece together this afternoon though..

Keep in mind, that the code has not been tested, so it might very well contain various bugs or issues. Also, it does a fair amount of list searches and keeps all codes in memory, so it might degrade performace in 600+ member channels.

The script is written for 1.6.20 eggdrops, if you're using older eggies, you'll have to find a replacement for the matchaddr command..

Code: Select all

bind mode - "% +b" checkBan
bind msg - !unban checkUnban

## Add a time or cron binding to purge old entries every 10 minutes..
#bind cron - "*/10 * * * *" cronPurgeBan
#bind time - "?0 *" cronPurgeBan

proc checkBan {nick host handle channel mode target} {
  ##Don't ban the bot, not explicitly requested but is a good precaution
  if {[matchaddr $target $::botname]} {
    pushmode $channel -b $target
    return
  }
  foreach user [chanlist $channel] {
    if {[matchaddr $target "${user}![getchanhost $user $channel]"]} {
      set key [addUnban $user $channel $target]
      puthelp "PRIVMSG $user :You have been banned! Please send \"!unban $channel $key\" to me to remove the ban"
    }
  }
}

proc generateRandomString {length} {
  set string ""
  while {[incr length -1] >= 0} {
    append string [string index "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!#" [rand 64]]
  }
  return $string
}

proc addUnban {nick channel banmask} {
  set key [string tolower $nick]
  set password [generateRandomString 8]

  ## Check to see if there's any data for the user already..
  if {[info exists $::banKeys($key)]} {

    ## If we're using tcl 8.5, this speeds things up alot..
    if {$::tcl_version >= 8.5} {
      set index [lsearch -index 0 -exact -nocase $::banKeys($key) $channel
    } else {
      for {set i 0; set index -1} {$i < [llength $::banKeys($key)]} {incr i} {
        if {[string equal -nocase [lindex $::banKeys($key) 0] $channel]} {
          set index $i
          break
        }
      }
    }
    ## See if we found a match for this channel in the user's data...
    if {$index >= 0} {
      lset ::banKeys($key) $index [list $channel $banmask $password [clock seconds]]
      return $password
    }
  }
  lappend ::banKeys($key) [list $channel $banmask $password [clock seconds]]
  return $password
}

proc checkUnban {nick host handle text} {
  set key [string tolower $nick]
  set data [split $text]

  ## Check to see if there's any data for the user already..
  if {[info exists $::banKeys($key)]} {

    ## If we're using tcl 8.5, this speeds things up alot..
    if {$::tcl_version >= 8.5} {
      lassign $data bChan bKey
      set index [lsearch -index 0 -exact -nocase $::banKeys($key) $bChan
    } else {
      foreach $data {bChan bKey} {}
      for {set i 0; set index -1} {$i < [llength $::banKeys($key)]} {incr i} {
        if {[string equal -nocase [lindex $::banKeys($key) 0] $bChan]} {
          set index $i
          break
        }
      }
    }
    ## See if we found a match for this channel in the user's data...
    if {$index >= 0} {
      if {[clock seconds] - [lindex $::banKeys($key) $index 3] > 60} {
        set ::banKeys($key) [lreplace $::banKeys($key) $index $index]
        if {[llength $::banKeys($key)] == 0} {
          unset ::banKeys($key)
        }
      } elseif {[string equal -nocase $bKey [lindex $::banKeys($key) $index 2]]} {
        pushmode [lindex $::banKeys($key) $index 0] -b [lindex $::banKeys($key) $index 1]
      }
    }
  }
}

proc purgeBan {{user *}} {
  foreach key [array names ::banKeys -glob [string tolower $user]] {
    set index 0
    while {$i < [llength $::banKeys($key)]} {
      if {[clock seconds] - [lindex $::banKeys($key) $index 3] > 60} {
        set ::banKeys($key) [lreplace $::banKeys($key) $index $index]
      } else {
        incr index
      }
    }
    if {[llength $::banKeys($key)] == 0} {
      unset ::banKeys($key)
    }
  }
}

proc cronPurgeBan {minute hour day month weekday} {
  purgeBan
}
NML_375
d
demetrius_reis
Halfop
Posts: 42
Joined: Tue Aug 10, 2010 9:54 am

Post by demetrius_reis »

oh yes I understand
I will evaluate scripts
thanks!
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Just ignore my first post as it won't do what exactly you needed, nml375's code on the other hand will.

/me takes hat down in front of nml375 :)
Once the game is over, the king and the pawn go back in the same box.
s
simo
Revered One
Posts: 1071
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

this is a bit of an old thread but i was curious about this code and tried it and

got: Tcl error [checkBan]: can't read "::banKeys(lilly)": no such variable

lilly being the banned nick
s
simo
Revered One
Posts: 1071
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

with the help of SpiKe^^ who debugged it and took out all bugs it seems to work proper now, thanks again SpiKe^^ and nml375 ofcourse who wrote the original code,..... apreciated so ill post it here if someone might need it as well:

Code: Select all

bind mode - "% +b" checkBan
bind msg - !unban checkUnban

## Add a time or cron binding to purge old entries every 10 minutes..
bind cron - "*/10 * * * *" cronPurgeBan
#bind time - "?0 *" cronPurgeBan

proc checkBan {nick host handle channel mode target} {
  ##Don't ban the bot, not explicitly requested but is a good precaution
  if {[matchaddr $target $::botname]} {
    pushmode $channel -b $target
    return
  }
  foreach user [chanlist $channel] {
    if {[matchaddr $target "${user}![getchanhost $user $channel]"]} {
      set key [addUnban $user $channel $target]
      puthelp "PRIVMSG $user :You have been banned! Please send \"!unban $channel $key\" to me to remove the ban"
    }
  }
}


proc generateRandomString {length} {
  set string ""
  while {[incr length -1] >= 0} {
    append string [string index "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!#" [rand 64]]
  }
  return $string
}

proc addUnban {nick channel banmask} {
  set key [string tolower $nick]
  set password [generateRandomString 8]

  ## Check to see if there's any data for the user already..
  if {[info exists ::banKeys($key)]} {

    ## If we're using tcl 8.5, this speeds things up alot..
    if {$::tcl_version >= 8.5} {
      set index [lsearch -index 0 -exact -nocase $::banKeys($key) $channel]
    } else {
      for {set i 0; set index -1} {$i < [llength $::banKeys($key)]} {incr i} {
        if {[string equal -nocase [lindex $::banKeys($key) 0] $channel]} {
          set index $i
          break
        }
      }
    }
    ## See if we found a match for this channel in the user's data...
    if {$index >= 0} {
      lset ::banKeys($key) $index [list $channel $banmask $password [clock seconds]]
      return $password
    }
  }
  lappend ::banKeys($key) [list $channel $banmask $password [clock seconds]]
  return $password
}

proc checkUnban {nick host handle text} {
  set key [string tolower $nick]
  set data [split $text]

  ## Check to see if there's any data for the user already..
  if {[info exists ::banKeys($key)]} {

    ## If we're using tcl 8.5, this speeds things up alot..
    if {$::tcl_version >= 8.5} {
      lassign $data bChan bKey
      set index [lsearch -index 0 -exact -nocase $::banKeys($key) $bChan]
    } else {
      foreach {bChan bKey} $data {}
      for {set i 0; set index -1} {$i < [llength $::banKeys($key)]} {incr i} {
        if {[string equal -nocase [lindex $::banKeys($key) 0] $bChan]} {
          set index $i
          break
        }
      }
    }
    ## See if we found a match for this channel in the user's data...
    if {$index >= 0} {
      if {[clock seconds] - [lindex $::banKeys($key) $index 3] > 60} {
        set ::banKeys($key) [lreplace $::banKeys($key) $index $index]
        if {[llength $::banKeys($key)] == 0} {
          unset ::banKeys($key)
        }
      } elseif {[string equal -nocase $bKey [lindex $::banKeys($key) $index 2]]} {
        pushmode [lindex $::banKeys($key) $index 0] -b [lindex $::banKeys($key) $index 1]
      }
    }
  }
}

proc purgeBan {{user *}} {
  foreach key [array names ::banKeys -glob [string tolower $user]] {
    set index 0
      while {$index < [llength $::banKeys($key)]} {
      if {[clock seconds] - [lindex $::banKeys($key) $index 3] > 60} {
        set ::banKeys($key) [lreplace $::banKeys($key) $index $index]
      } else {
        incr index
      }
    }
    if {[llength $::banKeys($key)] == 0} {
      unset ::banKeys($key)
    }
  }
}

proc cronPurgeBan {minute hour day month weekday} {
  purgeBan
}
Post Reply