simbot-commits Mailing List for SimBot (Page 8)
Status: Abandoned
Brought to you by:
kstange
This list is closed, nobody may subscribe to it.
| 2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(88) |
Jun
(11) |
Jul
(64) |
Aug
(74) |
Sep
(1) |
Oct
(4) |
Nov
(12) |
Dec
(4) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2006 |
Jan
(7) |
Feb
(1) |
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
(2) |
Sep
(3) |
Oct
(1) |
Nov
(4) |
Dec
|
| 2007 |
Jan
(5) |
Feb
(3) |
Mar
(1) |
Apr
(1) |
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2008 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Pete P. <fou...@us...> - 2005-07-19 20:27:27
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10222/plugins Modified Files: weather.pl Log Message: New source for METAR that doesn't fall behind so often. Index: weather.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/weather.pl,v retrieving revision 1.96 retrieving revision 1.97 diff -u -d -p -r1.96 -r1.97 --- weather.pl 19 Jul 2005 17:49:42 -0000 1.96 +++ weather.pl 19 Jul 2005 20:27:08 -0000 1.97 @@ -285,12 +285,21 @@ sub do_wx { } $station = uc($station); - my $url = - 'http://weather.noaa.gov/pub/data/observations/metar/stations/' - . $station . '.TXT'; - my $request = HTTP::Request->new(GET=>$url); + #my $url = + # 'http://weather.noaa.gov/pub/data/observations/metar/stations/' + # . $station . '.TXT'; + #my $request = HTTP::Request->new(GET=>$url); $kernel->post('wxua' => 'request', 'got_metar', - $request, "$nick!$station!$flags"); + (POST 'http://adds.aviationweather.noaa.gov/metars/index.php', + Content_Type => 'form-data', + Content => [ + station_ids => $station, + std_trans => 'standard', + chk_metars => 'on', + hoursStr => 'most recent only', + submitmet => 'Submit', + ], + ), "$nick!$station!$flags"); } if($flags & DO_FORECAST && defined $lat) { @@ -319,9 +328,16 @@ sub got_metar { } return; } - my ($datestamp, $raw_metar) = split(/\n/, $response->content); +# my ($datestamp, $raw_metar) = split(/\n/, $response->content); + my $raw_metar; + unless(($raw_metar) = $response->content =~ m|<FONT FACE="Monospace,Courier">(.*?)</FONT>|s) { + &SimBot::debug(1, "NOAA made no sense. They said:\n" . $response->content . "\n"); + &SimBot::send_message(&SimBot::option('network', 'channel'), "$nick: I couldn't make sense of what NOAA told me."); + return; + } + $raw_metar =~ s/\s+/ /ig; - &SimBot::debug(4, "weather: METAR is " . $raw_metar . "\n"); + &SimBot::debug(3, "weather: METAR is " . $raw_metar . "\n"); my $station_name_query = $dbh->prepare_cached( 'SELECT name, state, country FROM stations' @@ -347,7 +363,8 @@ sub got_metar { return; } - my $wxhash = &parse_metar("${datestamp}\n${raw_metar}"); + #my $wxhash = &parse_metar("${datestamp}\n${raw_metar}"); + my $wxhash = &parse_metar($raw_metar); my $remarks; ($raw_metar, undef, $remarks) |
|
From: Pete P. <fou...@us...> - 2005-07-19 17:49:55
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32372/plugins Modified Files: weather.pl Log Message: Stop crashing simbot if there is no precip/obscuration/whatever Index: weather.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/weather.pl,v retrieving revision 1.95 retrieving revision 1.96 diff -u -d -p -r1.95 -r1.96 --- weather.pl 19 Jul 2005 02:50:00 -0000 1.95 +++ weather.pl 19 Jul 2005 17:49:42 -0000 1.96 @@ -465,7 +465,9 @@ sub got_metar { push(@reply_with, $tmp); } - push(@reply_with, @{$wxhash->{'sky_conditions'}}); + if(defined $wxhash->{'sky_conditions'}) { + push(@reply_with, @{$wxhash->{'sky_conditions'}}); + } foreach my $cur_cloud (@{$wxhash->{'cloud_conditions'}}) { push(@reply_with, $cur_cloud->{'cover'} . ' clouds at ' |
|
From: Kevin S. <ks...@us...> - 2005-07-19 12:29:40
|
Update of /cvsroot/simbot/simbot In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25029 Modified Files: INSTALL TODO Log Message: Updating the TODO and the INSTALL. The couple notes about LWP are important to look into. Index: INSTALL =================================================================== RCS file: /cvsroot/simbot/simbot/INSTALL,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -p -r1.23 -r1.24 --- INSTALL 19 Jul 2005 02:33:28 -0000 1.23 +++ INSTALL 19 Jul 2005 12:29:28 -0000 1.24 @@ -2,54 +2,67 @@ SimBot Installation ================================================ -SimBot itself requires no compilation of software. The perl script comes -ready to run with only minor changes to the config.ini file. +SimBot is a collection of Perl script. It does not need to be compiled, but +it does require configuration and the installation of certain dependencies. -You should copy the config.default.ini file to config.ini and customize the -copy. Keep the file in the same directory where you have the simbot.pl -script installed. The installation directory is completely up to you and -is mostly irrelevant. +Configuration is simple. Copy the "config.default.ini" file to "config.ini" +and customize the copy. Many of the options in this file are already at +sane defaults, but you will likely want to customize at least the first +section to identify your bot uniquely. Keep the file in the same directory +where you have the simbot.pl script installed. The installation directory +is completely up to you. -You need the POE::Component::IRC and Encode Perl modules installed before -SimBot will function correctly. If you have Perl 5.8.0 or higher installed -you should already have a working Encode. If you do not, you will need to -install it. You may also install these additional modules for extra -features in SimBot: +It is strongly recommended that you install Perl version 5.8.0 or higher +when using SimBot. Versions below 5.8.0 will not be officially supported, +but should still work. Compatibility fixes will be accepted if users +choose to submit them. If you do not have Perl 5.8.0, please be sure to +install the Encode perl module as well as other dependencies. - POE::Component::Client::HTTP: - For weather.pl, rss.pl +You need the POE::Component::IRC Perl module installed before SimBot will +function at all. You should also install the following modules if you +intend to use any of the stock plugins provided with SimBot: - LWP: (libwwwperl) - For google.pl, tinyurl.pl +[ LWP ] (libwww-perl) version 5.802 or higher: - HTML::Entities: - For google.pl, rss.pl + If you wish to use any stock plugins, you should install LWP. It + is a dependency of several other modules and provides the framework + for accessing web-based content. v5.802 or later is required to + handle gzipped content properly in several plugins and utility scripts. - DBD::SQLite: - For sqlite-logger.pl, weather.pl, rss.pl +[ POE::Component::Client::HTTP ] - XML::Simple: - For weather.pl + * Required by: weather, rss - XML::RSS: - For rss.pl +[ HTML::Entities ] - Net::Dict: - For dict.pl + * Required by: google, rss - Text::Aspell: - For aspell.pl - - SOAP::Lite: - For currency.pl - - DateTime: - For time.pl +[ DBD::SQLite ] -This all, of course, requires that you have Perl installed. + * Required by: sqlite-logger, weather, rss + +[ XML::Simple ] + + * Required by: weather + +[ XML::RSS ] + + * Required by: rss + +[ Net::Dict ] + + * Required by: dict + +[ Text::Aspell] + + * Required by: aspell + +[ DateTime ] + + * Required by: time All of these modules are available in the CPAN repository, so you can -install them in most Perl installations by running: +install them in most Perl environments by running: perl -MCPAN -e shell; @@ -60,7 +73,7 @@ most recent version of each module, type For example: - install POE::Component::IRC Encode LWP + install POE::Component::IRC LWP CPAN will do what it needs to install the necessary package and you'll be on your way. If you are unsure how to answer the questions it asks, it is Index: TODO =================================================================== RCS file: /cvsroot/simbot/simbot/TODO,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -p -r1.16 -r1.17 --- TODO 19 Jul 2005 02:33:28 -0000 1.16 +++ TODO 19 Jul 2005 12:29:28 -0000 1.17 @@ -8,24 +8,25 @@ Targets for 1.0 Beta - Implement automatic database backups. - Implement learning ignore by hostmask/nickname. - Implement autokick plugin. -- Make interesting word calculation adaptive by db size, because over time, 5000 is not enough, and lots of words become uninteresting. +- Make interesting word base score adaptive by db size, because over time a constant is not enough, and lots of words become uninteresting. - Improve data storage format by converting to DBD-SQLite. - Convert all private messaging to private notices, to comply better with RFC 2812 section 3.3.2. +- Verify backwards compatibility with LWP < 5.802. We should never offer to accept gzipped content if we can't decode it. Targets for 1.0 Final ====================== -- Test dalnet and chanserv style services plugins. -- Polish the documentation (what documentation?). +- Test dalnet and chanserv style services plugins. Preferrably, merge these two services plugins, unless it's absolutely impossible. +- Polish (as in make better, not Poland) the documentation. - Standardize and clean up the debug output. -- Crush evil bugs! +- Test the hell out of every feature. Targets for Beyond 1.0 ====================== -- Use POE better, blocking less and using more events. -- RSS plugin desperately needs to handle all links/guids changing. -- Make sentence generation bonus __BEGIN/__END as sentence gets longer to reduce the chance of (but not obliterate) excessively long sentences. -- Redefine Plugin API using POE or related Perl 6 functionality. +- RSS plugin should handle all links/guids changing somehow that doesn't involve printing the entire feed to the channel. +- Make sentence generation give a bonus to __BEGIN/__END tags as the sentence gets longer in order to reduce the chance of excessively long sentences. +- Rework the Plugin API using POE or related Perl 6 functionality. +- Eliminate all unnecessary synchronous operations that might slow normal operations. - Allow the user to specify a custom data directory. Wish List @@ -34,3 +35,4 @@ Wish List - Implement authentication for bot administration. - Eventually recognize the possibility of joining 2 or more channels. - Allow for media other than IRC (connection plugins). +- Eventually port to the OOB functionality in Perl 6. |
|
From: Pete P. <fou...@us...> - 2005-07-19 02:50:09
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17924/plugins Modified Files: weather.pl Log Message: * I am insufficiently caffinated. Fixed a logic error in a warning. * timeago can now hide seconds * weather will not show you the seconds in how old the weather report is Index: weather.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/weather.pl,v retrieving revision 1.94 retrieving revision 1.95 diff -u -d -p -r1.94 -r1.95 --- weather.pl 19 Jul 2005 02:33:28 -0000 1.94 +++ weather.pl 19 Jul 2005 02:50:00 -0000 1.95 @@ -368,7 +368,7 @@ sub got_metar { my $reply = 'As reported '; if(defined $wxhash->{'report_time'}->{'unixtime'}) { - $reply .= &SimBot::timeago($wxhash->{'report_time'}->{'unixtime'}); + $reply .= &SimBot::timeago($wxhash->{'report_time'}->{'unixtime'}, 1); } else { $reply .= sprintf('at %d:%02d', $wxhash->{'report_time'}->{'hour'}, |
|
From: Pete P. <fou...@us...> - 2005-07-19 02:50:08
|
Update of /cvsroot/simbot/simbot In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17924 Modified Files: simbot.pl Log Message: * I am insufficiently caffinated. Fixed a logic error in a warning. * timeago can now hide seconds * weather will not show you the seconds in how old the weather report is Index: simbot.pl =================================================================== RCS file: /cvsroot/simbot/simbot/simbot.pl,v retrieving revision 1.123 retrieving revision 1.124 diff -u -d -p -r1.123 -r1.124 --- simbot.pl 19 Jul 2005 02:33:28 -0000 1.123 +++ simbot.pl 19 Jul 2005 02:50:00 -0000 1.124 @@ -524,12 +524,20 @@ sub numberize { } # TIMEAGO: Returns a string of how long ago something happened +# timeago(time, specificity) +# specificity: +# 0 shows as needed (1 hour 15 minutes 36 seconds) +# 1 hides seconds (1 hour 15 minutes) +# except if there are only seconds sub timeago { my ($seconds, $minutes, $hours, $days, $weeks, $years); my $now = time; $seconds = $now - $_[0]; - if($_[0] < $now) { + my $hidemode = $_[1]; + + if(!defined $hidemode) { $hidemode = 0; } + if($_[0] > $now) { warn "Trying to use timeago on a time in the future! Now is ${now}, Then is $_[0]"; } if($seconds >= 60) { @@ -554,7 +562,8 @@ sub timeago { push(@reply, "$days day" . (($days == 1) ? '' : 's')) if $days; push(@reply, "$hours hour" . (($hours == 1) ? '' : 's')) if $hours; push(@reply, "$minutes minute" . (($minutes == 1) ? '' : 's')) if $minutes; - push(@reply, "$seconds second" . (($seconds == 1) ? '' : 's')) if $seconds; + push(@reply, "$seconds second" . (($seconds == 1) ? '' : 's')) + if $seconds && $hidemode != 1; if(@reply) { my $string = join(', ', @reply) . ' ago'; $string =~ s/(.*),/$1 and/; |
|
From: Pete P. <fou...@us...> - 2005-07-19 02:33:40
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15606/plugins Modified Files: weather.pl Log Message: No more Geo::METAR! &got_metar still needs a rewrite or at least a cleaning. Relative times given when possible now. Index: weather.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/weather.pl,v retrieving revision 1.93 retrieving revision 1.94 diff -u -d -p -r1.93 -r1.94 --- weather.pl 21 Jun 2005 18:44:42 -0000 1.93 +++ weather.pl 19 Jul 2005 02:33:28 -0000 1.94 @@ -32,17 +32,13 @@ # KMSS) # * find other postal codes -> lat/long databases so we can find the closest # station outside the US -# * KILL Geo::METAR DAMN IT package SimBot::plugin::weather; use strict; use warnings; -# The weather, more or less! -use Geo::METAR; - -# the new fangled XML weather reports need to be parsed too! +# the new fangled XML weather reports need to be parsed! use XML::Simple; # and we need this to get the XML forecasts @@ -95,6 +91,42 @@ use constant DO_ALERTS => 1; # error messages when things fail. use constant DEFAULT_FLAGS => USING_DEFAULTS | DO_CONDITIONS | UNITS_AUTO; +our %cond_names = ( + 'MI', 'shallow', + 'PR', 'partial', + 'BC', 'patches', + 'DR', 'low drifting', + 'BL', 'blowing', + 'SH', 'showers', + 'TS', 'thunderstorm', + 'FZ', 'freezing', + + 'DZ', 'drizzle', + 'RA', 'rain', + 'SN', 'snow', + 'SG', 'snow grains', + 'IC', 'ice crystals', + 'PL', 'ice pellets', + 'GR', 'hail', + 'GS', 'small hail and/or snow pellets', + 'UP', 'unknown precipitation', + + 'BR', 'mist', + 'FG', 'fog', + 'FU', 'smoke', + 'VA', 'volcanic ash', + 'DU', 'widespread dust', + 'SA', 'sand', + 'HZ', 'haze', + 'PY', 'spray', + + 'PO', 'well-developed dust/sand whirls', + 'SQ', 'squalls', + 'FC', 'funnel cloud/tornado/waterspout', + 'SS', 'sandstorm', +); + + ### cleanup_wx # This method is run when SimBot is exiting. We save the station names # cache here. @@ -268,11 +300,6 @@ sub do_wx { } sub got_metar { - # This parses METAR reports. - # This should be replaced with something. - # Either stop using Geo::METAR, or find some service that gives - # us XML reports like NOAA does for US stations. - my ($kernel, $request_packet, $response_packet) = @_[KERNEL, ARG0, ARG1]; my ($nick, $station, $flags) @@ -292,8 +319,8 @@ sub got_metar { } return; } - my (undef, $raw_metar) = split(/\n/, $response->content); - + my ($datestamp, $raw_metar) = split(/\n/, $response->content); + &SimBot::debug(4, "weather: METAR is " . $raw_metar . "\n"); my $station_name_query = $dbh->prepare_cached( @@ -320,21 +347,14 @@ sub got_metar { return; } + my $wxhash = &parse_metar("${datestamp}\n${raw_metar}"); - # Geo::METAR has issues not ignoring the remarks section of the - # METAR report. Let's strip it out. my $remarks; ($raw_metar, undef, $remarks) = $raw_metar =~ m/^(.*?)( RMK (.*))?$/; - $raw_metar =~ s|/////KT|00000KT|; - $raw_metar =~ s{\b(BLU|WHT|GRN|YLO|AMB|RED)\b}{}; - &SimBot::debug(5, "weather: Reduced METAR is " . $raw_metar . "\n"); - - my $m = new Geo::METAR; - $m->metar($raw_metar); # Let's form a response! - if (!defined $m->{date_time}) { + if (!defined $wxhash->{report_time}) { # Something is very weird about this METAR. It has no date, # so we are probably not going to get anything useful out of # it. @@ -344,63 +364,61 @@ sub got_metar { . "metar $station if you want to try parsing it yourself."); return; } - my $wind_mph; - - $m->{date_time} =~ m/(\d\d)(\d\d)(\d\d)Z/; - my $time = "$2:$3"; - my $day=$1; - - my $reply = "As reported at $time UTC at $station_name"; + my ($wind_mph, $temp_f, $temp_c); + + my $reply = 'As reported '; + if(defined $wxhash->{'report_time'}->{'unixtime'}) { + $reply .= &SimBot::timeago($wxhash->{'report_time'}->{'unixtime'}); + } else { + $reply .= sprintf('at %d:%02d', + $wxhash->{'report_time'}->{'hour'}, + $wxhash->{'report_time'}->{'minute'}); + } + $reply .= " at $station_name"; my @reply_with; # There's no point in this exercise unless there's data in there if ($raw_metar =~ /NIL$/) { $reply .= " there is no data available"; - } else { - # Geo::METAR's error messages are a bit too aggressive... - local $SIG{__DIE__} = sub { - (my $msg = $_[0]) =~ s/You suck. /Geo::METAR says: /; - die $msg; - }; - + } else { # Temperature and related details *only* if we have # a temperature! - if (defined $m->TEMP_C || $raw_metar =~ m|(M?\d\d)/|) { + if (defined $wxhash->{'temperature'}) { # We have a temp, "it is" $reply .= " it is "; - # This nonsense checks to see if we have a temperature in - # the report that Geo::METAR is too stupid to see. - my $temp_c = (defined $m->TEMP_C ? $m->TEMP_C : $1); - $temp_c =~ s/M/-/; - my $temp_f = (defined $m->TEMP_F ? $m->TEMP_F - : (9/5)*$temp_c+32); - - push(@reply_with, &temp($temp_c, 'C', $flags)); - - # this nonsense checks for the odd wind declaration NZSP - # gives. I dunno what to make of the first part, I - # suspect it is a direction. Compass directions don't make - # much sense where every direction is north ;-) - if($raw_metar =~ m|(GRID\d{2}(\d{3}))|) { - $wind_mph = $2 * 1.1507771555; - } else { - $wind_mph = $m->WIND_MPH; - } - - if($temp_f <= 40 && $wind_mph > 5) { - # Do we have a wind chill? - my $windchill = 35.74 + (0.6215 * $temp_f) - - 35.75 * ($wind_mph ** 0.16) - + 0.4275 * $temp_f * ($wind_mph ** 0.16); - - push(@reply_with, 'a wind chill of ' - . &temp($windchill, 'F', $flags)); + push(@reply_with, &temp($wxhash->{'temperature'}->{'value'}, + $wxhash->{'temperature'}->{'unit'}, + $flags)); + $temp_f = &temp($wxhash->{'temperature'}->{'value'}, + $wxhash->{'temperature'}->{'unit'}, + UNITS_IMPERIAL | NO_UNITS); + $temp_c = &temp($wxhash->{'temperature'}->{'value'}, + $wxhash->{'temperature'}->{'unit'}, + UNITS_METRIC | NO_UNITS); + + if(defined $wxhash->{'wind_speed'}) { + $wind_mph = &speed($wxhash->{'wind_speed'}->{'value'}, + $wxhash->{'wind_speed'}->{'unit'}, + UNITS_IMPERIAL | NO_UNITS); + + if($temp_f <= 40 && $wind_mph > 5) { + # Do we have a wind chill? + my $windchill = 35.74 + (0.6215 * $temp_f) + - 35.75 * ($wind_mph ** 0.16) + + 0.4275 * $temp_f * ($wind_mph ** 0.16); + + push(@reply_with, 'a wind chill of ' + . &temp($windchill, 'F', $flags)); + } } # Humidity, only if we have a dewpoint! - if (defined $m->C_DEW) { - my $humidity = 100 * ( ( (112 - (0.1 * $temp_c) + $m->C_DEW) + if (defined $wxhash->{'dew_point'}) { + my $humidity = 100 * ( ( (112 - (0.1 * $temp_c) + + &temp($wxhash->{'dew_point'}->{'value'}, + $wxhash->{'dew_point'}->{'unit'}, + UNITS_METRIC | NO_UNITS)) / (112 + (0.9 * $temp_c)) ) ** 8 ); push(@reply_with, sprintf('%d', $humidity) . '% humidity'); @@ -427,31 +445,33 @@ sub got_metar { $reply .= ' there are '; } - if($wind_mph) { - my $tmp = &speed($wind_mph, 'MPH', $flags); - if ($m->WIND_DIR_ENG) { - $tmp .= ' winds from the ' . $m->WIND_DIR_ENG; + if(defined $wxhash->{'wind_speed'} + && $wxhash->{'wind_speed'}->{'value'} > 0) { + my $tmp = &speed($wxhash->{'wind_speed'}->{'value'}, + $wxhash->{'wind_speed'}->{'unit'}, + $flags); + if (defined $wxhash->{'wind_dir'}) { + $tmp .= ' winds from the ' . °_to_compass($wxhash->{'wind_dir'}->{'value'}); } else { $tmp .= ' variable winds'; + # FIXME: Deal with wind_dir_range } - if ($m->WIND_GUST_MPH) { - $tmp .= ' gusting to ' . &speed($m->WIND_GUST_MPH, 'MPH', $flags); + if (defined $wxhash->{'wind_gust'}) { + $tmp .= ' gusting to ' + . &speed($wxhash->{'wind_gust'}->{'value'}, + $wxhash->{'wind_gust'}->{'unit'}, + $flags); } push(@reply_with, $tmp); } - push(@reply_with, @{$m->WEATHER}); - my @sky = @{$m->SKY}; -# Geo::METAR returns sky conditions that can't be plugged into sentences -# nicely, let's clean them up. - for(my $x=0;$x<=$#sky;$x++) { - $sky[$x] = lc($sky[$x]); - $sky[$x] =~ s/solid overcast/overcast/; - $sky[$x] =~ s/sky clear/clear skies/; - $sky[$x] =~ s/(broken|few|scattered) at/$1 clouds at/; - } + push(@reply_with, @{$wxhash->{'sky_conditions'}}); - push(@reply_with, @sky); + foreach my $cur_cloud (@{$wxhash->{'cloud_conditions'}}) { + push(@reply_with, $cur_cloud->{'cover'} . ' clouds at ' + . $cur_cloud->{'height'}->{'value'} + . ' ' . $cur_cloud->{'height'}->{'unit'}); + } if($remarks) { # remarks are often not very easy to parse, but we can try. @@ -810,6 +830,220 @@ sub get_alerts { # We're done here - got_alerts will handle requesting the forecast } + +sub parse_metar { + my $raw_input = $_[0]; + + my %timedate; + if($raw_input =~ m/\n/) { + # probably came from NOAA and has a nicer date stamp on the first line + # Let's use it. + my $date; + ($date, $raw_input) = split(/\n/, $raw_input, 2); + ($timedate{'year'}, $timedate{'month'}, $timedate{'day'}, $timedate{'hour'}, $timedate{'minute'}) = $date =~ + m|(\d{4})/(\d{2})/(\d{2}) (\d{2}):(\d{2})|; + + foreach(($timedate{'year'}, $timedate{'month'}, $timedate{'day'}, $timedate{'hour'}, $timedate{'minute'})) { + $_ = int $_; + } + $timedate{'timezone'} = 'UTC'; + $timedate{'unixtime'} = timegm(0, $timedate{'minute'}, $timedate{'hour'}, $timedate{'day'}, $timedate{'month'} - 1, $timedate{'year'}); + } + my @metar = split(/ /, $raw_input); + + my %weather_data; + my @cloud_conds; + my @sky_conds; + my @unknown_blocks; + my @unknown_remarks; + + while(my $cur_block = shift @metar) { + if($cur_block =~ m/^(METAR|TAF|SPECI)$/) { # TYPE + # METAR type. We don't usually see this, but it's here + # for completeness. + $weather_data{'report_type'} = $1; + + + } elsif($cur_block =~ m/^([A-Z]{4})$/ + && !defined $weather_data{'station_id'}) { # ID + # Station ID + $weather_data{'station_id'} = $1; + + + } elsif($cur_block =~ m/^(\d{2})(\d{2})(\d{2})Z$/) { # DAY/TIME + $timedate{'day'} = int $1; + $timedate{'hour'} = int $2; + $timedate{'minute'} = int $3; + $timedate{'timezone'} = 'UTC'; + + + } elsif($cur_block =~ m/^(\d{3}|VRB|GRID\d{3})(\d{2})(?:G(\d{2}))?KT$/) { # WIND + # dddss[Ggg]KT + # ddd dir in degrees + # ss speed in knots + # gg gust speed in knots + # -- OR -- + # GRIDxxxss[Ggg]KT + # xxx some direction specification I've only seen used at the + # south pole + + my ($dir, $speed, $gust) = ($1, $2, $3); + + if($dir =~ m/^VRB$/) { + $weather_data{'wind_dir'}->{'variable'} = 1; + } elsif($1 =~ m/^GRID/) { + # hard code the south pole's odd wind speed direction + if($weather_data{'station_id'} =~ m/^NZSP$/) { + $weather_data{'wind_dir'} = &make_value_unit(0, 'deg'); + } + } else { + $weather_data{'wind_dir'} = &make_value_unit(int $dir, 'deg'); + } + $weather_data{'wind_speed'} = &make_value_unit(int $speed, 'kt'); + if(defined $gust) { + $weather_data{'wind_gust'} = &make_value_unit(int $gust, 'kt'); + } + + + } elsif($cur_block =~ m/^(\d{3})V(\d{3})$/) { # WIND VAR + # variable direction range for wind speeds over 6 kt + $weather_data{'wind_dir_range'} = [&make_value_unit(int $1, 'deg'), &make_value_unit(int $2, 'kt')]; + + + } elsif($cur_block =~ m/^(\d{1,5})SM$/) { # VISIBILITY + $weather_data{'visibility'} = &make_value_unit(int $1, 'mi'); + + + } elsif($cur_block =~ m|^(?:(M)?(\d{2}))/(?:(M)?(\d{2}))?$|) {# TEMP + if(defined $2) { + my $temp = int $2; + $temp *= -1 if defined $1; + $weather_data{'temperature'} = &make_value_unit($temp, 'C'); + } + + if(defined $4) { + my $temp = int $4; + $temp *= -1 if defined $3; + $weather_data{'dew_point'} = &make_value_unit($temp, 'C'); + } + + + } elsif($cur_block =~ m/^A(\d{4})$/) { # PRESSURE + $weather_data{'pressure'} = &make_value_unit((int $1) / 100, 'inHg'); + + + } elsif($cur_block =~ m{^ # WX COND + (-|\+|VC)? # Intensity + (MI|PR|BC|DR|BL|SH|TS|FR)? # Descriptor + (DZ|RA|SN|SG|IC|PL|GR|GS|UP)? # Precipitation + (BR|FG|FU|VA|DU|SA|HZ|PY)? # Obscuration + (PO|SQ|FC|SS)? # Other + $}x) { + my ($intensity, $descriptor, $precip, $obscuration, $other) + = ($1,$2,$3,$4,$5); + my @cond; + + if(defined $intensity) { + if($intensity =~ m/^-$/) { + push(@cond, 'light'); + } elsif($intensity =~ m/^\+$/) { + push(@cond, 'heavy'); + } + } + + if(defined $descriptor && $descriptor !~ m/^SH$/) { + push(@cond, $cond_names{$descriptor}); + } + + if(defined $precip) { + push(@cond, $cond_names{$precip}); + } + if(defined $obscuration) { + push(@cond, $cond_names{$obscuration}); + } + if(defined $other) { + push(@cond, $cond_names{$other}); + } + + if(defined $descriptor && $descriptor =~ m/^SH$/) { + push(@cond, $cond_names{'SH'}); + } + + push(@sky_conds, join(' ', @cond)); + + + } elsif($cur_block =~ m/^(FEW|SCT|BKN|OVC)(\d{3})(CB|TCU)?$/) { # SKY + my ($cover, $height, $type) = ($1, $2, $3); + + $cover =~ s/FEW/few/; + $cover =~ s/SCT/scattered/; + $cover =~ s/BKN/broken/; + $cover =~ s/OVC/overcast/; + + $height *= 100; + + my %hash; + $hash{'cover'} = $cover; + $hash{'height'} = &make_value_unit($height, 'ft'); + if(defined $type) { + $hash{'type'} = $type; + } + + push(@cloud_conds, \%hash); + + + } elsif($cur_block =~ m/^RMK$/) { # BEGIN REMARKS + last; + } else { + push(@unknown_blocks, $cur_block); + } + } + + while(my $cur_block = shift @metar) { # parse remarks + if($cur_block =~ m/^T(\d)(\d{3})(?:(\d)(\d{3}))$/) { # TEMP + my $temp = $2; + $temp *= -1 if $1 == 1; + $weather_data{'temperature'} = &make_value_unit($temp / 10, 'C'); + + if(defined $4) { + $temp = $4; + $temp *= -1 if $3 == 1; + $weather_data{'dew_point'} = &make_value_unit($temp / 10, 'C'); + } + + + } elsif($cur_block =~ m/^P(\d{4})$/) { # PRECIP + $weather_data{'precip_in_last_hr'} = &make_value_unit($1/100, 'in'); + + + } else { + push(@unknown_remarks, $cur_block); + } + } + + if(%timedate) { + $weather_data{'report_time'} = \%timedate; + } + if(@sky_conds) { + $weather_data{'sky_conditions'} = \@sky_conds; + } + if(@cloud_conds) { + $weather_data{'cloud_conditions'} = \@cloud_conds; + } + if(@unknown_remarks) { + $weather_data{'unknown_remarks'} = \@unknown_remarks; + } + if(@unknown_blocks) { + $weather_data{'unknown_blocks'} = \@unknown_blocks; + } + return \%weather_data; +} + +sub make_value_unit { + my ($value, $unit) = @_; + return { 'value' => $value, 'unit' => $unit }; +} + sub find_closest_station { my ($zipcode) = @_; @@ -995,6 +1229,46 @@ sub distance { . ' (' . (int $dist_km) . ($flags & NO_UNITS ? '' : ' km') . ')'; } +sub deg_to_compass { + my $deg = $_[0]; + + if($deg < 11.25) { + return 'North'; + } elsif($deg < 33.75) { + return 'NNE'; + } elsif($deg < 56.25) { + return 'Northeast'; + } elsif($deg < 78.75) { + return 'ENE'; + } elsif($deg < 101.25) { + return 'East'; + } elsif($deg < 123.75) { + return 'ESE'; + } elsif($deg < 146.25) { + return 'Southeast'; + } elsif($deg < 168.75) { + return 'SSE'; + } elsif($deg < 191.25) { + return 'South'; + } elsif($deg < 213.75) { + return 'SSW'; + } elsif($deg < 236.25) { + return 'Southwest'; + } elsif($deg < 258.75) { + return 'WSW'; + } elsif($deg < 281.25) { + return 'West'; + } elsif($deg < 303.75) { + return 'WNW'; + } elsif($deg < 326.25) { + return 'Northwest'; + } elsif($deg < 348.75) { + return 'NNW'; + } else { + return 'North'; + } +} + # Register Plugins &SimBot::plugin_register( plugin_id => "weather", |
|
From: Pete P. <fou...@us...> - 2005-07-19 02:33:40
|
Update of /cvsroot/simbot/simbot In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15606 Modified Files: ChangeLog INSTALL TODO simbot.pl Log Message: No more Geo::METAR! &got_metar still needs a rewrite or at least a cleaning. Relative times given when possible now. Index: ChangeLog =================================================================== RCS file: /cvsroot/simbot/simbot/ChangeLog,v retrieving revision 1.75 retrieving revision 1.76 diff -u -d -p -r1.75 -r1.76 --- ChangeLog 9 May 2005 02:02:35 -0000 1.75 +++ ChangeLog 19 Jul 2005 02:33:28 -0000 1.76 @@ -1,3 +1,9 @@ +Version 1.0 alpha: (18 Jul 2005) + * plugins/weather.pl: + - Added our own METAR parser. With luck, this will be more sane. + - If we can figure out a valid time for the report, we tell the user how + old the report is instead of the UTC time. + Version 1.0 alpha: (08 May 2005) * plugins/time.pl: - New plugin! Index: INSTALL =================================================================== RCS file: /cvsroot/simbot/simbot/INSTALL,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -p -r1.22 -r1.23 --- INSTALL 9 May 2005 02:06:34 -0000 1.22 +++ INSTALL 19 Jul 2005 02:33:28 -0000 1.23 @@ -28,9 +28,6 @@ features in SimBot: DBD::SQLite: For sqlite-logger.pl, weather.pl, rss.pl - Geo::METAR: - For weather.pl - XML::Simple: For weather.pl @@ -63,7 +60,7 @@ most recent version of each module, type For example: - install POE::Component::IRC Encode Geo::METAR LWP + install POE::Component::IRC Encode LWP CPAN will do what it needs to install the necessary package and you'll be on your way. If you are unsure how to answer the questions it asks, it is Index: TODO =================================================================== RCS file: /cvsroot/simbot/simbot/TODO,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -p -r1.15 -r1.16 --- TODO 4 May 2005 21:36:58 -0000 1.15 +++ TODO 19 Jul 2005 02:33:28 -0000 1.16 @@ -24,7 +24,6 @@ Targets for Beyond 1.0 ====================== - Use POE better, blocking less and using more events. - RSS plugin desperately needs to handle all links/guids changing. -- Weather plugin needs to stop using Geo::METAR. - Make sentence generation bonus __BEGIN/__END as sentence gets longer to reduce the chance of (but not obliterate) excessively long sentences. - Redefine Plugin API using POE or related Perl 6 functionality. - Allow the user to specify a custom data directory. Index: simbot.pl =================================================================== RCS file: /cvsroot/simbot/simbot/simbot.pl,v retrieving revision 1.122 retrieving revision 1.123 diff -u -d -p -r1.122 -r1.123 --- simbot.pl 18 Jul 2005 05:06:45 -0000 1.122 +++ simbot.pl 19 Jul 2005 02:33:28 -0000 1.123 @@ -526,7 +526,12 @@ sub numberize { # TIMEAGO: Returns a string of how long ago something happened sub timeago { my ($seconds, $minutes, $hours, $days, $weeks, $years); - $seconds = time - $_[0]; + my $now = time; + + $seconds = $now - $_[0]; + if($_[0] < $now) { + warn "Trying to use timeago on a time in the future! Now is ${now}, Then is $_[0]"; + } if($seconds >= 60) { $minutes = int $seconds / 60; $seconds %= 60; |
|
From: Pete P. <fou...@us...> - 2005-07-19 02:26:49
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14244/plugins Modified Files: sqlite-logger.pl Log Message: This has been sitting here needing checking in for a while... Use prepare_cached instead of prepare in a few spots, should save some SQL time. Maybe. Index: sqlite-logger.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/sqlite-logger.pl,v retrieving revision 1.44 retrieving revision 1.45 diff -u -d -p -r1.44 -r1.45 --- sqlite-logger.pl 6 May 2005 21:10:27 -0000 1.44 +++ sqlite-logger.pl 19 Jul 2005 02:26:39 -0000 1.45 @@ -23,7 +23,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # TODO: -# * see comment at about line 452 +# * see comment at about line 600 # @@ -376,7 +376,7 @@ sub do_recap { my $nick_id = &get_nickchan_id($nick); - my $start_query = $dbh->prepare( + my $start_query = $dbh->prepare_cached( 'SELECT id FROM chatlog' . ' WHERE channel_id = ?' . ' AND source_nick_id = ?' @@ -387,7 +387,7 @@ sub do_recap { . ' LIMIT 1' ); - my $end_query = $dbh->prepare( + my $end_query = $dbh->prepare_cached( 'SELECT id FROM chatlog' . ' WHERE channel_id = ?' . ' AND source_nick_id = ?' @@ -396,7 +396,7 @@ sub do_recap { . ' LIMIT 1' ); - my $log_query = $dbh->prepare( + my $log_query = $dbh->prepare_cached( 'SELECT time, source_nick_id, event,' . ' target_nick_id, content' . ' FROM chatlog' @@ -490,7 +490,7 @@ sub access_log { # no nick specified, so how 'bout some generic stats? my $tmp_query; - $tmp_query = $dbh->prepare( + $tmp_query = $dbh->prepare_cached( 'SELECT time FROM chatlog' . ' WHERE channel_id = ?' . ' ORDER BY time' @@ -499,7 +499,7 @@ sub access_log { my $start_date = localtime(($tmp_query->fetchrow_array())[0]); $tmp_query->finish; - $tmp_query = $dbh->prepare( + $tmp_query = $dbh->prepare_cached( 'SELECT count() FROM chatlog' . ' WHERE channel_id = ?' ); |
|
From: Kevin S. <ks...@us...> - 2005-07-18 23:19:01
|
Update of /cvsroot/simbot/simbot In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8510 Modified Files: config.default.ini Log Message: miami is dead, mesa is still alive Index: config.default.ini =================================================================== RCS file: /cvsroot/simbot/simbot/config.default.ini,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -p -r1.28 -r1.29 --- config.default.ini 8 Jun 2005 00:25:13 -0000 1.28 +++ config.default.ini 18 Jul 2005 23:18:52 -0000 1.29 @@ -53,7 +53,7 @@ gender=I # server name. (server=miami.fl.us.undernet.org:7000 for example) # Undernet -- Verified Bot Friendly (Non-abusive bots) -server=miami.fl.us.undernet.org +server=mesa.az.us.undernet.org server=oslo1.no.eu.undernet.org server=fairfax.va.us.undernet.org server=Carouge.CH.EU.undernet.org |
|
From: Pete P. <fou...@us...> - 2005-07-18 12:56:46
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26759/plugins Modified Files: tinyurl.pl Log Message: biglnk.com not biglink.com Index: tinyurl.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/tinyurl.pl,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -p -r1.8 -r1.9 --- tinyurl.pl 18 Jul 2005 00:23:23 -0000 1.8 +++ tinyurl.pl 18 Jul 2005 12:56:36 -0000 1.9 @@ -78,7 +78,7 @@ EOT qr%(http://[\S+]\.v3\.net)%, qr%(http://heh\.pl/[\S]+)%, qr%(http://shorterlink\.(com|co\.uk)/[\S]+)%, - qr%(http://(biglink|babyurl)\.com/[\S]+)%, + qr%(http://(biglnk|babyurl)\.com/[\S]+)%, ); # makeashorterlink.com aka masl.to doesn't work as it doesn't use # http redirects. Doesn't matter, as it warns you where you're about to |
|
From: Kevin S. <ks...@us...> - 2005-07-18 05:06:58
|
Update of /cvsroot/simbot/simbot In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7903 Modified Files: simbot.pl Log Message: Yes, dropkick to oblivion Index: simbot.pl =================================================================== RCS file: /cvsroot/simbot/simbot/simbot.pl,v retrieving revision 1.121 retrieving revision 1.122 diff -u -d -p -r1.121 -r1.122 --- simbot.pl 20 Jun 2005 01:59:54 -0000 1.121 +++ simbot.pl 18 Jul 2005 05:06:45 -0000 1.122 @@ -992,7 +992,7 @@ sub delete_words { my (undef, $nick, $channel, undef, $word) = @_; my $max = option('chat', 'delete_usage_max'); $word = lc($word); - if (defined $word) { + if (defined $word && $word ne "") { my @deleted = &delete_word($word, $max); if (!@deleted && !defined $chat_words{$word}) { &send_message($channel, "$nick: I don't remember ever seeing that word before. It will be hard to forget it."); |
|
From: Pete P. <fou...@us...> - 2005-07-18 00:23:41
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26795/plugins Modified Files: tinyurl.pl Log Message: added shorterlink.com, shorterlink.co.uk, babyurl.com, biglink.com Index: tinyurl.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/tinyurl.pl,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -p -r1.7 -r1.8 --- tinyurl.pl 18 Jul 2005 00:03:41 -0000 1.7 +++ tinyurl.pl 18 Jul 2005 00:23:23 -0000 1.8 @@ -77,6 +77,8 @@ EOT qr%(http://([\S]+\.)?url123\.com/[\S]+)%, qr%(http://[\S+]\.v3\.net)%, qr%(http://heh\.pl/[\S]+)%, + qr%(http://shorterlink\.(com|co\.uk)/[\S]+)%, + qr%(http://(biglink|babyurl)\.com/[\S]+)%, ); # makeashorterlink.com aka masl.to doesn't work as it doesn't use # http redirects. Doesn't matter, as it warns you where you're about to @@ -131,7 +133,7 @@ sub handle_chat { # not a HTTP redirect, maybe a META? if($response->content =~ m{<meta http-equiv="refresh" content="(.*?)"}) { $to_url = $1; - $to_url =~ s/^\d+\;//g; + $to_url =~ s/^\d+\s*\;//g; $to_url =~ s/^URL=//g; $db_insert_query->execute($url, $to_url); |
|
From: Pete P. <fou...@us...> - 2005-07-18 00:03:51
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23811/plugins Modified Files: tinyurl.pl Log Message: Added tinyurl.heh.pl Index: tinyurl.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/tinyurl.pl,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -p -r1.6 -r1.7 --- tinyurl.pl 17 Jul 2005 23:46:47 -0000 1.6 +++ tinyurl.pl 18 Jul 2005 00:03:41 -0000 1.7 @@ -76,6 +76,7 @@ EOT qr%(http://tinyurl\.(com|co\.uk)/[\S]+)%, qr%(http://([\S]+\.)?url123\.com/[\S]+)%, qr%(http://[\S+]\.v3\.net)%, + qr%(http://heh\.pl/[\S]+)%, ); # makeashorterlink.com aka masl.to doesn't work as it doesn't use # http redirects. Doesn't matter, as it warns you where you're about to |
|
From: Pete P. <fou...@us...> - 2005-07-17 23:46:55
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20650/plugins Modified Files: tinyurl.pl Log Message: TinyURL.com changed their redirects so they could insert some advertising or maybe their own affiliate garbage. We now look for META redirects as well as plain 'ol HTTP redirects. Also, we now cache links. This works fine for tinyurl, since the links last forever, but the others should probably be checked to see if we should expire the cache. Or maybe we should expire the cache anyway. Index: tinyurl.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/tinyurl.pl,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -p -r1.5 -r1.6 --- tinyurl.pl 13 Apr 2005 00:06:52 -0000 1.5 +++ tinyurl.pl 17 Jul 2005 23:46:47 -0000 1.6 @@ -41,6 +41,34 @@ use vars qw( @match_rules %urlcache ); use LWP::UserAgent; +use DBI; + +use vars qw{ $dbh $db_query $db_insert_query }; + +sub messup_tinyurl { + # Let's create our database + $dbh = DBI->connect('dbi:SQLite:dbname=caches/tinyurl','','', + { RaiseError => 1, AutoCommit => 1}) or die; + + { + local $dbh->{RaiseError}; + local $dbh->{PrintError}; + + $dbh->do(<<EOT); +CREATE TABLE redirects ( + from_url STRING UNIQUE, + to_url STRING +); + +CREATE UNIQUE INDEX redirectfrom + ON redirects (from_url); +EOT + } + + $db_query = $dbh->prepare('SELECT to_url FROM redirects WHERE from_url = ? LIMIT 1'); + $db_insert_query = $dbh->prepare('INSERT INTO redirects (from_url, to_url) VALUES (?, ?)'); +} + # these are matching rules for various tinyurl style services # they should be qr// regular expressions. The entire URL needs to be # in (). @@ -73,25 +101,48 @@ sub handle_chat { foreach my $cur_rule (@match_rules) { if($content =~ /$cur_rule/) { my $url = munge_url($1); - &SimBot::debug(3, "tinyurl: Looking up ${url}\n"); - my $useragent = - LWP::UserAgent->new(requests_redirectable => undef); - $useragent->agent(SimBot::PROJECT . '/' . SimBot::VERSION); - $useragent->timeout(5); - my $request = HTTP::Request->new(GET => $url); - my $response = $useragent->request($request); - if($response->previous) { - if($response->previous->is_redirect) { - &SimBot::send_message($channel, 'TinyURL points to ' - . &shorten_url($response->request->uri())); + $db_query->execute($url); + my $to_url; + if(($to_url) = $db_query->fetchrow_array()) { + &SimBot::debug(3, "tinyurl: Looking up ${url} (cached)\n"); + &SimBot::send_message($channel, 'TinyURL points to ' + . &shorten_url($to_url)); + } else { + &SimBot::debug(3, "tinyurl: Looking up ${url}\n"); + + my $useragent = + LWP::UserAgent->new(requests_redirectable => undef); + $useragent->agent(SimBot::PROJECT . '/' . SimBot::VERSION); + $useragent->timeout(5); + my $request = HTTP::Request->new(GET => $url); + my $response = $useragent->request($request); + if($response->previous) { + if($response->previous->is_redirect) { + $to_url = $response->request->uri(); + $db_insert_query->execute($url, $to_url); + &SimBot::send_message($channel, 'TinyURL points to ' + . &shorten_url($to_url)); + } else { + &SimBot::debug(3, " failed! (no redirect)\n"); + } } else { - &SimBot::debug(3, " failed! (no redirect)\n"); + # not a HTTP redirect, maybe a META? + if($response->content =~ m{<meta http-equiv="refresh" content="(.*?)"}) { + $to_url = $1; + $to_url =~ s/^\d+\;//g; + $to_url =~ s/^URL=//g; + + $db_insert_query->execute($url, $to_url); + &SimBot::send_message($channel, 'TinyURL points to ' + . &shorten_url($to_url)); + } else { + &SimBot::debug(3, " failed!\n"); + warn $response->content; + } } - } else { - &SimBot::debug(3, " failed!\n"); - warn $response->content; } + $db_query->finish; return; } } @@ -129,7 +180,7 @@ sub shorten_url { &SimBot::plugin_register( plugin_id => 'tinyurl', -# event_plugin_load => \&messup_tinyurl, + event_plugin_load => \&messup_tinyurl, # event_plugin_unload => \&cleanup_tinyurl, event_channel_message => \&handle_chat, ); |
|
From: Pete P. <fou...@us...> - 2005-07-14 00:08:44
|
Update of /cvsroot/simbot/simbot/tools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29421/tools Modified Files: create_wx_station_db.pl Log Message: We now rollback the database and exit on errors instead of trying to continue. Index: create_wx_station_db.pl =================================================================== RCS file: /cvsroot/simbot/simbot/tools/create_wx_station_db.pl,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -p -r1.6 -r1.7 --- create_wx_station_db.pl 21 Jun 2005 19:33:58 -0000 1.6 +++ create_wx_station_db.pl 14 Jul 2005 00:08:35 -0000 1.7 @@ -72,6 +72,8 @@ my $response = $ua->get('http://weather. if($response->is_error) { print STDERR "Failed!\n " . $response->code . ' ' . $response->message . "\n"; + $dbh->rollback; + exit(1); } else { print "Done!\nReading it in"; my $content = $response->decoded_content; @@ -122,6 +124,8 @@ $response = $ua->get('ftp://weather.noaa if($response->is_error) { print STDERR "Failed! " . $response->code . ' ' . $response->message . "\n"; + $dbh->rollback; + exit(1); } else { my $line_count = 0; print "Done!\nReading it in"; |
|
From: Pete P. <fou...@us...> - 2005-07-07 23:31:56
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10998/plugins Removed Files: currency.pl Log Message: %currency is dead! Use %find instead. --- currency.pl DELETED --- |
|
From: Pete P. <fou...@us...> - 2005-06-21 19:34:07
|
Update of /cvsroot/simbot/simbot/tools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17851/tools Modified Files: create_wx_station_db.pl Log Message: Remove unwanted spaces in the weather station names, and correct spelling on a comment. Index: create_wx_station_db.pl =================================================================== RCS file: /cvsroot/simbot/simbot/tools/create_wx_station_db.pl,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -p -r1.5 -r1.6 --- create_wx_station_db.pl 14 May 2005 00:28:26 -0000 1.5 +++ create_wx_station_db.pl 21 Jun 2005 19:33:58 -0000 1.6 @@ -87,6 +87,9 @@ if($response->is_error) { ($cur_line, $content) = split(/\n/, $content, 2); my ($station, undef, undef, $name, $state, $country, undef, $lat_dms, $long_dms, undef, undef, $rbsn) = split(/;/, $cur_line); + $name =~ s/\s+$//; + $name =~ s/^\s+//; + my ($long_deg); my ($lat_deg, $minutes, $seconds, $dir) = $lat_dms =~ m/(\d+)-(\d+)(?:-(\d+))?([NS])/; @@ -123,7 +126,7 @@ if($response->is_error) { my $line_count = 0; print "Done!\nReading it in"; - # Create a temprary table as a list of candidates for deletion + # Create a temporary table as a list of candidates for deletion $dbh->do(<<EOT); CREATE TEMPORARY TABLE delrows AS SELECT id FROM stations; CREATE UNIQUE INDEX delstationid ON delrows (id); |
|
From: Pete P. <fou...@us...> - 2005-06-21 18:45:25
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28648/plugins Modified Files: weather.pl Log Message: Apparently Geo::METAR calls you names when it crashes. While this doesn't fix the whole crashing bit, at least it removes the name calling. Index: weather.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/weather.pl,v retrieving revision 1.92 retrieving revision 1.93 diff -u -d -p -r1.92 -r1.93 --- weather.pl 10 Jun 2005 12:37:56 -0000 1.92 +++ weather.pl 21 Jun 2005 18:44:42 -0000 1.93 @@ -357,6 +357,12 @@ sub got_metar { if ($raw_metar =~ /NIL$/) { $reply .= " there is no data available"; } else { + # Geo::METAR's error messages are a bit too aggressive... + local $SIG{__DIE__} = sub { + (my $msg = $_[0]) =~ s/You suck. /Geo::METAR says: /; + die $msg; + }; + # Temperature and related details *only* if we have # a temperature! if (defined $m->TEMP_C || $raw_metar =~ m|(M?\d\d)/|) { |
|
From: Pete P. <fou...@us...> - 2005-06-20 02:00:03
|
Update of /cvsroot/simbot/simbot In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13352 Modified Files: simbot.pl Log Message: We now fire the unload event for the plugins when we get disconnected from the server and are quitting, instead of when we send the quit command or get klined. This should (might?) fix a crash should simbot get a message after beginning to quit. It also removes a bit of code duplication. Index: simbot.pl =================================================================== RCS file: /cvsroot/simbot/simbot/simbot.pl,v retrieving revision 1.120 retrieving revision 1.121 diff -u -d -p -r1.120 -r1.121 --- simbot.pl 6 Jun 2005 22:16:17 -0000 1.120 +++ simbot.pl 20 Jun 2005 01:59:54 -0000 1.121 @@ -1929,6 +1929,12 @@ sub irc_disconnected { &debug(3, "Disconnected!\n"); $kernel->post(bot => unregister => "all"); + + # Everyone out of the pool! + foreach(keys(%event_plugin_unload)) { + &plugin_callback($_, $event_plugin_unload{$_}); + } + # since the event loop should soon have nothing to do # it'll exit. Or something like that. } else { @@ -1966,10 +1972,6 @@ sub server_banned { if(!@{$conf{'network'}{'server'}}) { # hmm... we've removed our last server &debug(1, "No more servers to connect to! Please add some to config.ini.\n"); - # Everyone out of the pool! - foreach(keys(%event_plugin_unload)) { - &plugin_callback($_, $event_plugin_unload{$_}); - } $terminating=100; } @@ -2001,11 +2003,6 @@ sub quit_session { $terminating = 1 unless $terminating > 1; - # Everyone out of the pool! - foreach(keys(%event_plugin_unload)) { - &plugin_callback($_, $event_plugin_unload{$_}); - } - $kernel->post(bot => quit => PROJECT . " " . VERSION . (($message ne "") ? ": $message" : "")); &debug(3, "Disconnecting from IRC... $message\n"); |
|
From: Pete P. <fou...@us...> - 2005-06-10 12:38:17
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18452/plugins Modified Files: weather.pl Log Message: We now catch NOAA's fondness for sending an empty forecast for 1970 in response to bad requests and give an error message, including the suggestion to check one's clock. Now to figure out why my computer thinks it is 1982... Index: weather.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/weather.pl,v retrieving revision 1.91 retrieving revision 1.92 diff -u -d -p -r1.91 -r1.92 --- weather.pl 14 May 2005 22:41:27 -0000 1.91 +++ weather.pl 10 Jun 2005 12:37:56 -0000 1.92 @@ -681,7 +681,11 @@ sub get_forecast { my (undef, undef, undef, $today_day, $today_mon, $today_year, $toay_wday) = localtime; foreach (@days) { my ($year, $month, $day) = m/^(\d+)-(\d+)-(\d+)/; - if($year == $today_year+1900 + if($year <= 2000) { + # NOAA's giving us bogus data again + &SimBot::debug(1, "weather: Forecast is in the past, check your clock!\n"); + return 'Could not get the forecast.'; + } elsif($year == $today_year+1900 && $month == $today_mon+1 && $day == $today_day) { |
|
From: Pete P. <fou...@us...> - 2005-06-08 00:25:31
|
Update of /cvsroot/simbot/simbot In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14511 Modified Files: config.default.ini Log Message: fairfax.va.us.undernet.org now allows non-abusive bots, adding it to the default config. Index: config.default.ini =================================================================== RCS file: /cvsroot/simbot/simbot/config.default.ini,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -p -r1.27 -r1.28 --- config.default.ini 8 Jun 2005 00:18:30 -0000 1.27 +++ config.default.ini 8 Jun 2005 00:25:13 -0000 1.28 @@ -55,6 +55,7 @@ gender=I # Undernet -- Verified Bot Friendly (Non-abusive bots) server=miami.fl.us.undernet.org server=oslo1.no.eu.undernet.org +server=fairfax.va.us.undernet.org server=Carouge.CH.EU.undernet.org # Undernet (These could put you on an bot-unfriendly server. Avoid using them.) |
|
From: Pete P. <fou...@us...> - 2005-06-08 00:18:39
|
Update of /cvsroot/simbot/simbot In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9977 Modified Files: config.default.ini Log Message: Looks like Elsene.Be.Eu.undernet.org is no more. (points to oslo) Index: config.default.ini =================================================================== RCS file: /cvsroot/simbot/simbot/config.default.ini,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -p -r1.26 -r1.27 --- config.default.ini 9 May 2005 02:02:36 -0000 1.26 +++ config.default.ini 8 Jun 2005 00:18:30 -0000 1.27 @@ -55,7 +55,6 @@ gender=I # Undernet -- Verified Bot Friendly (Non-abusive bots) server=miami.fl.us.undernet.org server=oslo1.no.eu.undernet.org -server=Elsene.Be.Eu.undernet.org server=Carouge.CH.EU.undernet.org # Undernet (These could put you on an bot-unfriendly server. Avoid using them.) |
|
From: Pete P. <fou...@us...> - 2005-06-06 22:16:28
|
Update of /cvsroot/simbot/simbot In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18130 Modified Files: simbot.pl Log Message: Made the banned error message slightly clearer. Index: simbot.pl =================================================================== RCS file: /cvsroot/simbot/simbot/simbot.pl,v retrieving revision 1.119 retrieving revision 1.120 diff -u -d -p -r1.119 -r1.120 --- simbot.pl 6 Jun 2005 22:08:58 -0000 1.119 +++ simbot.pl 6 Jun 2005 22:16:17 -0000 1.120 @@ -329,7 +329,7 @@ POE::Session->new irc_433 => \&pick_new_nick, # nickname in use irc_socketerr => \&socket_error, # internet wants to yell at us irc_error => \&server_error, # server wants to yell at us - irc_465 => \&server_banned, # ERR_YOUREBANNEDCREEP + irc_465 => \&server_banned, # ERR_YOUREBANNEDCREEP irc_disconnected => \&irc_disconnected, # disconnected irc_303 => \&server_ison, # check ison reply irc_352 => \&server_who, # check who reply @@ -1953,7 +1953,7 @@ sub server_notice { # SERVER_BANNED: The server has told us you're banned, creep. # no, really. Numeric 465, ERR_YOUREBANNEDCREEP sub server_banned { - &debug(1, "Banned! $_[ARG1]\n"); + &debug(1, "Banned from $_[ARG0]: $_[ARG1]\n"); if(!defined $chosen_server) { die q($chosen_server is undefined); |
|
From: Pete P. <fou...@us...> - 2005-06-06 22:09:07
|
Update of /cvsroot/simbot/simbot In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15361 Modified Files: simbot.pl Log Message: Handling numeric 465, you're banned creep, would be a good thing. Especially since it tells us *why* we were klined. (bite me, identd) Index: simbot.pl =================================================================== RCS file: /cvsroot/simbot/simbot/simbot.pl,v retrieving revision 1.118 retrieving revision 1.119 diff -u -d -p -r1.118 -r1.119 --- simbot.pl 6 Jun 2005 21:50:13 -0000 1.118 +++ simbot.pl 6 Jun 2005 22:08:58 -0000 1.119 @@ -329,6 +329,7 @@ POE::Session->new irc_433 => \&pick_new_nick, # nickname in use irc_socketerr => \&socket_error, # internet wants to yell at us irc_error => \&server_error, # server wants to yell at us + irc_465 => \&server_banned, # ERR_YOUREBANNEDCREEP irc_disconnected => \&irc_disconnected, # disconnected irc_303 => \&server_ison, # check ison reply irc_352 => \&server_who, # check who reply @@ -354,6 +355,7 @@ POE::Session->new irc_ctcp_time => \&process_time, irc_ctcp_finger => \&process_finger, irc_ctcp_ping => \&process_ping, + irc_snotice => \&server_notice, # These are our own custom events-- signs that we're using POE correctly. scheduler_60 => \&run_scheduler_60, # run events every 60 seconds @@ -1939,25 +1941,38 @@ sub irc_disconnected { # SERVER_ERROR: The server's whining at us. We should listen. sub server_error { &debug(1, "$_[ARG0]\n"); - if ($_[ARG0] =~ /k-lined/i) { - if(!defined $chosen_server) { - die q($chosen_server is undefined); - } - for (my $i = 0; defined @{$conf{'network'}{'server'}}[$i]; $i++) { - if ($chosen_server eq @{$conf{'network'}{'server'}}[$i]) { - splice(@{$conf{'network'}{'server'}}, $i, 1) - } +# if ($_[ARG0] =~ /k-lined/i) { +# } +} + +# SERVER_NOTICE: The server has something to say. We should listen. +sub server_notice { + &debug(3, "$_[ARG0]\n"); +} + +# SERVER_BANNED: The server has told us you're banned, creep. +# no, really. Numeric 465, ERR_YOUREBANNEDCREEP +sub server_banned { + &debug(1, "Banned! $_[ARG1]\n"); + + if(!defined $chosen_server) { + die q($chosen_server is undefined); + } + for (my $i = 0; defined @{$conf{'network'}{'server'}}[$i]; $i++) { + if ($chosen_server eq @{$conf{'network'}{'server'}}[$i]) { + splice(@{$conf{'network'}{'server'}}, $i, 1) } - if(!@{$conf{'network'}{'server'}}) { - # hmm... we've removed our last server - &debug(1, "No more servers to connect to! Please add some to config.ini.\n"); - # Everyone out of the pool! - foreach(keys(%event_plugin_unload)) { - &plugin_callback($_, $event_plugin_unload{$_}); - } - $terminating=100; + } + if(!@{$conf{'network'}{'server'}}) { + # hmm... we've removed our last server + &debug(1, "No more servers to connect to! Please add some to config.ini.\n"); + # Everyone out of the pool! + foreach(keys(%event_plugin_unload)) { + &plugin_callback($_, $event_plugin_unload{$_}); } + $terminating=100; } + } # SOCKET_ERROR: Spit out the error, then reconnect to IRC. |
|
From: Pete P. <fou...@us...> - 2005-06-06 21:50:22
|
Update of /cvsroot/simbot/simbot In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4863 Modified Files: simbot.pl Log Message: We now cleanly quit if we've removed our last server when getting klined. Index: simbot.pl =================================================================== RCS file: /cvsroot/simbot/simbot/simbot.pl,v retrieving revision 1.117 retrieving revision 1.118 diff -u -d -p -r1.117 -r1.118 --- simbot.pl 6 Jun 2005 21:34:35 -0000 1.117 +++ simbot.pl 6 Jun 2005 21:50:13 -0000 1.118 @@ -1939,16 +1939,25 @@ sub irc_disconnected { # SERVER_ERROR: The server's whining at us. We should listen. sub server_error { &debug(1, "$_[ARG0]\n"); - if ($_[ARG0] =~ /k-lined/i) { - if(!defined $chosen_server) { - die q($chosen_server is undefined); - } - for (my $i = 0; defined @{$conf{'network'}{'server'}}[$i]; $i++) { - if ($chosen_server eq @{$conf{'network'}{'server'}}[$i]) { - splice(@{$conf{'network'}{'server'}}, $i, 1) - } - } - } + if ($_[ARG0] =~ /k-lined/i) { + if(!defined $chosen_server) { + die q($chosen_server is undefined); + } + for (my $i = 0; defined @{$conf{'network'}{'server'}}[$i]; $i++) { + if ($chosen_server eq @{$conf{'network'}{'server'}}[$i]) { + splice(@{$conf{'network'}{'server'}}, $i, 1) + } + } + if(!@{$conf{'network'}{'server'}}) { + # hmm... we've removed our last server + &debug(1, "No more servers to connect to! Please add some to config.ini.\n"); + # Everyone out of the pool! + foreach(keys(%event_plugin_unload)) { + &plugin_callback($_, $event_plugin_unload{$_}); + } + $terminating=100; + } + } } # SOCKET_ERROR: Spit out the error, then reconnect to IRC. @@ -1975,7 +1984,7 @@ sub quit_session { } } - $terminating = 1 unless $terminating == 2; + $terminating = 1 unless $terminating > 1; # Everyone out of the pool! foreach(keys(%event_plugin_unload)) { @@ -2033,5 +2042,9 @@ if ($terminating == 2) { . (defined $args{config} ? " --config=\"$args{config}\"" : ""); } else { &debug(3, "Terminated.\n"); - exit 0; + if($terminating > 2) { + exit $terminating; #abnormal exit + } else { + exit 0; + } } |