Code: Select all
namespace eval talkIsCheap {
# When a person has spoken 500 words without being idle
# for more than 10 minutes, he/she is rewarded a voice.
# The voice is lost if idle for more than 10 minutes.
# - Unless you change the following settings:
variable limit 500;# words
variable idle 10;# minutes
# change the mask or add more binds if you need it to
# work in other channels:
bind pubm - "#get_clue *" [namespace current]::count
# public command to get the number of words left for
# yourself or the given person:
bind pub - !wordsLeft [namespace current]::wordsLeft
# the timer checking for idlers
bind time - * [namespace current]::devoice
# variable for keeping track of user counts
variable count
# the counting proc (called when someone speaks)
proc count {n u h c s} {
variable limit
variable count
if {[isvoice $n $c]||[isop $n $c]} {
if {[info exists count($c,$u)]} {set count($c,$u) [clock sec],$limit}
return
}
if {[info exists count($c,$u)]} {scan $count($c,$u) %*i,%i a} {set a 0}
set a [expr {$a+1+[regexp -all {[ \t,]+} $s]}]
if {$a>=$limit} {
set count($c,$u) [clock sec],$limit
pushmode $c +v $n
} {
set count($c,$u) [clock sec],$a
}
}
# the devoice proc (run once every minute)
proc devoice args {
variable idle
variable count
set t [expr {[clock sec]-$idle*60}]
foreach {e v} [array get count] {
if {[scan $v %i]<$t} {
unset count($e)
scan $e {%[^,],%s} c u
if {![validchan $c]} continue
foreach n [chanlist $c] {
if {[getchanhost $n $c]==$u&&[isvoice $n $c]&&![isop $n $c]} {
pushmode $c -v $n
}
}
}
}
}
# the public counter display (by user request)
proc wordsLeft {n u h c a} {
if {$a!=""} {
if {[onchan $a $c]} {
set n $a
set u [getchanhost $n $c]
} else return
}
variable count
if {![isvoice $n $c]&&[info exists count($c,$u)]} {
variable limit
set words [expr {$limit-[scan $count($c,$u) %*i,%i]}]
set s [expr {$words==1?"":"s"}]
puthelp "PRIVMSG $c :$n has to speak $words more word$s to get voiced."
}
}
}
Code: Select all
namespace eval talkIsCheap {
# When a person has spoken 500 words without being idle
# for more than 10 minutes, he/she is rewarded a voice.
# The voice is lost if idle for more than 10 minutes.
# - Unless you change the following settings:
variable limit 500;# words
variable idle 10;# minutes
# change the mask or add more binds if you need it to
# work in other channels:
bind pubm - "*" [namespace current]::count
# public command to get the number of words left for
# yourself or the given person:
bind pub - !words [namespace current]::wordsLeft
# the timer checking for idlers
bind time - * [namespace current]::devoice
# variable for keeping track of user counts
variable count
# the counting proc (called when someone speaks)
proc count {n u h c s} {
variable limit
variable count
if {[isvoice $n $c]||[isop $n $c]} {
if {[info exists count($c,$u)]} {set count($c,$u) [clock sec],$limit}
return
}
if {[info exists count($c,$u)]} {scan $count($c,$u) %*i,%i a} {set a 0}
set a [expr {$a+1+[regexp -all {[ \t,]+} $s]}]
if {$a>=$limit} {
set count($c,$u) [clock sec],$limit
pushmode $c +v $n
} {
set count($c,$u) [clock sec],$a
}
}
# the devoice proc (run once every minute)
proc devoice args {
variable idle
variable count
set t [expr {[clock sec]-$idle*60}]
foreach {e v} [array get count] {
if {[scan $v %i]<$t} {
unset count($e)
scan $e {%[^,],%s} c u
if {![validchan $c]} continue
foreach n [chanlist $c] {
if {[getchanhost $n $c]==$u&&[isvoice $n $c]&&![isop $n $c]} {
pushmode $c -v $n
}
}
}
}
}
# the public counter display (by user request)
proc wordsLeft {n u h c a} {
if {$a!=""} {
if {[onchan $a $c]} {
set n $a
set u [getchanhost $n $c]
} else return
}
variable count
if {![isvoice $n $c]&&[info exists count($c,$u)]} {
variable limit
set words [expr {$limit-[scan $count($c,$u) %*i,%i]}]
set s [expr {$words==1?"":"s"}]
puthelp "PRIVMSG $c :$n has to speak $words more word$s to get voiced."
}
}
}
Code: Select all
[07:42] <[Sp4wn]> testing 1 2 3
[07:42] <[Sp4wn]> testing 1 2 3
[07:42] <[Sp4wn]> bla bla bla
[07:42] <[Sp4wn]> !words [Sp4wn]
[07:42] <[Sp4wn]> !words
[07:44] <[Sp4wn]> !words
[07:44] <[Sp4wn]> !words
[07:44] <[Sp4wn]> !words
[07:44] <[Sp4wn]> !words
[07:45] <[Sp4wn]> bla bla bla
[07:45] <[Sp4wn]> bla bla bla
[07:45] <[Sp4wn]> bla bla bla
[07:45] <[Sp4wn]> bla bla bla
[07:47] <[Sp4wn]> bla bla bla
[07:47] <[Sp4wn]> bla bla bla
[07:47] <[Sp4wn]> bla bla bla
Code: Select all
[07:47] <[myteddy]> [07:47] #[Sp4wn]# binds pub*
[07:47] <[myteddy]> Command bindings:
[07:47] <[myteddy]> TYPE FLGS COMMAND HITS BINDING (TCL)
[07:47] <[myteddy]> pub -|- !seen 0 pub_seen
[07:47] <[myteddy]> pub -|- !asl 0 asl_search
[07:47] <[myteddy]> pub o|- !asldel 0 asl_del
[07:47] <[myteddy]> pub o|- !asladd 0 asl_add
[07:47] <[myteddy]> pub -|- !lijst 0 pub_list
[07:47] <[myteddy]> pub o|o !zwijg 0 pub_shutup
[07:47] <[myteddy]> pub o|o !spreek 0 pub_speak
[07:47] <[myteddy]> pub o|o !vergeet 0 pub_forget
[07:47] <[myteddy]> pub o|o !leer 0 pub_teach
[07:47] <[myteddy]> pub -|- !words 6 ::talkIsCheap::wordsLeft
[07:47] <[myteddy]> pubm -|- * 3 pubm_search
[07:47] <[myteddy]> pubm -|- * 10 ::talkIsCheap::count
Code: Select all
source scripts/alltools.tcl
source scripts/action.fix.tcl
source scripts/teach.tcl
source scripts/asl.tcl
source scripts/seen5.5.4.tcl
# source scripts/mc.idledemode.tcl
# source scripts/count.tcl
source scripts/talkIsCheap.tcl
Code: Select all
source scripts/alltools.tcl
source scripts/action.fix.tcl
# source scripts/teach.tcl
# source scripts/asl.tcl
# source scripts/seen5.5.4.tcl
# source scripts/mc.idledemode.tcl
# source scripts/count.tcl
source scripts/talkIsCheap.tcl
Code: Select all
bind msg - !words [namespace current]::wordsLeft
bind pub - !words [namespace current]::wordsLeft
proc wordsLeft {n u h args} {
variable count
variable limit
if {[scan [join $args] %s%s c t]<1||![validchan $c]} return
if {[info exists t]} {set u [getchanhost $t]} {set t $n}
if {![onchan $t $c]||![info exists count($c,$u)]||[isvoice $t $c]} return
set i [expr {$limit-[scan $count($c,$u) %*i,%i]}]
puthelp "PRIVMSG $n :[expr {$n==$t?"You have":"$t has"}] $i word[expr {$i==1?"":"s"}] to go."
}