Enable

From Scriptwiki
(Redirected from Disable)
Jump to: navigation, search

Enables or disables the specified groups in all scripts.

/enable <group1 group2 ... groupN>
/disable <group1 group2 ... groupN>

You can also specify a wildcard to enable/disable all matching groups.

Example

/enable #one #two #three

Enables groups #one, #two and #three within any loaded scripts.

/disable #help*

Disables all groups starting with the word help.

The example below shows how to enable or disable a block of code (menu item in this example) only when #my_channel is active.

;Trigger when a windows focus is changed.
on *:active:*: {
  ;If #my_channel is the channel that is now the active window, enable the group.
  if ($active == #my_channel) .enable #MyChannelActive 
  ;Else if #my_channel is the last active channel disable the group.
  elseif ($lactive == #my_channel) .disable #MyChannelActive
}

#MyChannelActive off
menu channel,nick {
  My Menu Option: DoCommand
}

;You can put your commands or other events in the group also.
alias -l DoCommand { echo -ag We've done the command. }
#MyChannelActive end 

Note

You can not break up an event with a group, you can only put whole events in a group. Below is an example of broken code:

on *:text:hello:#: {
  #Anti-Spam on
  disable #Anti-Spam
  msg # Hello $nick
  #Anti-Spam end
  .timerANTISPAM 1 5 enable #Anti-Spam
}

The above code is incorrect, below is an example of how to correctly use groups in this fashion.

#Anti-Spam on
on *:text:hello:#: {
  disable #Anti-Spam
  msg # Hello $nick
  .timerANTISPAM 1 5 enable #Anti-Spam
}
#Anti-Spam end

Note that although you're disable a group from inside the same group you're disabling the rest of the code block continues to execute. When you disable a group it stops the events from triggering, although the already triggered groups continue as if the groups enabled.

See Also