src/Plugin.php
public function resolve($url, \GuzzleHttp\Message\Response $data, Event $event, Queue $queue)
    {
        $logger = $this->getLogger();
        $json = json_decode($data->getBody());
        $logger->info('resolve', array('url' => $url, 'json' => $json));

        if (isset($json->error)) {
            return $logger->warning(
                'Query response contained an error',
                array(
                    'url' => $url,
                    'error' => $json->error,
                )
            );
        }

        $entries = $json->items;
        if (!is_array($entries) || !$entries) {
            return $logger->warning(
                'Query returned no results',
                array('url' => $url)
            );
        }

        $entry = reset($entries);
        $replacements = $this->getReplacements($entry);
        $message = str_replace(
            array_keys($replacements),
            array_values($replacements),
            $this->responseFormat
        );
        $queue->ircPrivmsg($event->getSource(), $message);
    }
public function resolve($url, \GuzzleHttp\Message\Response $data, Event $event, Queue $queue)
    {
        $logger = $this->getLogger();
        $json = json_decode($data->getBody());
        $logger->info('resolve', array('url' => $url, 'json' => $json));

        if (isset($json->error)) {
            return $logger->warning(
                'Query response contained an error',
                array(
                    'url' => $url,
                    'error' => $json->error,
                )
            );
        }

        $entries = $json->items;
        if (!is_array($entries) || !$entries) {
            return $logger->warning(
                'Query returned no results',
                array('url' => $url)
            );
        }

        $entry = reset($entries);
        $replacements = $this->getReplacements($entry);
        $message = str_replace(
            array_keys($replacements),
            array_values($replacements),
            $this->responseFormat
        );
        $queue->ircPrivmsg($event->getSource(), $message);
    }
Handles a successful request for video data.

@param string $url URL of the request
@param \GuzzleHttp\Message\Response $data Response body
@param \Phergie\Irc\EventInterface $event
@param \Phergie\Irc\Bot\React\EventQueueInterface $queue