<~Justine> !autovoice on
<~Chicken> Autovoice for channel [#massivity] is now [ ON ]
<~Justine> !autovoice off
<~Chicken> Autovoice for channel [#massivity] is now [ OFF ]
==edited==
added onjoin event
on *:text:!autovoice on*:#: {
if ($me !isop $chan) { notice $nick 4 $+ ERROR - I will only function on channels where i am opped | .halt }
if ($nick !isop $chan) { msg $chan 4 $+ ERROR - You are not authorized for this command | .halt }
if (% [ $+ autovoice. $+ [ $chan ] ] == on) { msg $chan 4 $+ ERROR - Autovoice for $chan is already on | .halt }
.set % [ $+ autovoice. $+ [ $chan ] ] on
msg $chan 7Autovoice for channel 2[ $+ $chan $+ ]7 is now [ $+ 9 ON $+ ]
}
on *:text:!autovoice off*:#: {
if ($me !isop $chan) { notice $nick 4 $+ ERROR - I will only function on channels where i am opped | .halt }
if ($nick !isop $chan) { msg $chan 4 $+ ERROR - You are not authorized for this command | .halt }
if (% [ $+ autovoice. $+ [ $chan ] ] == off) { msg $chan 4 $+ ERROR - Autovoice for $chan is already off | .halt }
.set % [ $+ autovoice. $+ [ $chan ] ] off
msg $chan 7Autovoice for channel 2[ $+ $chan $+ ]7 is now [ $+ 4 OFF $+ ]
}
on *:join:#: {
if ($me isop $chan) {
if (% [ $+ autovoice. $+ [ $chan ] ] == on) {
.mode $chan +v $nick
}
}
}
BigSteve, have a read at this link: http://www.hawkee.com/phpBB2/faq.php?mode=bbcode
BigSteve, your example should include a dynamic timer to voice each user in a delay, or else you're running the risk of mode flood. Let's say lots of nick joins in at once or at the same time...the client that runs the code will be doomed without some sort of protection.
on @*:join:#:{
$+(.timer,autov,#,$network,$nick) 1 5 mode # +v $nick - $&
$(|) msg # $nick has been auto voiced. Hello and Welcome to # $nick $+ .
}
P.S. There is yet a /pvoice command that may be useful too.
Like WorldDMT said, using $iif to avoid repetition. But if you don't know much about $iif, you can still use one text with the if-elseif-else statement:
on $*:text:/^!autovoice\so(n|ff)/iS:#:{
if (!%p [ $+ [ # ] ]) {
inc -u5 $+(%,p,#)
if $regml(1) = n {
if !$nick(#,$nick,oh) {
notice $nick 4 $+ ERROR - I will only function on channels where i am opped.
}
elseif (% [ $+ autovoice. $+ [ # ] ] == on) {
msg # $nick 4 $+ ERROR - Autovoice for $chan is already on
}
else {
set % $+ autovoice. $+ # on
msg # $nick 7Autovoice for channel 2[ $+ # $+ ]7 is now [ $+ 9 ON $+ ]
}
}
else {
if !$nick(#,$nick,oh) {
notice $nick 4 $+ ERROR - I will only function on channels where i am opped.
}
elseif (% [ $+ autovoice. $+ [ # ] ] == off) {
msg # $nick 4 $+ ERROR - Autovoice for # is already off.
}
else {
set % $+ autovoice. $+ # off
msg # $nick 7Autovoice for channel 2[ $+ # $+ ]7 is now [ $+ 4 OFF $+ ]
}
}
}
}
And you should really add a trigger control to avoid being spammed or flooded. And I don't see the need to notice and message the channel for op or halfop check at the same time. Lastly, you don't need the evaluation brackets [ ] when setting the dynamic var.