This a broadcast script for bots, it's like an amsg but broadcast means to send out information by a bot.
Command:
$broadcast [message]
The command is only for operators, but you can fix that if not /q me
;-----------------------------------------------------------------------------------
; Broadcast by Andreas Moen a.k.a xelent
; xelent@online.no;
; 13:37 15. December 2007;
;-----------------------------------------------------------------------------------
on *:TEXT:$broadcast *:#:{
if ($nick isop $chan) {
Var %x = 1, %y = $Chan(0)
Var %z = #chan #chan #chan
While (%x <= %y) {
If ($Chan(%x) !isin %z) {
Msg $Chan(%x) (Broadcast) $2-
}
Inc %x
}
}
else {
.notice $nick You don't have access for this command.
}
}
Woah man. Nobody complained once.
One of the main purposes of this snippet repository is for scriptors to get feedback on the code they share.
If you are not open to comments like those above than you should probably rethink posting here because you will always get them.
Nobody said it didnt work, we merely suggested ways of improving it.
What would you think about maybe killing the %z = line and add on on load and menu option that uses a goto loop to add channels to the %z variable
for instance
on *:load:{ setchannels }
alias setchannels {
if ($input(Would you like to add a channel?,y,Add a channel) == $true) {
:addanother
var %tmptmp = #$$?=\"Enter the channel name to be added.\"
if (%tmptmp != $null) && ($istok(%z,%tmptmp,32) != $true) {
%z = $addtok(%z,%tmptmp,32)
}
if ($input(Would you like to add another channel?,y,Add a channel) == $true) { goto addanother }
}
}
This seems sloppy to me but i tried a while ($input() != $true) line and it wouldnt work for me.
Honestly tho Im just trying to convey my idea, not make the best code I can.
Anyhoo then you could maybe even add a..
menu channel,query,status,nicklist { Set $chr(36) $+ Broadcast Channels:setchannels }
It did occur to me that you might also want to include a removechannels alias but making that from the example above would be pretty easy and im only trying to convey an idea here.
Var %z = #chan #chan #chan
I would say in the description that people need to put exception channels in there.
If ($Chan(%x) !isin %z) {
I would use !$istok rather than !isin, because a restricted channel could be #test123 and #test would match. If you don\'t know what $istok does, it\'ll check if $chan(%x) matches one of the tokens in the %z variable (each channel in this case).