| View previous topic :: View next topic |
| Author |
Message |
ViciousPiranha Voice
Joined: 17 Dec 2012 Posts: 36
|
Posted: Sun Dec 01, 2013 4:22 pm Post subject: |
|
|
| Thanks Spike^^, it works now, although it quits due to Excess |
|
| Back to top |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 792 Location: Tennessee, USA
|
Posted: Sun Dec 01, 2013 4:32 pm Post subject: |
|
|
How's that? Excess what?
Looks like it might take a long time to get it done, but that it would finish. _________________ SpiKe^^
Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
. |
|
| Back to top |
|
 |
ViciousPiranha Voice
Joined: 17 Dec 2012 Posts: 36
|
Posted: Sun Dec 01, 2013 4:40 pm Post subject: |
|
|
| Excess Flood. |
|
| Back to top |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 792 Location: Tennessee, USA
|
Posted: Sun Dec 01, 2013 5:05 pm Post subject: |
|
|
That's just it's numbers of 5 sends every 10 seconds need a little tweeking.
Try playing with the new settings in this one...
| Code: |
# 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)"
}
}
|
EDITED: FIXED: Tcl error [broadcast:buildQueue]: wrong # args: should be "incr varName ?increment?" _________________ SpiKe^^
Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
Last edited by SpiKe^^ on Sun Dec 01, 2013 5:20 pm; edited 3 times in total |
|
| Back to top |
|
 |
ViciousPiranha Voice
Joined: 17 Dec 2012 Posts: 36
|
Posted: Sun Dec 01, 2013 5:13 pm Post subject: |
|
|
| 2:13:30] Tcl error [broadcast:buildQueue]: wrong # args: should be "incr varName ?increment?" |
|
| Back to top |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 792 Location: Tennessee, USA
|
Posted: Sun Dec 01, 2013 5:17 pm Post subject: |
|
|
Sorry, fixed that issue in the last posted script above. _________________ SpiKe^^
Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
. |
|
| Back to top |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 792 Location: Tennessee, USA
|
Posted: Sun Dec 01, 2013 5:34 pm Post subject: |
|
|
I like this timer setup a whole lot better, it never has more than 1 utimer running at a time:)
| Code: |
# 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]
}
}
|
_________________ SpiKe^^
Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
. |
|
| Back to top |
|
 |
ViciousPiranha Voice
Joined: 17 Dec 2012 Posts: 36
|
Posted: Sun Dec 01, 2013 5:35 pm Post subject: |
|
|
That seems to work great Spike^^
Thank you very much.
I do not suppose you can add some sort of message to indicate that every message was sent out and the round was completed? |
|
| Back to top |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 792 Location: Tennessee, USA
|
Posted: Sun Dec 01, 2013 5:55 pm Post subject: |
|
|
Done. try this...
| Code: |
# 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."
}
}
|
_________________ SpiKe^^
Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
. |
|
| Back to top |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 792 Location: Tennessee, USA
|
Posted: Sun Dec 01, 2013 9:50 pm Post subject: |
|
|
This one seems more done.
Adds a private message command to do the same thing.
Adds protection against starting more than 1 broadcast at a time.
Cleaned up the script replies some.
Gave the script a name and version number.
| Code: |
# 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."
|
_________________ SpiKe^^
Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
Last edited by SpiKe^^ on Sun Dec 08, 2013 1:01 pm; edited 1 time in total |
|
| Back to top |
|
 |
ViciousPiranha Voice
Joined: 17 Dec 2012 Posts: 36
|
Posted: Mon Dec 02, 2013 11:13 am Post subject: |
|
|
| That works perfectly! Thanks! |
|
| Back to top |
|
 |
|