Bot-Cobalt-Plugin-Weather

 view release on metacpan or  search on metacpan

lib/Bot/Cobalt/Plugin/Weather.pm  view on Meta::CPAN


        pwx_error
        pwx_weather
        pwx_forecast
      / ],
    ],
  );

  register( $self, SERVER =>
    'public_cmd_wx',
    'wx_timer_expire_item',
  );

  logger->info("Loaded: wx");

  PLUGIN_EAT_NONE
}

sub Cobalt_unregister {
  my ($self, $core) = splice @_, 0, 2;
  logger->info("Shutting down POEx::Weather::OpenWeatherMap ...");
  $core->timer_del_alias( $core->get_plugin_alias($self) );
  $self->{location} = +{};
  $self->pwx->stop if $self->pwx;
  logger->info("wx unloaded");
  PLUGIN_EAT_NONE
}

sub _start {
  my $self = $_[OBJECT];

  my $pcfg = core->get_plugin_cfg($self);

lib/Bot/Cobalt/Plugin/Weather.pm  view on Meta::CPAN


  my $wind      = $day->wind_speed_mph;
  my $winddir   = $day->wind_direction;

  "${date}: High of ${temp_hi_f}F/${temp_hi_c}C"
  . ", low of ${temp_lo_f}F/${temp_lo_c}C"
  . ", wind $winddir at ${wind}mph"
  . "; $terse: $verbose"
}

sub Bot_wx_timer_expire_item {
  my ($self, $core) = splice @_, 0, 2;
  my $context = ${ $_[0] };
  my $nick    = ${ $_[1] };
  return unless exists $self->{location}->{$context};
  delete $self->{location}->{$context}->{$nick};
  delete $self->{location}->{$context}
    unless keys %{ $self->{location}->{$context} };
}

sub Bot_public_cmd_wx {

lib/Bot/Cobalt/Plugin/Weather.pm  view on Meta::CPAN

      $location = $loc->{ $context }->{ $lower };
    } else {
      broadcast( message => $context => $msg->channel =>
        $msg->src_nick . ': no location specified'
      );
      return PLUGIN_EAT_NONE
    }
  } else {
    $location = join ' ', @parts;
    $loc->{ $context }->{ $lower } = $location;
    $core->timer_set( 180,
      +{
        Event => 'wx_timer_expire_item',
        Args  => [ $context, $lower ],
        Alias => $core->get_plugin_alias($self),
      }
    );
  }

  if ($self->_limiter->delay) {
    broadcast( message => $msg->context => $msg->channel =>
      "Weather is currently rate-limited; wait a minute and try again."
    );



( run in 1.043 second using v1.01-cache-2.11-cpan-49f99fa48dc )