| View previous topic :: View next topic |
| Author |
Message |
starpossen Op
Joined: 10 Jan 2006 Posts: 139
|
Posted: Wed May 07, 2008 8:45 pm Post subject: Peak in choosen channel |
|
|
I found this script on an old backup cd:
| Code: |
bind PUB fo|fo -peak pub:peak
bind JOIN -|- * join:peak
setudef str peak-data
setudef flag peak
proc pub:peak {nickname hostname handle channel arguments} {
if {![channel get $channel peak]} {return}
if {[set peakdata [channel get $channel peak-data]] == ""} {
puthelp "PRIVMSG $channel :No peak data available yet (try rejoining)."
} else {
puthelp "PRIVMSG $channel :Peak for $channel: [lindex $peakdata 3] (by [lindex $peakdata 0]![lindex $peakdata 1] at [clock format [lindex $peakdata 2] -format {%d/%m/%y %H:%M:%S}])"
}
}
proc join:peak {nickname hostname handle channel} {
if {[channel get $channel peak]} {
if {[set peakdata [channel get $channel peak-data]] == ""} {
channel set $channel peak-data [list $nickname $hostname [clock seconds] [llength [chanlist $channel]]]
} elseif {[lindex $peakdata 3] < [llength [chanlist $channel]]} {
channel set $channel peak-data [list $nickname $hostname [clock seconds] [llength [chanlist $channel]]]
# if you want to announce there is a new peak, do it here (just remove the comment)
puthelp "PRIVMSG $channel :New peak ([llength [chanlist $channel]]) by $nickname!"
}
}
}
|
It works and all, but i'd like to define channels in which to use it
is that hard to make it do so? |
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Wed May 07, 2008 9:12 pm Post subject: |
|
|
It kinda already does that, using .chanset. If you meant a static channel list, you can use the changes below. | Code: | #change
setudef flag peak
#into
variable peakchanlist "#chan1 #chan2 #etc" ;#space delimited
#change
if {![channel get $channel peak]} {return}
#into
if {![lsearch -exact [split $::peakchanlist] $channel]} {return}
#change
if {![channel get $channel peak]} {
#into
if {[lsearch -exact [split $::peakchanlist] $channel]} { |
|
|
| Back to top |
|
 |
starpossen Op
Joined: 10 Jan 2006 Posts: 139
|
Posted: Wed May 07, 2008 9:32 pm Post subject: |
|
|
I tried that and it seemed to work, so thank you
one thing that bothers me, is the output:
| Code: |
<bot> Peak for #channel: 30 (by nick !host@hots.host at 08/05/08 02:48:57)
|
I don't like the idea of it showing the host, I just want nick and date/time, I tried removing the host part in the script, but once again realized that i'm no pro scripter, so the bot crashed, any idea of which line to edit/remove to make it only show nick and date/time? |
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Wed May 07, 2008 9:36 pm Post subject: |
|
|
| Code: | #change
puthelp "PRIVMSG $channel :Peak for $channel: [lindex $peakdata 3] (by [lindex $peakdata 0]![lindex $peakdata 1] at [clock format [lindex $peakdata 2] -format {%d/%m/%y %H:%M:%S}])"
#into either
#1) gives 'nick at date' as reply.
puthelp "PRIVMSG $channel :Peak for $channel: [lindex $peakdata 3] (by [lindex $peakdata 0] at [clock format [lindex $peakdata 2] -format {%d/%m/%y %H:%M:%S}])"
#or
#2) gives 'nick duration ago' as reply, this is a better replacement.
puthelp "PRIVMSG $channel :Peak for $channel: [lindex $peakdata 3] (by [lindex $peakdata 0] [duration [expr [unixtime] - [lindex $peakdata 2]]] ago)" |
|
|
| Back to top |
|
 |
starpossen Op
Joined: 10 Jan 2006 Posts: 139
|
Posted: Wed May 07, 2008 11:07 pm Post subject: |
|
|
Number 2 is absolutly what I wanted, thanks alot for the help, and the quick replys.
So I guess there's nothing more to add to this script, or do you have any additions or ideas? |
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Wed May 07, 2008 11:47 pm Post subject: |
|
|
| starpossen wrote: | Number 2 is absolutly what I wanted, thanks alot for the help, and the quick replys.
So I guess there's nothing more to add to this script, or do you have any additions or ideas? |
A throttle mechanism to keep clueless users from repeating the command several thousand times (+f/o users can be clueless and yes i noticed you restricted binding to just those flags )
User has written a great one that could easily be incorporated. |
|
| Back to top |
|
 |
starpossen Op
Joined: 10 Jan 2006 Posts: 139
|
Posted: Wed May 07, 2008 11:54 pm Post subject: |
|
|
Somewhat a flood-control, let's say users can't use the peak command twice in a row, a 30 second denial of usage, to prevent spam/flood, could be very usefull, in case of flagged users getting a bit to hyper with the command.
And yes I know I can restrict the command so only I can use it, but still, a flood-control kinda thing would be great.
*EDIT* maybe i'm to tired, but it looks like I kinda repeated what you wrote, except my text looks confusing. |
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Thu May 08, 2008 12:30 am Post subject: |
|
|
To add it, copy the steps below. | Code: | # code provided by user via egghelp forums
# url @ http://forum.egghelp.org/viewtopic.php?t=9009&start=3
proc throttled {id seconds} {
global throttle
if {[info exists throttle($id)]&&$throttle($id)>[clock sec]} {
set id 1
} {
set throttle($id) [expr {[clock sec]+$seconds}]
set id 0
}
}
# delete expired entries every 10 minutes
bind time - ?0* throttledCleanup
proc throttledCleanup args {
global throttle
set now [clock sec]
foreach {id time} [array get throttle] {
if {$time<=$now} {unset throttle($id)}
}
} |
Add the above to bottom of the script (in it's entirety without changing anything, user deserves credit). Then make the change below, that's it.
| Code: | #change
if {![lsearch -exact [split $::peakchanlist] $channel]} {return}
#into
if {[throttled $hostname,$channel 30] || ![lsearch -exact [split $::peakchanlist] $channel]} {return} |
This allows one trigger per "!ident@hostname,#channel" every 30 seconds. If instead you think once public in channel is enough, use the code below. | Code: | #into
if {[throttled $channel 30] || ![lsearch -exact [split $::peakchanlist] $channel]} {return} | Once every 30 seconds per channel, regardless of who why or what triggered it. |
|
| Back to top |
|
 |
starpossen Op
Joined: 10 Jan 2006 Posts: 139
|
Posted: Thu May 08, 2008 8:28 am Post subject: |
|
|
| Ofcourse i'll keep the script unchanged which you posted so credits are where they should be, and also it works very nicely, thanks for all your help, and especially the very quick reply's. |
|
| Back to top |
|
 |
|