This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Global Broadcast

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
V
ViciousPiranha
Voice
Posts: 36
Joined: Mon Dec 17, 2012 5:21 am

Post by ViciousPiranha »

Thanks Spike^^, it works now, although it quits due to Excess
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

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
.
V
ViciousPiranha
Voice
Posts: 36
Joined: Mon Dec 17, 2012 5:21 am

Post by ViciousPiranha »

Excess Flood.
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

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: 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)" 
   } 
} 

EDITED: FIXED: Tcl error [broadcast:buildQueue]: wrong # args: should be "incr varName ?increment?"
Last edited by SpiKe^^ on Sun Dec 01, 2013 5:20 pm, edited 3 times in total.
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
V
ViciousPiranha
Voice
Posts: 36
Joined: Mon Dec 17, 2012 5:21 am

Post by ViciousPiranha »

2:13:30] Tcl error [broadcast:buildQueue]: wrong # args: should be "incr varName ?increment?"
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

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
.
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

I like this timer setup a whole lot better, it never has more than 1 utimer running at a time:)

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] 
   } 

} 

SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
V
ViciousPiranha
Voice
Posts: 36
Joined: Mon Dec 17, 2012 5:21 am

Post by ViciousPiranha »

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?
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

Done. try this...

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." 

   } 
} 

SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

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: 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."

Last edited by SpiKe^^ on Sun Dec 08, 2013 1:01 pm, edited 1 time in total.
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
V
ViciousPiranha
Voice
Posts: 36
Joined: Mon Dec 17, 2012 5:21 am

Post by ViciousPiranha »

That works perfectly! Thanks!
Post Reply