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

Global Broadcast

Post by ViciousPiranha »

Hello.

I am looking for a script that would act like a network broadcast service but for a specific chat room.

When typed !broadcast <channel here> <message here>

The bot will than one by one, notice all the users in the specific chat room with that specific message.

Of course this must have some sort of flood protection so that bot won't quit due to excess flood

Thank you!
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

What exactly do you want to get out of this?

Sending messages to multiple members of a channel is at the margin a plain spam behavior. I'm not 100% confident on your intentions, but anyway, all boils down to the number of members the specific channel has cos every server has it's own built in flood protection mechanism that would prevent this sort of unwanted behavior, meaning spam.

Even if where to use puthelp I honestly doubt the bot won't flood itself off shortly if the list is big enough. The only option left I guess would be to send in bursts. For instance, if the channel has 100 members, and the servers allows a member to send just 10 messages per 10 seconds, then send the first 10 messages as allowed, and the rest send in batches of 10 after another 10 seconds and so on until the queue is finished.

I think I gave you more than enough information on how to achieve this, the only reason I'm not going further is that, like I've previously said, sound like a spam behavior and this is unacceptable and I won't take part in this.
Once the game is over, the king and the pawn go back in the same box.
V
ViciousPiranha
Voice
Posts: 36
Joined: Mon Dec 17, 2012 5:21 am

Post by ViciousPiranha »

Hello caesar
Sending messages to multiple members of a channel is at the margin a plain spam behavior.
I understand your concern, perhaps I should explain myself and my intentions, I do not want to be taken as a spammer.

I run a rather friendly chat room with a bunch of 40-45 regular users who pretty much know each other as we are all fairly active and some of the users even meet each other irl and quite often we either run events such as meetings and playing games online, sometimes we (the chat room) would like to get as many users attentions as possible, but it just seems that even when using other methods such as topic updates, repeating messages and etc, only when a user receives a private message or a NOTICE does he actually pay attention and we found it to be a good way to reach everyone and pay a more 'personal' attention (notice/msg each user asking him if he's going to participate in the event) to each user.
The only option left I guess would be to send in bursts. For instance, if the channel has 100 members, and the servers allows a member to send just 10 messages per 10 seconds, then send the first 10 messages as allowed, and the rest send in batches of 10 after another 10 seconds and so on until the queue is finished.
That sounds just fine really, its way better than messaging/sending out a notice to each and every one manually, the message doesn't have to reach out everyone at the exact same time as long as it will reach out to whoever is attending the chat room when we broadcast it
w
willyw
Revered One
Posts: 1203
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

Experiment with this.


Code: Select all


# July 6, 2013

# http://forum.egghelp.org/viewtopic.php?t=19467

##When typed !broadcast <channel here> <message here>

##The bot will than one by one, notice all the users in the specific chat room with that specific message.

##Of course this must have some sort of flood protection so that bot won't quit due to excess flood
###############



# As it is right now, with     bind pub n       , script will respond only to bot owners.

# Usage:
# !broadcast <text>


bind pub n "!broadcast" notice_to_all



proc notice_to_all {nick uhost handle chan text} {


   foreach user [chanlist $chan] {
     putserv "notice $user :$text"
    }

}

Reference:
http://www.eggheads.org/support/egghtml ... mands.html
and
http://www.tcl.tk/man/tcl8.5/TclCmd/foreach.htm
if you want to know what is going on. Perhaps you want to change something.


About flooding:
I believe that queuing is built into Eggdrop, and implemented when using putserv.

Test it. In a channel of yours, with more than 5 users present.
I suspect that the first 5 will all get their notices at the same time, and from then on, one user every couple seconds.

For simplicity, this script does not need to be told what channel.
Whatever channel you are in, when you do:
!broadcast <text to notice to every user>
will be the channel that the user list will come from.
Is it a requirement that you be able to specify the channel?




I hope this helps.
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Code: Select all

bind pub n !alert pushNicks

proc pushNicks {n u h c t} {
	if {[info exists ::queuedNicks]} {
		putserv "notice $n :$n, there is still a queue of [llength $::queuedNicks] nicknames that need to see the previous message, please wait a bit and I will announce when I am completed." -next
	} else {
		# start at 1 to avoid sending a message to the botnick itself
		set ::queuedNicks [lrange [chanlist $c] 1 end]
		puthelp "privmsg $c :$n, pushing your message to everyone in channel. Please be patient."
		popNicks $t $n
	}
}

proc popNicks {t n} {
	foreach nick [lrange $::queuedNicks 0 4] {
		puthelp "notice $nick :$t (via $n)"
	}
	if {![llength [set ::queuedNicks [lrange $::queuedNicks 5 end]]]} {
		puthelp "privmsg $c :$n, message push completed. Everyone in channel has seen it."
		unset ::queuedNicks
	} else { utimer 20 [list popNicks $t $n] }
}
Here's one written how caeser suggested, using a first-in,first-out (fifo) queue system. It will spew to 5 nicks, then wait 20 seconds, spew 5 more, etc...
V
ViciousPiranha
Voice
Posts: 36
Joined: Mon Dec 17, 2012 5:21 am

Post by ViciousPiranha »

Thank you for your understanding speechles.

Code: Select all

bind pub n !alert pushNicks 

proc pushNicks {n u h c t} { 
   if {[info exists ::queuedNicks]} { 
      putserv "notice $n :$n, there is still a queue of [llength $::queuedNicks] nicknames that need to see the previous message, please wait a bit and I will announce when I am completed." -next 
   } else { 
      # start at 1 to avoid sending a message to the botnick itself 
      set ::queuedNicks [lrange [chanlist $c] 1 end] 
      puthelp "privmsg $c :$n, pushing your message to everyone in channel. Please be patient." 
      popNicks $t $n 
   } 
}
I loaded the script and it indeed sent out the notices, one issue though, even when trying on a small amount of users (2), the script seems to freeze after sending out all the notices:

<+Vicious> !alert Testing speechles script
-FriendlyBot-Vicious, there is still a queue of 0 nicknames that need to see the previous message, please wait a bit and I will announce when I am completed.

I waited and nothing changed
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

Did it ever post this line to the channel?
<nick>, message push completed. Everyone in channel has seen it.
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 »

PostPosted: Sun Jul 07, 2013 12:00 pm Post subject:
Did it ever post this line to the channel?
Quote:
<nick>, message push completed. Everyone in channel has seen it.
no it did not
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Code: Select all

bind pub n !alert pushNicks
bind pub n !killalert killNicks

proc killNicks {n u h c t} {
   if {[info exists ::queuedNicks]} {
      putserv "privmsg $c :$n, erased alert queue of [llength $::queuedNicks] nicknames."
      unset ::queuedNicks
   } else {
      putserv "privmsg $c :$n, there isn't a queue active. The alert is already killed."
   }
}

proc pushNicks {n u h c t} {
   if {[info exists ::queuedNicks]} {
      putserv "notice $n :$n, there is still a queue of [llength $::queuedNicks] nicknames that need to see the previous message, please wait a bit and I will announce when I am completed." -next
   } else {
      # start at 1 to avoid sending a message to the botnick itself
      set ::queuedNicks [lrange [chanlist $c] 1 end]
      puthelp "privmsg $c :$n, pushing your message to everyone in channel. Please be patient."
      popNicks $t $n $c
   }
}

proc popNicks {t n c} {
   foreach nick [lrange $::queuedNicks 0 4] {
      puthelp "notice $nick :$t (via $n)"
   }
   if {![llength [set ::queuedNicks [lrange $::queuedNicks 5 end]]]} {
      puthelp "privmsg $c :$n, message push completed. Everyone in channel has seen it."
      unset ::queuedNicks
   } else { utimer 20 [list popNicks $t $n $c] }
}
oops... I forgot to include $c in the passed arguments to popNicks. How can it message that channel when the push is complete otherwise..DOH!

also added !killalert which will erase and unset the queue if you need to manually reset it ever.
<speechles> !alert does this work now?
<bot> speechles, pushing your message to everyone in channel. Please be patient.
-bot- does this work now? (via speechles)
<bot> speechles, message push completed. Everyone in channel has seen it.
<speechles> !killalert
<bot> speechles, there isn't a queue active. The alert is already killed.
V
ViciousPiranha
Voice
Posts: 36
Joined: Mon Dec 17, 2012 5:21 am

Post by ViciousPiranha »

Awesome speechles! thanks oh so very much!
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

speechles wrote:[...]Here's one written how caeser suggested[...]
see, you are no stranger to spelling names either. :roll: :lol:

Anyway, here's my take on this.

Code: Select all

bind pub n !broadcast pub:buildQueue

proc broadcast:buildQueue {nick uhost hand chan text} {
	if {![llength $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 [lrange $text 1 end]
	}
	set users [lreplace [chanlist $chan] 0 0]
	while {[llength $users] != 0} {
	incr time 10
		utimer $time [list broadcast:sendMessage $nick [lrange $users 0 5] $text]
		set users [lrange $users 6 end]
	}
}
	
proc broadcast:sendMessage {sender queue text} {
	foreach user [split $queue] {
		puthelp "PRIVMSG $user :$text (via $sender)"
	}
}
It will send 5 PM to the first 5 in the queue, then 10 seconds later to the next 5 and so on.

The !broadcast accepts a different channel than the one you issue the command, if a channel is not given will use the current one to make it's queue.

Haven't tested anything. :P
Once the game is over, the king and the pawn go back in the same box.
V
ViciousPiranha
Voice
Posts: 36
Joined: Mon Dec 17, 2012 5:21 am

Post by ViciousPiranha »

caesar wrote:
speechles wrote:[...]Here's one written how caeser suggested[...]
see, you are no stranger to spelling names either. :roll: :lol:

Anyway, here's my take on this.

Code: Select all

bind pub n !broadcast pub:buildQueue

proc broadcast:buildQueue {nick uhost hand chan text} {
	if {![llength $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 [lrange $text 1 end]
	}
	set users [lreplace [chanlist $chan] 0 0]
	while {[llength $users] != 0} {
	incr time 10
		utimer $time [list broadcast:sendMessage $nick [lrange $users 0 5] $text]
		set users [lrange $users 6 end]
	}
}
	
proc broadcast:sendMessage {sender queue text} {
	foreach user [split $queue] {
		puthelp "PRIVMSG $user :$text (via $sender)"
	}
}
It will send 5 PM to the first 5 in the queue, then 10 seconds later to the next 5 and so on.

The !broadcast accepts a different channel than the one you issue the command, if a channel is not given will use the current one to make it's queue.

Haven't tested anything. :P

Hi, I'm getting this error:

[19:09:30] Tcl error [pub:buildQueue]: invalid command name "pub:buildQueue"
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

Try this...

Code: Select all

bind pub n !broadcast broadcast:buildQueue 

proc broadcast:buildQueue {nick uhost hand chan text} { 
   if {![llength $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 [lrange $text 1 end] 
   } 
   set users [lreplace [chanlist $chan] 0 0] 
   while {[llength $users] != 0} { 
   incr time 10 
      utimer $time [list broadcast:sendMessage $nick [lrange $users 0 5] $text] 
      set users [lrange $users 6 end] 
   } 
} 
    
proc broadcast:sendMessage {sender queue text} { 
   foreach user [split $queue] { 
      puthelp "PRIVMSG $user :$text (via $sender)" 
   } 
}

You will need to make sure the broke bind is not still loaded, try restart.
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 »

SpiKe^^ wrote:Try this...

Code: Select all

bind pub n !broadcast broadcast:buildQueue 

proc broadcast:buildQueue {nick uhost hand chan text} { 
   if {![llength $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 [lrange $text 1 end] 
   } 
   set users [lreplace [chanlist $chan] 0 0] 
   while {[llength $users] != 0} { 
   incr time 10 
      utimer $time [list broadcast:sendMessage $nick [lrange $users 0 5] $text] 
      set users [lrange $users 6 end] 
   } 
} 
    
proc broadcast:sendMessage {sender queue text} { 
   foreach user [split $queue] { 
      puthelp "PRIVMSG $user :$text (via $sender)" 
   } 
}

You will need to make sure the broke bind is not still loaded, try restart.
Hi Spike^^, after doing that I'm now getting this error:

[20:25:16] Tcl error [broadcast:buildQueue]: can't read "time": no such variable
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

It was trying to increment a variable that doesn't exist:)
and a few other more minor issues. Try this...

Code: Select all

bind pub n !broadcast broadcast:buildQueue 

proc broadcast:buildQueue {nick uhost hand chan text} { 
   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
   }

   broadcast:sendMessage $nick [lrange $users 0 4] $text
   set users [lrange $users 5 end]
   set time 0

   while {[llength $users] > 0} { 
      incr time 10 
      utimer $time [list broadcast:sendMessage $nick [lrange $users 0 4] $text] 
      set users [lrange $users 5 end] 
   } 
} 
    
proc broadcast:sendMessage {sender queue text} { 
   foreach user [split $queue] { 
      puthelp "PRIVMSG $user :$text (via $sender)" 
   } 
} 

SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
Post Reply