Code: Select all
set reason [lrange [split $arg] 0 end]
.... You forgot the join...
Code: Select all
set reason [join [lrange [split $arg] 0 end]]
blackshadow wrote:Thanks for the sugestion speechles.
Suggestion? It wasn't that at all. It was fixing the part which wasn't written correctly. The same as your code example shown above. This isn't a suggestion, this is a clear error within your script. You might say, meh, added braces when the reason contains spaces is a feature. Feature this isn't, it's clearly flawed understanding on lists vs strings. Blackshadow, all your scripts need to be checked for this problem you aren't watching closely enough these lessons and in your posts your teaching people horrible habits that are flawed...
blake wrote:Need adding to this also what i need it to do is when someone uses the proc once it wont allow them to use it again untill 2 minues has passed if they try within the 2 minutes it
should notice them a message such as please wait 2 minutes before sending another report
Use this simple script below which includes user's "throttle" procedure which is posted
here.
Code: Select all
variable reportTime 120
bind msg -|- report cmd:report
proc cmd:report {nick uhost hand arg} {
if {![throttled "$nick!$uhost" $::reportTime]} {
set reason [join [lrange [split $arg] 0 end]]
putserv "NOTICE #Ops :Report made: <$nick ($uhost)> $reason"
puthelp "NOTICE $nick :Your report has been recieved"
} else {
puthelp "NOTICE $nick :Slow your roll.... You've been throttled!"
}
}
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)}
}
}
This does exactly what you want. Tracking is done by "nick!ident@host" and each can only use this command once every 2 minutes.