setudef flag nopubbart
bind pub - !барт pub_bart
bind pub - !bart pub_bart
set bart(delay) 15
set bart(color) \00310
proc pub_bart {nick uhost hand chan args} {
variable bart
if {[channel get $chan nopubbart]} { return }
if {[info exists bart(lasttime,$chan)] && [expr $bart(lasttime,$chan) + $bart(delay)] > [clock seconds]} {
putserv "NOTICE $nick :Запрос не чаще одного раза в $bart(delay) [lindex {. секунду секунды секунд} [bartnumgrp $bart(delay)]]."
putserv "NOTICE $nick :Подождите [expr $bart(delay) - [expr [clock seconds] - $bart(lasttime,$chan)]] [lindex {. секунду секунды секунд} [bartnumgrp [expr $bart(delay) - [expr [clock seconds] - $bart(lasttime,$chan)]]]] до следующего запроса."
return
}
set bartlist {
1.Я не буду кричать "Пожар!" в классе}
set bartline [lindex [split $bartlist \n] [rand [llength [split $bartlist \n]]]]
set bartonr [lindex [split $bartline "."] 0]
set barttxt [lindex [split $bartline "."] 1]
largetext $chan "\[$bartonr\/110\] $bart(color)$barttxt."
set bart(lasttime,$chan) [clock seconds]
}
proc largetext {target text {lineLen 400} {delims {;:.,-!}}} {
if {[string length $text] <= $lineLen} {
putserv "PRIVMSG $target :$text"
return
}
set _text [split $text $delims]
set x 0; set i 0
while {$x < $lineLen} {
if {$i >= [llength $_text]} { return }
set wordlen [string length [lindex $_text $i]];
if {$x + $wordlen > $lineLen} { break }
incr x $wordlen
incr x; incr i
}
putserv "PRIVMSG $target :[string range $text 0 [expr $x - 1]] "
largetext $target [string trimleft [string range $text $x end]] $lineLen $delims
}
proc bartnumgrp {number} {
switch -glob -- "$number" {
*11 {return 3}
*12 {return 3}
*13 {return 3}
*14 {return 3}
*1 {return 1}
*2 {return 2}
*3 {return 2}
*4 {return 2}
default {return 3}
}
}
putlog "bart.tcl by tvrsh loaded"