<commit_before><?php
/**
 * Phergie (http://phergie.org)
 *
 * @link https://github.com/phergie/phergie-irc-plugin-react-thefuckingweather for the canonical source repository
 * @copyright Copyright (c) 2008-2014 Phergie Development Team (http://phergie.org)
 * @license http://phergie.org/license New BSD License
 * @package Phergie\Irc\Plugin\React\TheFuckingWeather
 */

namespace Phergie\Irc\Plugin\React\TheFuckingWeather;

use Phergie\Irc\Bot\React\AbstractPlugin;
use Phergie\Irc\Bot\React\EventQueueInterface as Queue;
use Phergie\Irc\Plugin\React\Command\CommandEvent as Event;
use WyriHaximus\Phergie\Plugin\Http\Request as HttpRequest;

/**
 * Plugin for providing weather information from thefuckingweather.com.
 *
 * @category Phergie
 * @package Phergie\Irc\Plugin\React\TheFuckingWeather
 */
class Plugin extends AbstractPlugin
{
    /**
     * Indicates that the plugin monitors events for a "thefuckingweather"
     * event emitted by the Command plugin and a corresponding event for a
     * "help" command emitted by the CommandHelp plugin.
     *
     * @return array
     */
    public function getSubscribedEvents()
    {
        return array(
            'command.thefuckingweather' => 'handleCommand',
            'command.thefuckingweather.help' => 'handleHelp',
        );
    }

    /**
     * Returns weather information for a given location.
     *
     * @param \Phergie\Irc\Plugin\React\Command\CommandEvent $event
     * @param \Phergie\Irc\Bot\React\EventQueueInterface $queue
     */
    public function handleCommand(Event $event, Queue $queue)
    {
        $params = $event->getCustomParams();
        if (!$params) {
            return $this->handleHelp($event, $queue);
        }

        $where = reset($params);
        $url = 'http://www.thefuckingweather.com/?where=' . urlencode($where);

        $self = $this;
        $request = new HttpRequest(array(
            'url' => $url,
            'resolveCallback' => function($data) use ($self, $event, $queue) {
                $self->resolve($data, $event, $queue);<commit_msg>Commented out help event temporarily for testing purposes<commit_after><?php
/**
 * Phergie (http://phergie.org)
 *
 * @link https://github.com/phergie/phergie-irc-plugin-react-thefuckingweather for the canonical source repository
 * @copyright Copyright (c) 2008-2014 Phergie Development Team (http://phergie.org)
 * @license http://phergie.org/license New BSD License
 * @package Phergie\Irc\Plugin\React\TheFuckingWeather
 */

namespace Phergie\Irc\Plugin\React\TheFuckingWeather;

use Phergie\Irc\Bot\React\AbstractPlugin;
use Phergie\Irc\Bot\React\EventQueueInterface as Queue;
use Phergie\Irc\Plugin\React\Command\CommandEvent as Event;
use WyriHaximus\Phergie\Plugin\Http\Request as HttpRequest;

/**
 * Plugin for providing weather information from thefuckingweather.com.
 *
 * @category Phergie
 * @package Phergie\Irc\Plugin\React\TheFuckingWeather
 */
class Plugin extends AbstractPlugin
{
    /**
     * Indicates that the plugin monitors events for a "thefuckingweather"
     * event emitted by the Command plugin and a corresponding event for a
     * "help" command emitted by the CommandHelp plugin.
     *
     * @return array
     */
    public function getSubscribedEvents()
    {
        return array(
            'command.thefuckingweather' => 'handleCommand',
            // 'command.thefuckingweather.help' => 'handleHelp',
        );
    }

    /**
     * Returns weather information for a given location.
     *
     * @param \Phergie\Irc\Plugin\React\Command\CommandEvent $event
     * @param \Phergie\Irc\Bot\React\EventQueueInterface $queue
     */
    public function handleCommand(Event $event, Queue $queue)
    {
        $params = $event->getCustomParams();
        if (!$params) {
            return $this->handleHelp($event, $queue);
        }

        $where = reset($params);
        $url = 'http://www.thefuckingweather.com/?where=' . urlencode($where);

        $self = $this;
        $request = new HttpRequest(array(
            'url' => $url,
            'resolveCallback' => function($data) use ($self, $event, $queue) {
                $self->resolve($data, $event, $queue);
{'fraction_non_alphanumeric': 0.12228325770241223, 'fraction_numerical': 0.0038213518032003822, 'mean_word_length': 2.992373689227836, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4252397', 'n_tokens_mistral': 1296, 'n_tokens_neox': 1249, 'n_words': 290}