public function registerTriggers($triggers, $channel)
    {
        if (!is_array($triggers)) {
            $triggers = array($triggers);
        }

        $fmt        = $this->getFormatter(false);
        $translator = $fmt->getTranslator();
        if (!is_string($channel)) {
            throw new \Erebot\InvalidValueException($fmt->_('Invalid channel'));
        }

        $scopes = array(
            $channel => $translator->_(
                'A trigger named "<var name="trigger"/>" '.
                'has already been registered on channel <var name="chan"/>.'
            ),
            self::MATCH_ANY => $translator->_(
                'A trigger named "<var name="trigger"/>" '.
                'has already been registered globally.'
            ),
        );

        foreach ($triggers as $trigger) {
            foreach ($scopes as $scope => $error) {
                if (isset($this->triggers[$scope])) {
                    if ($this->containsRecursive($this->triggers[$scope], $trigger)) {
                        $this->logger and $this->logger->info(
                            $fmt->render(
                                $error,
                                array(
                                    'trigger' => $trigger,
                                    'chan' => $channel,
                                )
                            )
                        );
                        return null;
                    }
                }
            }
        }

        $this->triggers[$channel][] = $triggers;
        end($this->triggers[$channel]);
        return $channel.' '.key($this->triggers[$channel]);
    }
public function registerTriggers($triggers, $channel)
    {
        if (!is_array($triggers)) {
            $triggers = array($triggers);
        }

        $fmt        = $this->getFormatter(false);
        $translator = $fmt->getTranslator();
        if (!is_string($channel)) {
            throw new \Erebot\InvalidValueException($fmt->_('Invalid channel'));
        }

        $scopes = array(
            $channel => $translator->_(
                'A trigger named "<var name="trigger"/>" '.
                'has already been registered on channel <var name="chan"/>.'
            ),
            self::MATCH_ANY => $translator->_(
                'A trigger named "<var name="trigger"/>" '.
                'has already been registered globally.'
            ),
        );

        foreach ($triggers as $trigger) {
            foreach ($scopes as $scope => $error) {
                if (isset($this->triggers[$scope])) {
                    if ($this->containsRecursive($this->triggers[$scope], $trigger)) {
                        $this->logger and $this->logger->info(
                            $fmt->render(
                                $error,
                                array(
                                    'trigger' => $trigger,
                                    'chan' => $channel,
                                )
                            )
                        );
                        return null;
                    }
                }
            }
        }

        $this->triggers[$channel][] = $triggers;
        end($this->triggers[$channel]);
        return $channel.' '.key($this->triggers[$channel]);
    }
public function registerTriggers ( $ triggers , $ channel ) { if ( ! is_array ( $ triggers ) ) { $ triggers = array ( $ triggers ) ; } $ fmt = $ this -> getFormatter ( false ) ; $ translator = $ fmt -> getTranslator ( ) ; if ( ! is_string ( $ channel ) ) { throw new \ Erebot \ InvalidValueException ( $ fmt -> _ ( 'Invalid channel' ) ) ; } $ scopes = array ( $ channel => $ translator -> _ ( 'A trigger named "<var name="trigger"/>" ' . 'has already been registered on channel <var name="chan"/>.' ) , self :: MATCH_ANY => $ translator -> _ ( 'A trigger named "<var name="trigger"/>" ' . 'has already been registered globally.' ) , ) ; foreach ( $ triggers as $ trigger ) { foreach ( $ scopes as $ scope => $ error ) { if ( isset ( $ this -> triggers [ $ scope ] ) ) { if ( $ this -> containsRecursive ( $ this -> triggers [ $ scope ] , $ trigger ) ) { $ this -> logger and $ this -> logger -> info ( $ fmt -> render ( $ error , array ( 'trigger' => $ trigger , 'chan' => $ channel , ) ) ) ; return null ; } } } } $ this -> triggers [ $ channel ] [ ] = $ triggers ; end ( $ this -> triggers [ $ channel ] ) ; return $ channel . ' ' . key ( $ this -> triggers [ $ channel ] ) ; }
Registers a series of triggers, either globally
or for a specific channel.

\param mixed $triggers
Either a single string or an array of strings
with the names of the triggers to register.

\param string $channel
Either the name of a specific IRC channel
the triggers should be registered for (eg. #Erebot),
or the constant Erebot::Module::TriggerRegistry::MATCH_ANY
to register them globally (for all channels).

\retval mixed
Either a string which acts as a key to later
unregister the triggers at a later time
(see Erebot::Module::TriggerRegistry::freeTriggers),
or \b null if the triggers could not be registered
(eg. because they conflict with other already
registered triggers).

\warning
Triggers should only contain alphanumeric characters
(characters from the range a-z or 0-9), should not
contain spaces or prefixes (eg. "!"), and are
case-insensitive.
Registers a series of triggers either globally or for a specific channel .