Code: Select all
# set the number of messages to send at one time #
set BroadCast(msgs) "4"
# set how long to wait before sending more (in seconds) #
set BroadCast(wait) "10"
bind pub n !broadcast broadcast:buildQueue
proc broadcast:buildQueue {nick uhost hand chan text} {
global BroadCast
if {![llength [split $text]]} {
puthelp "NOTICE $chan :Error, syntax: !broadcast [channel] <message>"
return
}
if {[string equal -length 1 # $text]} {
set chan [lindex [split $text] 0]
if {![validchan $chan]} {
puthelp "NOTICE $chan :Error, $chan channel is not valid."
return
}
if {![botonchan $chan]} {
puthelp "NOTICE $chan :Error, I'm not on $chan channel right now."
return
}
set text [join [lrange [split $text] 1 end]]
}
set users [lreplace [chanlist $chan] 0 0]
if {![llength $users]} {
puthelp "NOTICE $nick :Error, No one in $chan channel right now."
return
}
set end [expr {$BroadCast(msgs)-1}]
broadcast:sendMessage $nick [lrange $users 0 $end] $text
set users [lrange $users $BroadCast(msgs) end]
set time 0
while {[llength $users] > 0} {
incr time $BroadCast(wait)
utimer $time [list broadcast:sendMessage $nick [lrange $users 0 $end] $text]
set users [lrange $users $BroadCast(msgs) end]
}
}
proc broadcast:sendMessage {sender queue text} {
foreach user [split $queue] {
puthelp "PRIVMSG $user :$text (via $sender)"
}
}
Code: Select all
# set the number of messages to send at one time #
set BroadCast(msgs) "4"
# set how long to wait before sending more (in seconds) #
set BroadCast(wait) "10"
bind pub n !broadcast broadcast:buildQueue
proc broadcast:buildQueue {nick uhost hand chan text} {
global BroadCast
if {![llength [split $text]]} {
puthelp "NOTICE $chan :Error, syntax: !broadcast [channel] <message>"
return
}
if {[string equal -length 1 # $text]} {
set chan [lindex [split $text] 0]
if {![validchan $chan]} {
puthelp "NOTICE $chan :Error, $chan channel is not valid."
return
}
if {![botonchan $chan]} {
puthelp "NOTICE $chan :Error, I'm not on $chan channel right now."
return
}
set text [join [lrange [split $text] 1 end]]
}
set users [lreplace [chanlist $chan] 0 0]
if {![llength $users]} {
puthelp "NOTICE $nick :Error, No one in $chan channel right now."
return
}
foreach user [lrange $users 0 [expr {$BroadCast(msgs)-1}]] {
puthelp "PRIVMSG $user :$text (via $nick)"
}
set users [lrange $users $BroadCast(msgs) end]
if {[llength $users]} {
utimer $BroadCast(wait) [list broadcast:sendMessage $nick $users $text]
}
}
proc broadcast:sendMessage {sender queue text} {
global BroadCast
foreach user [lrange $queue 0 [expr {$BroadCast(msgs)-1}]] {
puthelp "PRIVMSG $user :$text (via $sender)"
}
set queue [lrange $queue $BroadCast(msgs) end]
if {[llength $queue]} {
utimer $BroadCast(wait) [list broadcast:sendMessage $sender $queue $text]
}
}
Code: Select all
# set the number of messages to send at one time #
set BroadCast(msgs) "4"
# set how long to wait before sending more (in seconds) #
set BroadCast(wait) "10"
bind pub n !broadcast broadcast:buildQueue
proc broadcast:buildQueue {nick uhost hand chan text} {
global BroadCast
if {[string match #* $text]} {
set chan [lindex [split $text] 0]
if {![validchan $chan]} {
puthelp "NOTICE $nick :Error, $chan channel is not valid."
return
}
if {![botonchan $chan]} {
puthelp "NOTICE $nick :Error, I'm not on $chan channel right now."
return
}
set text [join [lrange [split $text] 1 end]]
}
set text [string trim $text]
if {$text eq ""} {
puthelp "NOTICE $nick :Error, syntax: !broadcast [channel] <message>"
return
}
set users [lreplace [chanlist $chan] 0 0]
if {![llength $users]} {
puthelp "NOTICE $nick :Error, No one in $chan channel right now."
return
}
puthelp "NOTICE $nick :Broadcasting message to everyone in $chan..."
foreach user [lrange $users 0 [expr {$BroadCast(msgs)-1}]] {
puthelp "PRIVMSG $user :$text (via $nick)"
}
set users [lrange $users $BroadCast(msgs) end]
if {[llength $users]} {
utimer $BroadCast(wait) [list broadcast:sendMessage $nick $users $text]
} else {
puthelp "NOTICE $nick :Broadcast Message Completed."
}
}
proc broadcast:sendMessage {sender queue text} {
global BroadCast
foreach user [lrange $queue 0 [expr {$BroadCast(msgs)-1}]] {
puthelp "PRIVMSG $user :$text (via $sender)"
}
set queue [lrange $queue $BroadCast(msgs) end]
if {[llength $queue]} {
utimer $BroadCast(wait) [list broadcast:sendMessage $sender $queue $text]
} else {
puthelp "NOTICE $sender :Broadcast Message Completed."
}
}
Code: Select all
# broadcast.tcl ver 0.1 by SpiKe^^ | Based on a script by: caesar #
# Script replies to !broadcast command in the channel & in private message #
# When using the private message command, <channel> is required #
# set the number of messages to send at one time #
set BroadCast(msgs) "4"
# set how long to wait before sending more (in seconds) #
set BroadCast(wait) "10"
# change access flags & triggers for public/message commands below #
bind pub n !broadcast broadcast:buildQueue
bind msg n !broadcast broadcast:mBuildQueue
############################# END OF SETTINGS #############################
proc broadcast:mBuildQueue {nick uhost hand text} {
if {![string match #* $text] || [llength [split $text]]<"2"} {
puthelp "NOTICE $nick :Error, syntax: !broadcast <channel> <message>"
return 0
}
broadcast:buildQueue $nick $uhost $hand [lindex [split $text] 0] $text
return 0
}
proc broadcast:buildQueue {nick uhost hand chan text} {
global BroadCast
if {[utimerexists broadcast:sendMessage] ne ""} {
puthelp "NOTICE $nick :Please wait, still working on last broadcast."
return 0
}
if {[string match #* $text]} {
set chan [lindex [split $text] 0]
if {![validchan $chan]} {
puthelp "NOTICE $nick :Error, $chan channel is not valid."
return 0
}
if {![botonchan $chan]} {
puthelp "NOTICE $nick :Error, I'm not on $chan channel right now."
return 0
}
set text [join [lrange [split $text] 1 end]]
}
set text [string trim $text]
if {$text eq ""} {
puthelp "NOTICE $nick :Error, syntax: !broadcast [channel] <message>"
return 0
}
set queue [lreplace [chanlist $chan] 0 0]
if {![llength $queue]} {
puthelp "NOTICE $nick :Error, No one in $chan channel right now."
return 0
}
puthelp "NOTICE $nick :Broadcasting message to everyone ([llength $queue] nicks in $chan). Please wait..."
foreach user [lrange $queue 0 [expr {$BroadCast(msgs)-2}]] {
puthelp "PRIVMSG $user :$text (via $nick)"
}
set queue [lrange $queue [expr {$BroadCast(msgs)-1}] end]
if {[llength $queue]} {
utimer $BroadCast(wait) [list broadcast:sendMessage $nick $queue $text]
} else {
puthelp "NOTICE $nick :Broadcast Message Completed."
}
return 0
}
proc broadcast:sendMessage {nick queue text} {
global BroadCast
foreach user [lrange $queue 0 [expr {$BroadCast(msgs)-1}]] {
puthelp "PRIVMSG $user :$text (via $nick)"
}
set queue [lrange $queue $BroadCast(msgs) end]
if {[llength $queue]} {
utimer $BroadCast(wait) [list broadcast:sendMessage $nick $queue $text]
} else {
puthelp "NOTICE $nick :Broadcast Message Completed."
}
}
putlog "broadcast.tcl ver 0.1 by SpiKe^^ loaded."