/**
  * Generates the chanmode/prefix maps and enables NAMESX if supported.
  *
  * @param \Phergie\Irc\Event\ServerEventInterface $event
  * @param \Phergie\Irc\Bot\React\EventQueueInterface $queue
  */
 public function processCapabilities(ServerEventInterface $event, EventQueueInterface $queue)
 {
     $connection = $event->getConnection();
     $logger = $this->getLogger();
     $store = $this->connectionStore;
     if (!$store->contains($connection)) {
         $store->attach($connection, new \ArrayObject());
     }
     foreach ($event->getParams()['iterable'] as $param) {
         if ($param == 'NAMESX') {
             $queue->ircProtoctl('NAMESX');
         } elseif (preg_match('/^CHANMODES=([^,]*),((?1)),((?1)),((?1))$/', $param, $matches)) {
             $logger->debug('Parsing chanmode types from RPL_ISUPPORT');
             $chanModeTypes = [];
             foreach (array(1 => self::CHANMODE_TYPE_LIST, 2 => self::CHANMODE_TYPE_PARAM_ALWAYS, 3 => self::CHANMODE_TYPE_PARAM_SETONLY, 4 => self::CHANMODE_TYPE_NOPARAM) as $index => $type) {
                 if (!empty($matches[$index])) {
                     $chanModeTypes += array_fill_keys(str_split($matches[$index]), $type);
                 }
             }
             if (!empty($store[$connection]['modes'])) {
                 $chanModeTypes += $store[$connection]['modes'];
             }
             $store[$connection]['modes'] = $chanModeTypes;
         } elseif (preg_match('/^PREFIX=\\((\\S+)\\)(\\S+)$/', $param, $matches) && strlen($matches[1]) == strlen($matches[2])) {
             $logger->debug('Parsing prefixes from RPL_ISUPPORT');
             $prefixModes = str_split($matches[1]);
             $store[$connection]['prefixes'] = array_combine(str_split($matches[2]), $prefixModes);
             $chanModeTypes = array_fill_keys($prefixModes, self::CHANMODE_TYPE_PARAM_ALWAYS);
             if (!empty($store[$connection]['modes'])) {
                 $chanModeTypes += $store[$connection]['modes'];
             }
             $store[$connection]['modes'] = $chanModeTypes;
         }
     }
 }