Peak - Record channel peaks

Purpose of this sBNC add-on, is to record and store channel peaks. In other words to remember the maximum of users that has been on a certain channel and when that was. A simple addition encouraged by a post in the sBNC forum.

Requirements

Software Version Details
sBNC (w/TCL module) 1.2 Developed and tested on 1.2-8411).

Download

Latest version: Build 1 (2006-10-29) .zip (1.2kB)
Previous versions: None

Install

  • Download
  • Unzip
  • Place peak.tcl in scripts/
  • Add source scripts/peak.tcl to sbnc.tcl
  • Rehash TCL
  • Use

Usage

Default syntax:

/sbnc peak [#channel]

If a channel is not specified it will list a top5 of known channel peaks.

Source

Note that this source will/should be the development version, i.e. all changes noted in the history section, will have been made in this section.

peak.tcl

# peak.tcl - Record channel peaks
# Copyright (C) 2006 David Lorentsen
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
internalbind command peak:commands
bind join - * peak:join
 
proc peak:commands {client parameters} {
	if {[string equal -nocase [lindex $parameters 0] "peak"]} {
		if {[llength $parameters] < 2} {
			set top5 [list]
			foreach tag [bncgetglobaltags] {
				set tagd [split $tag "."]
				if {[string equal [lindex $tagd 0] "peak"]} {
					lappend top5 [list [lindex $tagd 1] [lindex [split [bncgetglobaltag $tag] "."] 0]] 
				}
			}
			set top5 [lrange [lsort -decreasing -integer -index 1 $top5] 0 4]
			bncreply "Top[llength $top5] peaks:"
			foreach peak $top5 {
				bncreply "[lindex $peak 0] with [lindex $peak 1] users."
			}
			bncreply "End of list. Use '/sbnc peak #channel' for a specific channel."
		} else {
			set channel [string tolower [lindex $parameters 1]]
			if {[bncgetglobaltag "peak.${channel}"]} {
				set data [split [bncgetglobaltag "peak.${channel}"] "."]
				bncreply "Peak for $channel is [lindex $data 0] users, set [clock format [lindex $data 1] -format "%A, %Y-%m-%d %H:%M:%S"]."
			} else {
				bncreply "No peak saved for [lindex $parameters 1]"
			}
		}
		haltoutput
	}
}
 
proc peak:join {nick host hand chan} {
	peak:check $chan [llength [chanlist $chan]]
}
 
proc peak:initscan {} {
	foreach user [bncuserlist] {
		setctx $user
		foreach chan [channels] {
			peak:check $chan [llength [chanlist $chan]]
		}
	}
}
 
proc peak:check {chan current} {
	set peak [bncgetglobaltag "peak.${chan}"]
	if {[string equal $peak ""] || $peak < $current} {
		bncsetglobaltag "peak.${chan}" "${current}.[unixtime]"
	}
}
 
peak:initscan

History

Build 2 (????-??-??)

Release date Notes
????-??-?? Only minor changes, no point in releasing yet..
  • Proper reply if you specify a channel without peak.

Build 1 (2006-10-29)

Release date Notes
2006-10-29 First public release
  • No prior releases to compare with.
1) Uses global tags to store data. A feature introduced with 1.2
sbnc/peak.txt · Last modified: 2006/10/31 12:36 by zyberdog