egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Global Broadcast
Goto page Previous  1, 2
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
ViciousPiranha
Voice


Joined: 17 Dec 2012
Posts: 36

PostPosted: Sun Dec 01, 2013 4:22 pm    Post subject: Reply with quote

Thanks Spike^^, it works now, although it quits due to Excess
Back to top
View user's profile Send private message
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 792
Location: Tennessee, USA

PostPosted: Sun Dec 01, 2013 4:32 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
ViciousPiranha
Voice


Joined: 17 Dec 2012
Posts: 36

PostPosted: Sun Dec 01, 2013 4:40 pm    Post subject: Reply with quote

Excess Flood.
Back to top
View user's profile Send private message
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 792
Location: Tennessee, USA

PostPosted: Sun Dec 01, 2013 5:05 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
ViciousPiranha
Voice


Joined: 17 Dec 2012
Posts: 36

PostPosted: Sun Dec 01, 2013 5:13 pm    Post subject: Reply with quote

2:13:30] Tcl error [broadcast:buildQueue]: wrong # args: should be "incr varName ?increment?"
Back to top
View user's profile Send private message
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 792
Location: Tennessee, USA

PostPosted: Sun Dec 01, 2013 5:17 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 792
Location: Tennessee, USA

PostPosted: Sun Dec 01, 2013 5:34 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
ViciousPiranha
Voice


Joined: 17 Dec 2012
Posts: 36

PostPosted: Sun Dec 01, 2013 5:35 pm    Post subject: Reply with quote

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
View user's profile Send private message
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 792
Location: Tennessee, USA

PostPosted: Sun Dec 01, 2013 5:55 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 792
Location: Tennessee, USA

PostPosted: Sun Dec 01, 2013 9:50 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
ViciousPiranha
Voice


Joined: 17 Dec 2012
Posts: 36

PostPosted: Mon Dec 02, 2013 11:13 am    Post subject: Reply with quote

That works perfectly! Thanks!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber