| View previous topic :: View next topic |
| Author |
Message |
ViciousPiranha Voice
Joined: 17 Dec 2012 Posts: 36
|
Posted: Sat Jul 06, 2013 6:03 am Post subject: Global Broadcast |
|
|
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! |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Sat Jul 06, 2013 8:17 am Post subject: |
|
|
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. |
|
| Back to top |
|
 |
ViciousPiranha Voice
Joined: 17 Dec 2012 Posts: 36
|
Posted: Sat Jul 06, 2013 5:33 pm Post subject: |
|
|
Hello caesar
| Quote: | | 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.
| Quote: | | 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 |
|
| Back to top |
|
 |
willyw Revered One
Joined: 15 Jan 2009 Posts: 1175
|
Posted: Sat Jul 06, 2013 8:31 pm Post subject: |
|
|
Experiment with this.
| Code: |
# 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/1.6.21/tcl-commands.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. |
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Sat Jul 06, 2013 9:14 pm Post subject: |
|
|
| Code: | 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... _________________ speechles' eggdrop tcl archive |
|
| Back to top |
|
 |
ViciousPiranha Voice
Joined: 17 Dec 2012 Posts: 36
|
Posted: Sun Jul 07, 2013 2:52 am Post subject: |
|
|
Thank you for your understanding speechles.
| Code: | 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 |
|
| Back to top |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 792 Location: Tennessee, USA
|
Posted: 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. |
_________________ 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 Jul 07, 2013 6:27 pm Post subject: |
|
|
| Quote: | 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 |
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Sun Jul 07, 2013 9:10 pm Post subject: |
|
|
| Code: | 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.
| Quote: | <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. |
_________________ speechles' eggdrop tcl archive |
|
| Back to top |
|
 |
ViciousPiranha Voice
Joined: 17 Dec 2012 Posts: 36
|
Posted: Mon Jul 08, 2013 2:49 am Post subject: |
|
|
| Awesome speechles! thanks oh so very much! |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Mon Jul 08, 2013 4:04 am Post subject: |
|
|
| speechles wrote: | | [...]Here's one written how caeser suggested[...] |
see, you are no stranger to spelling names either.
Anyway, here's my take on this.
| Code: |
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.  _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
ViciousPiranha Voice
Joined: 17 Dec 2012 Posts: 36
|
Posted: Sun Dec 01, 2013 2:12 pm Post subject: |
|
|
| caesar wrote: | | speechles wrote: | | [...]Here's one written how caeser suggested[...] |
see, you are no stranger to spelling names either.
Anyway, here's my take on this.
| Code: |
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.  |
Hi, I'm getting this error:
[19:09:30] Tcl error [pub:buildQueue]: invalid command name "pub:buildQueue" |
|
| Back to top |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 792 Location: Tennessee, USA
|
Posted: Sun Dec 01, 2013 3:13 pm Post subject: |
|
|
Try this...
| Code: |
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
. |
|
| Back to top |
|
 |
ViciousPiranha Voice
Joined: 17 Dec 2012 Posts: 36
|
Posted: Sun Dec 01, 2013 3:25 pm Post subject: |
|
|
| SpiKe^^ wrote: | Try this...
| Code: |
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 |
|
| Back to top |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 792 Location: Tennessee, USA
|
Posted: Sun Dec 01, 2013 4:10 pm Post subject: |
|
|
It was trying to increment a variable that doesn't exist:)
and a few other more minor issues. Try this...
| Code: |
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
. |
|
| Back to top |
|
 |
|
|
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
|
|