I understand your concern, perhaps I should explain myself and my intentions, I do not want to be taken as a spammer.Sending messages to multiple members of a channel is at the margin a plain spam behavior.
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 itThe 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.
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"
}
}
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] }
}
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
}
}
<nick>, message push completed. Everyone in channel has seen it.
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] }
}
<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.
see, you are no stranger to spelling names either.speechles wrote:[...]Here's one written how caeser suggested[...]
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)"
}
}
caesar wrote:see, you are no stranger to spelling names either.speechles wrote:[...]Here's one written how caeser suggested[...]
Anyway, here's my take on this.It will send 5 PM to the first 5 in the queue, then 10 seconds later to the next 5 and so on.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)" } }
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.
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)"
}
}
Hi Spike^^, after doing that I'm now getting this error:SpiKe^^ wrote:Try this...You will need to make sure the broke bind is not still loaded, try restart.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)" } }
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)"
}
}