ChanPeak.tcl

ChanPeak.tcl

This script keeps a record of the peak amount of users in a channel. The channel peak can be viewed from dcc chat or via pub command. It can also optionally announce to the channel or broadcast a partyline notice when a channel's peak record is broken.

Postat de Copyright Categorie Review user Vizualizari Data
btc Scram stats Cod netestat 450 2023-12-24 23:33:02

#####################################################################
### ChanPeak.tcl                				  ###
### Version 1.3ger	      				          ###
### Übersetzer: Scram	         				  ###
### Tester:	Majonas	         				  ###
### Über einen besuch in den Channels würden wir uns freuen ;o) ! ###
### IrcNet #Edenbridge & #Goslar 				  ###
#####################################################################

##################################
### Originalversion:	       ###
### ChanPeak.tcl               ###
### Version 1.3                ###
### By Wcc                     ###
### [email protected]        ###
### http://www.dawgtcl.com:81/ ###
### EFnet #|DAWG|Tcl           ###
##################################

############################################################################
### Copyright © 2000 - 2002 |DAWG| Scripting Group. All rights reserved. ###
############################################################################

###############################################################################
## This script keeps a record of the peak amount of users in a channel. The  ##
## channel peak can be viewed from dcc chat or via pub command. It can also  ##
## optionally announce to the channel or broadcast a partyline notice when a ##
## channel's peak record is broken.                                          ##
###############################################################################

###############################################################################
## Veränderungen gegenüber des Originalscripts:				     ##
## Ührzeit auf 24 Stunden Anzeige geändert ! (AM und PM fallen weg ;o)       ##
## Datum in Tag Monat Jahr geändert !					     ##
## Ausgabetext in deutsch übersetzt !					     ##
## Abänderung der Ausgabe in der Partyline wenn das Script geladen wird !    ##
###############################################################################

##############
## COMMANDS ##
#############################################################
## DCC ## .chanset <channel> +/-peak                       ##
######### Enables or disables peak-trackingfor a channel.  ##
######### ------------------------------------------------ ##
######### .peak <channel> (Can be changed)                 ##
######### Shows the peak for a channel.                    ##
#############################################################
## PUB ## !peak [channel] (Can be changed)                 ##
######### Shows the peak for the specified channel. If no  ##
######### channel is specified, the current channel's peak ##
######### will be displayed.                               ##
#############################################################

##########################################################
## Just load the script, edit the settings, and rehash. ##
##########################################################

###########################################################
# Set the flag required to use the pub peak command here. #
###########################################################

set chanpeak_setting(pflag) "-|-"

###########################################################
# Set the flag required to use the dcc peak command here. #
###########################################################

set chanpeak_setting(dflag) "-|-"

##################################
# Set the pub peak command here. #
##################################

set chanpeak_setting(cmd_pub) "!peak"

##################################
# Set the dcc peak command here. #
##################################

set chanpeak_setting(cmd_dcc) "peak"

###################################
# Enable use of bold in DCC chat? #
###################################

set chanpeak_setting(bold) 1

############################################
# Prefix "CHANPEAK:" in DCC chat messages? #
############################################

set chanpeak_setting(CHANPEAK:) 1

######################################
# Announce new peaks to the channel? #
######################################

set chanpeak_setting(announce) 0

#########################################
# Broadcast new peaks to the partyline? #
#########################################

set chanpeak_setting(cast) 1

###################################
# Set the database filename here. #
###################################

set chanpeak_setting(db) "./scripts/peak.db"

####################
# Code begins here #
####################

if {![string match 1.6.* $version]} { putlog "\002CHANPEAK:\002 \002WARNING:\002 This script is intended to run on eggdrop 1.6.x or later." }
if {[info tclversion] < 8.2} { putlog "\002CHANPEAK:\002 \002WARNING:\002 This script is intended to run on Tcl Version 8.2 or later." }

setudef flag peak
bind join - * chanpeak_join
bind dcc $chanpeak_setting(dflag) $chanpeak_setting(cmd_dcc) chanpeak_dcc
bind pub $chanpeak_setting(pflag) $chanpeak_setting(cmd_pub) chanpeak_pub

proc chanpeak_readarray {array file} {
	upvar $array ours
	if {[catch {open $file r} fd]} { return }
	if {[array exists ours]} { unset ours }
	foreach line [split [read $fd] \n] {
		if {[string range $line 0 2] != "%!%" || [scan [string range $line 3 end] {%[^!]!!!%s} name data] != 2} { continue }
		if {![info exists data]} { set data "" }
		set ours($name) $data
	}
	close $fd
}
proc chanpeak_savearray {array file} {
	upvar $array ours
	if {![array exists ours] || [catch {open $file w} fd]} { return }
	foreach entry [array names ours] { puts $fd "%!%$entry!!!$ours($entry)" }
	close $fd
}
if {[file exists $chanpeak_setting(db)]} { chanpeak_readarray chanpeak_peak $chanpeak_setting(db) }
proc chanpeak_dopre {} {
	if {!$::chanpeak_setting(CHANPEAK:)} { return "" }
	if {!$::chanpeak_setting(bold)} { return "CHANPEAK: " }
	return "\002CHANPEAK:\002 "
}
proc chanpeak_dcc {hand idx text} {
	if {$text == ""} { putdcc $idx "[chanpeak_dopre]Usage: .$::chanpeak_setting(cmd_dcc) <channel>" ; return }
	if {![info exists ::chanpeak_peak([string tolower [set chan [lindex [split $text] 0]]])]} { putdcc $idx "[chanpeak_dopre]The peak record for $chan does not exist." ; return }
	set list [split $::chanpeak_peak([string tolower $chan]) @]
	putdcc $idx "[chanpeak_dopre]Der Channel Rekord für $chan2 liegt bei [lindex $list 0] User. Der Rekord wurde am [lindex $list 1] um [lindex $list 2] Uhr erreicht."
}
proc chanpeak_pub {nick uhost hand chan text} {
	if {[set chan2 [lindex [split $text] 0]] == ""} { set chan2 $chan }
	if {![info exists ::chanpeak_peak([string tolower $chan2])]} { puthelp "PRIVMSG $chan :The peak record for $chan2 does not exist." ; return }
	set list [split $::chanpeak_peak([string tolower $chan2]) @]
	puthelp "PRIVMSG $chan :Der Channel Rekord für $chan2 liegt bei [lindex $list 0] User. Der Rekord wurde am [lindex $list 1] um [lindex $list 2] Uhr erreicht."
}
proc chanpeak_join {nick uhost hand chan} {
	global chanpeak_peak
	if {[lsearch -exact [channel info $chan] +peak] == -1} { return }
	if {[info exists chanpeak_peak([string tolower $chan])]} {
		set peak $chanpeak_peak([string tolower $chan])
	} {
		set peak "0@[clock format [clock seconds] -format %d].[clock format [clock seconds] -format %m].[clock format [clock seconds] -format %Y]@[clock format [clock seconds] -format "%H:%M"]@--"
	}
	set peak [split $peak @]
	if {[lindex $peak 0] >= [set users [llength [chanlist $chan]]]} { return }
	if {$::chanpeak_setting(announce)} { puthelp "PRIVMSG $chan :Neuer $chan Rekord: $users user. Der Letze Rekord war am [lindex $peak 1] um [lindex $peak 2]." }
	if {$::chanpeak_setting(cast)} { dccbroadcast "Neuer $chan Rekord: $users user. Der Letze Rekord war am [lindex $peak 1] um [lindex $peak 2]." }
	set ::chanpeak_peak([string tolower $chan]) "$users@[clock format [clock seconds] -format %d].[clock format [clock seconds] -format %m].[clock format [clock seconds] -format %Y]@[clock format [clock seconds] -format {%H:%M}]@[clock format [clock seconds] -format %p]"
	chanpeak_savearray chanpeak_peak $::chanpeak_setting(db)
}
putlog "\002CHANPEAK:\002 ChanPeak.tcl Version 1.3ger Übersetzer: Scram , Tester: Majonas . Über einen besuch in #Edenbridge & #Goslar im IrcNet würden wir uns freuen. Dank an Wcc für dieses Script"