simbot-commits Mailing List for SimBot (Page 9)
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-06-06 21:34:43
|
Update of /cvsroot/simbot/simbot In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28101 Modified Files: simbot.pl Log Message: We now work with the proper array when removing servers that have klined us. Index: simbot.pl =================================================================== RCS file: /cvsroot/simbot/simbot/simbot.pl,v retrieving revision 1.116 retrieving revision 1.117 diff -u -d -p -r1.116 -r1.117 --- simbot.pl 6 Jun 2005 21:16:40 -0000 1.116 +++ simbot.pl 6 Jun 2005 21:34:35 -0000 1.117 @@ -24,6 +24,8 @@ # Hi, my name(space) is: package SimBot; +use Data::Dumper; + # Sometimes we end up in Unicode. Since IRC and Unicode are not good # friends, we'll take a ride back to ISO-8859-1 before we send the # server any questionable strings. This requires Perl 5.8.0 or a perl @@ -1941,9 +1943,9 @@ sub server_error { if(!defined $chosen_server) { die q($chosen_server is undefined); } - for (my $i = 0; defined @{$conf{'network'}{'servers'}}[$i]; $i++) { - if ($chosen_server eq @{$conf{'network'}{'servers'}}[$i]) { - splice(@{$conf{'network'}{'servers'}}, $i, 1) + for (my $i = 0; defined @{$conf{'network'}{'server'}}[$i]; $i++) { + if ($chosen_server eq @{$conf{'network'}{'server'}}[$i]) { + splice(@{$conf{'network'}{'server'}}, $i, 1) } } } |
|
From: Pete P. <fou...@us...> - 2005-06-06 21:16:52
|
Update of /cvsroot/simbot/simbot In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17815 Modified Files: simbot.pl Log Message: How old is this logic bug? Should simbot get klined, we'll now properly remove the server from the pool instead of getting stuck in a loop. Index: simbot.pl =================================================================== RCS file: /cvsroot/simbot/simbot/simbot.pl,v retrieving revision 1.115 retrieving revision 1.116 diff -u -d -p -r1.115 -r1.116 --- simbot.pl 10 May 2005 02:25:57 -0000 1.115 +++ simbot.pl 6 Jun 2005 21:16:40 -0000 1.116 @@ -1938,7 +1938,10 @@ sub irc_disconnected { sub server_error { &debug(1, "$_[ARG0]\n"); if ($_[ARG0] =~ /k-lined/i) { - for (my $i = 0; !defined @{$conf{'network'}{'servers'}}[$i]; $i++) { + if(!defined $chosen_server) { + die q($chosen_server is undefined); + } + for (my $i = 0; defined @{$conf{'network'}{'servers'}}[$i]; $i++) { if ($chosen_server eq @{$conf{'network'}{'servers'}}[$i]) { splice(@{$conf{'network'}{'servers'}}, $i, 1) } |
|
From: Pete P. <fou...@us...> - 2005-05-15 03:07:04
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10593/plugins Modified Files: currency.pl Log Message: Removing the timeout here. I'll fix it later, when I'm awake. Index: currency.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/currency.pl,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -p -r1.12 -r1.13 --- currency.pl 10 May 2005 02:23:02 -0000 1.12 +++ currency.pl 15 May 2005 03:06:55 -0000 1.13 @@ -51,13 +51,13 @@ sub get_currency { # first, let's get the exchange rate my $rate; if(!defined $SOAP) { - unless($SOAP = new SOAP::Lite - -> service(WSDL_FILE_LOCATION) - ->transport->timeout(5)) + unless($SOAP = SOAP::Lite->new( + service => WSDL_FILE_LOCATION)) { &SimBot::send_message($channel, "$nick: Sorry, but I am having trouble accessing my source for currency conversions. Please try again later."); return; } +# $SOAP->transport->timeout(5); } if(eval { $rate = $SOAP->getRate($from_currency, $to_currency) } && defined $rate) { &SimBot::send_message($channel, "$nick: $orig_amount $from_currency is " |
|
From: Kevin S. <ks...@us...> - 2005-05-14 22:41:37
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28019/plugins Modified Files: weather.pl Log Message: Wind Gusts seem like useful information for those of us in Chicago. Index: weather.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/weather.pl,v retrieving revision 1.90 retrieving revision 1.91 diff -u -d -p -r1.90 -r1.91 --- weather.pl 14 May 2005 00:28:25 -0000 1.90 +++ weather.pl 14 May 2005 22:41:27 -0000 1.91 @@ -428,6 +428,9 @@ sub got_metar { } else { $tmp .= ' variable winds'; } + if ($m->WIND_GUST_MPH) { + $tmp .= ' gusting to ' . &speed($m->WIND_GUST_MPH, 'MPH', $flags); + } push(@reply_with, $tmp); } |
|
From: Pete P. <fou...@us...> - 2005-05-14 00:28:44
|
Update of /cvsroot/simbot/simbot/tools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10873/tools Modified Files: create_wx_station_db.pl Log Message: - Remove XML current conditions reports. They don't tell us anything METAR doesn't, and are often further behind. - Fix &distance... 'course, it isn't called anymore, but that'll change soon. - Remove url column from the weather db. Index: create_wx_station_db.pl =================================================================== RCS file: /cvsroot/simbot/simbot/tools/create_wx_station_db.pl,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -p -r1.4 -r1.5 --- create_wx_station_db.pl 7 May 2005 18:39:41 -0000 1.4 +++ create_wx_station_db.pl 14 May 2005 00:28:26 -0000 1.5 @@ -53,8 +53,7 @@ CREATE TABLE stations ( state STRING, country STRING, latitude REAL, - longitude REAL, - url STRING + longitude REAL ); EOT @@ -112,37 +111,6 @@ if($response->is_error) { print " Done! Read $line_count lines\n" } -# now let's get the XML data file. -# this only has US stations, and generally lacks lat/long. - -print "Downloading XML station list... "; -$response = $ua->get('http://www.nws.noaa.gov/data/current_obs/index.xml'); - -if($response->is_error) { - print STDERR "Failed!\n " . $response->code . ' ' - . $response->message . "\n"; -} else { - print "Done!\nReading it in"; - my $xml; - if (!eval { $xml = XMLin($response->decoded_content, SuppressEmpty => 1); }) { - print STDERR " Failed!\n$@\n"; - } else { - my $update_station_query = $dbh->prepare( - 'UPDATE stations SET url = ? WHERE id = ?'); - my $line_count = 0; - foreach my $cur_station (@{$xml->{'station'}}) { - if(++$line_count % 300 == 0) { print '.'; } - no warnings qw( uninitialized ); - - $update_station_query->execute( - $cur_station->{'xml_url'}, - $cur_station->{'station_id'} - ); - } - print " Done! Read $line_count lines\n"; - } -} - # OK, now we have a great list of station codes. However, not all have # METAR reports. Let's find codes to remove... @@ -155,10 +123,9 @@ if($response->is_error) { my $line_count = 0; print "Done!\nReading it in"; - # Stations with URLs are XML stations, we don't care if METAR is unavailable # Create a temprary table as a list of candidates for deletion $dbh->do(<<EOT); -CREATE TEMPORARY TABLE delrows AS SELECT id FROM stations WHERE url IS NULL; +CREATE TEMPORARY TABLE delrows AS SELECT id FROM stations; CREATE UNIQUE INDEX delstationid ON delrows (id); EOT |
|
From: Pete P. <fou...@us...> - 2005-05-14 00:28:44
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10873/plugins Modified Files: weather.pl Log Message: - Remove XML current conditions reports. They don't tell us anything METAR doesn't, and are often further behind. - Fix &distance... 'course, it isn't called anymore, but that'll change soon. - Remove url column from the weather db. Index: weather.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/weather.pl,v retrieving revision 1.89 retrieving revision 1.90 diff -u -d -p -r1.89 -r1.90 --- weather.pl 14 May 2005 00:02:43 -0000 1.89 +++ weather.pl 14 May 2005 00:28:25 -0000 1.90 @@ -82,7 +82,7 @@ use constant PI => 3.1415926; # Flags use constant USING_DEFAULTS => 512; use constant RAW_METAR => 256; -use constant FORCE_METAR => 128; +# => 128; use constant UNITS_METRIC => 64; use constant UNITS_IMPERIAL => 32; use constant UNITS_AUTO => 16; @@ -131,8 +131,7 @@ CREATE TABLE stations ( state STRING, country STRING, latitude REAL, - longitude REAL, - url STRING + longitude REAL ); CREATE UNIQUE INDEX stationid @@ -155,7 +154,6 @@ EOT _start => \&bootstrap, do_wx => \&do_wx, got_metar => \&got_metar, - got_xml => \&got_xml, get_alerts => \&get_alerts, got_alerts => \&got_alerts, shutdown => \&shutdown, @@ -255,31 +253,7 @@ sub do_wx { } $station = uc($station); - - # Try to look up the station in the database. - # if it is there, check for a URL - # if there is no URL, it's metar, go do that - # if there is a URL, it's XML, go do that - # if it is not there, it's metar, go do that. - my $query = $dbh->prepare_cached( - 'SELECT url FROM stations' - . ' WHERE id = ?' - ); - $query->execute($station); - my ($url); - if((($url) = $query->fetchrow_array) - && !($flags & RAW_METAR) - && !($flags & FORCE_METAR) - && (defined $url)) { - my $request = HTTP::Request->new(GET=>$url); - $kernel->post('wxua' => 'request', 'got_xml', - $request, "$nick!$station!$flags"); - - return; - } - - # Damn, guess we need to parse METAR. - $url = + my $url = 'http://weather.noaa.gov/pub/data/observations/metar/stations/' . $station . '.TXT'; my $request = HTTP::Request->new(GET=>$url); @@ -338,6 +312,7 @@ sub got_metar { } else { $station_name = $station; } + $station_name_query->finish; if($flags & RAW_METAR) { &SimBot::send_message(&SimBot::option('network', 'channel'), @@ -566,155 +541,6 @@ sub got_metar { "$nick: $reply"); } -sub got_xml { - my ($kernel, $request_packet, $response_packet) - = @_[KERNEL, ARG0, ARG1]; - my ($nick, $station, $flags) - = (split(/!/, $request_packet->[1], 3)); - my $response = $response_packet->[0]; - - # NOAA tries to be very helpful by offering a "did you mean?" list - # returning an HTTP 300 response, instead of a 404 error. This is - # annoying when we are not a human being. It also means we get an - # HTTP 301 redirection if we have a similar METAR ID with only one - # suitable alternative. I have a feeling that if NOAA is trying to - # give us a 3xx response, it'll be for a different report than the - # user asked for, so we're going to trust the user knows what he - # wants rather than letting NOAA's web server decide for him. - if ($response->code eq '404' || $response->code =~ /^3/) { - &SimBot::debug(3, - "weather: Couldn't get XML weather for $station; falling back to METAR.\n"); - 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"); - return; - } elsif ($response->is_error) { - &SimBot::debug(3, "weather: Couldn't get XML weather for $station: " . $response->code . " " . $response->message . "\n"); - &SimBot::send_message(&SimBot::option('network', 'channel'), "$nick: " . CANNOT_ACCESS); - return; - } - - &SimBot::debug(4, 'weather: Got XML weather for ' . $nick - . " for $station\n"); - my $raw_xml = $response->content; - my $cur_obs; - - # If this XML feed is unparsable, METAR /may/ be more useful. - # Hey, it sure beats die(). - if (!eval { $cur_obs = XMLin($raw_xml, SuppressEmpty => 1, NormaliseSpace => 2); }) { - &SimBot::debug(3, "weather: XML parse error for $station; falling back to METAR.\n"); - &SimBot::debug(4, "weather: XML parser failure: $@"); - 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"); - return; - } - - my $u_time = $cur_obs->{'observation_time'}; - my $location = $cur_obs->{'location'}; - my $weather = $cur_obs->{'weather'}; - my $temp = $cur_obs->{'temp_c'}; - my $rhumid = $cur_obs->{'relative_humidity'}; - my $wdir = $cur_obs->{'wind_dir'}; - my $wmph = $cur_obs->{'wind_mph'}; - my $wgust = $cur_obs->{'wind_gust_mph'}; - my $hidx = $cur_obs->{'heat_index_c'}; - my $wchill = $cur_obs->{'windchill_c'}; - my $visibility = $cur_obs->{'visibility'}; - - my $msg = 'As reported '; - my @reply_with; - - if(defined $u_time) { - $u_time =~ s/Last Updated on //; - $msg .= 'on ' . $u_time . ' '; - } - - if(defined $location) { $msg .= 'at ' . $location; } - else { $msg .= 'at ' . $station; } - - if(defined $weather && $weather !~ m/^null$/i) { - $weather = lc($weather); - - $weather =~ s/haze/hazy/; - $weather =~ s/^(rain|snow)$/$1ing/; - $weather =~ s/^thunderstorm$/a thunderstorm/; - - if ($weather =~ m/not applicable|na/) - { $msg .= ' it is '; } - elsif($weather =~ m/ing$/) - { $msg .= " it is $weather and "; } - elsif($weather =~ m/^(patches of) / # was (a|patches of) - || $weather =~ m/showers|clouds/) - { $msg .= " there are $weather and "; } - elsif($weather =~ m/fog|smoke|rain|dust|sand|thunderstorm/) - { $msg .= " there is $weather and "; } - - else - { $msg .= " it is $weather and "; } - } else { - $msg .= ' it is '; - } - - if(defined $temp) { $msg .= &temp($temp, 'C', $flags); } - - $msg .= ', with'; - - if(defined $hidx && $hidx !~ m/(Not Applicable|null)/i && $hidx > $temp) { - push(@reply_with, 'a heat index of ' . &temp($hidx, 'C', $flags)); - } - - if(defined $wchill && $wchill !~ m/(Not Applicable|null)/i && $wchill < $temp) { - push(@reply_with, 'a wind chill of ' . &temp($wchill, 'C', $flags)); - } - - if(defined $rhumid && $rhumid != 0) { - push(@reply_with, "${rhumid}% humidity"); - } - - if(defined $wmph) { - my $mmsg = ''; - if($wmph <= 0) { - $mmsg = 'calm winds'; - if(defined $wgust && $wgust > 0) - { $mmsg .= ' gusting to ' . &speed($wgust, 'MPH', $flags) - . " from the $wdir"; } - } else { - if($wdir =~ m/Variable/i) - { $mmsg = 'variable ' }; - $mmsg .= &speed($wmph, 'MPH', $flags) . ' winds'; - if($wdir !~ m/Variable/i) - { $mmsg .= " from the $wdir"; } - if(defined $wgust && $wgust > 0) - { $mmsg .= ' gusting to ' . &speed($wgust, 'MPH', $flags); } - } - push(@reply_with, $mmsg); - } - - if(defined $visibility && $visibility !~ m/(Not Applicable|null)/i) { - my ($vis, $vis_unit) = $visibility =~ m/^([\d\.]+)\s([a-z]+)/i; - push(@reply_with, &distance($vis, $vis_unit, $flags) . ' visibility'); - } - - my $sep; - if($#reply_with == 1) { - $sep = ' and '; - } elsif($#reply_with > 1) { - $sep = ', '; - $reply_with[-1] = 'and ' . $reply_with[-1]; - } - $msg .= ' ' . join($sep, @reply_with); - - &SimBot::send_message(&SimBot::option('network', 'channel'), - "$nick: $msg"); -} - sub got_alerts { my ($kernel, $request_packet, $response_packet) = @_[KERNEL, ARG0, ARG1]; @@ -940,7 +766,6 @@ sub handle_user_command { if($command =~ /^.metar$/) { $flags |= RAW_METAR | DO_CONDITIONS; } foreach(@args) { - if(m/^metar$/) { $flags |= FORCE_METAR | DO_CONDITIONS; } if(m/^m(etric)?$/) { $flags |= UNITS_METRIC; } if(m/^f(ore)?cast$/) { $flags |= DO_FORECAST | DO_ALERTS; } if(m/^(us|imp(erial)?)$/) { $flags |= UNITS_IMPERIAL; } @@ -1127,11 +952,11 @@ sub distance { warn "unit missing or invalid in distance, called from $caller[3] line $caller[2]"; return $dist; } - if( ($unit =~ m/mi/i && $flags & UNITS_METRIC) - || ($unit =~ m/km/i && $flags & UNITS_IMPERIAL)) + if( ($unit =~ m/km/i && $flags & UNITS_METRIC) + || ($unit =~ m/mi/i && $flags & UNITS_IMPERIAL)) { # Distance is already in the desired units. - return (int $dist) . ($flags & NO_UNITS ? '' : $unit); + return (int $dist) . ($flags & NO_UNITS ? '' : ' ' . $unit); } my ($dist_mi, $dist_km); |
|
From: Pete P. <fou...@us...> - 2005-05-14 00:02:53
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7125/plugins Modified Files: weather.pl Log Message: Getting the forecast now times out properly. Would NOAA take a donation of a faster server? Index: weather.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/weather.pl,v retrieving revision 1.88 retrieving revision 1.89 diff -u -d -p -r1.88 -r1.89 --- weather.pl 10 May 2005 02:45:53 -0000 1.88 +++ weather.pl 14 May 2005 00:02:43 -0000 1.89 @@ -808,14 +808,19 @@ sub get_forecast { my $weather = SOAP::Lite->new(uri => $soapAction, proxy => $endpoint); $weather->transport->timeout(8); - my $response = $weather->call( - SOAP::Data->name($method) - => SOAP::Data->type(decimal => $lat )->name('latitude'), - => SOAP::Data->type(decimal => $long )->name('longitude'), - => SOAP::Data->type(date => $startDate)->name('startDate'), - => SOAP::Data->type(integer => $numDays )->name('numDays'), - => SOAP::Data->type(string => $format )->name('format') - ); + my $response; + if(!eval { + $response = $weather->call( + SOAP::Data->name($method) + => SOAP::Data->type(decimal => $lat )->name('latitude'), + => SOAP::Data->type(decimal => $long )->name('longitude'), + => SOAP::Data->type(date => $startDate)->name('startDate'), + => SOAP::Data->type(integer => $numDays )->name('numDays'), + => SOAP::Data->type(string => $format )->name('format') + ); + }) { + return 'I cannot contact NOAA. Please try again later.'; + } if ($response->fault) { return 'Something unexpected happened: ' . $response->faultstring; |
|
From: Pete P. <fou...@us...> - 2005-05-13 02:03:40
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28003/plugins Modified Files: google.pl Log Message: We now understand half stars. Index: google.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/google.pl,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -p -r1.19 -r1.20 --- google.pl 12 May 2005 12:32:18 -0000 1.19 +++ google.pl 13 May 2005 02:03:22 -0000 1.20 @@ -83,14 +83,19 @@ sub google_find { # Movies! # Let's count the stars... - my @star_list = $response->content =~ m{<nobr><img src="/images/showtimes-star-(on|off)\.gif" border=0><img src="/images/showtimes-star-(on|off)\.gif" border=0><img src="/images/showtimes-star-(on|off)\.gif" border=0><img src="/images/showtimes-star-(on|off)\.gif" border=0><img src="/images/showtimes-star-(on|off)\.gif" border=0></nobr>}; + my @star_list = $response->content =~ m{<nobr><img src="/images/showtimes-star-(on|off|half)\.gif" border=0><img src="/images/showtimes-star-(on|off|half)\.gif" border=0><img src="/images/showtimes-star-(on|off|half)\.gif" border=0><img src="/images/showtimes-star-(on|off|half)\.gif" border=0><img src="/images/showtimes-star-(on|off|half)\.gif" border=0></nobr>}; my $stars; - if ($star_list[4] eq 'on') { $stars = 5; } - elsif($star_list[3] eq 'on') { $stars = 4; } - elsif($star_list[2] eq 'on') { $stars = 3; } - elsif($star_list[1] eq 'on') { $stars = 2; } - elsif($star_list[0] eq 'on') { $stars = 1; } - else { $stars = 0; } + if ($star_list[4] eq 'on') { $stars = 5; } + elsif($star_list[4] eq 'half') { $stars = 4.5; } + elsif($star_list[3] eq 'on') { $stars = 4; } + elsif($star_list[3] eq 'half') { $stars = 3.5; } + elsif($star_list[2] eq 'on') { $stars = 3; } + elsif($star_list[2] eq 'half') { $stars = 2.5; } + elsif($star_list[1] eq 'on') { $stars = 2; } + elsif($star_list[1] eq 'half') { $stars = 1.5; } + elsif($star_list[0] eq 'on') { $stars = 1; } + elsif($star_list[0] eq 'half') { $stars = 0.5; } + else { $stars = 0; } my ($url, $title) = $response->content =~ m|<td valign=top><a href="(/reviews?\S+)">(.*?)</a>|; $url = 'http://www.google.com' . $url; |
|
From: Kevin S. <ks...@us...> - 2005-05-12 12:32:27
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17598/plugins Modified Files: google.pl Log Message: Fixed the define: queries again, and added a little code to eat any possible extra "term is" from the beginning of the result. Index: google.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/google.pl,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -p -r1.18 -r1.19 --- google.pl 4 May 2005 20:39:05 -0000 1.18 +++ google.pl 12 May 2005 12:32:18 -0000 1.19 @@ -65,8 +65,8 @@ sub google_find { &SimBot::send_message($channel, "$nick: $result"); } elsif ($response->content =~ m|Definitions of <b>(.*?)</b> on the Web:|) { my $term = $1; - if ($response->content =~ m/<li>(.*?)(<br>|<li>)/) { - my $result = $1; + if ($response->content =~ m/<li>($term is )?(.*?)\n?(<br>|<li>)/i) { + my $result = $2; $result =~ s|[\n\r]||g; $result = HTML::Entities::decode($result); &SimBot::send_pieces($channel, "$nick: ", "\"$term\" is $result"); |
|
From: Kevin S. <ks...@us...> - 2005-05-10 15:30:12
|
Update of /cvsroot/simbot/simbot/data In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7319/data Modified Files: errors.db Log Message: Ray: Error 500: Cannot find bean cart in any scope Me: ? Ray: Nextel's shopping cart gives me that error Index: errors.db =================================================================== RCS file: /cvsroot/simbot/simbot/data/errors.db,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -p -r1.2 -r1.3 --- errors.db 6 May 2005 21:15:54 -0000 1.2 +++ errors.db 10 May 2005 15:30:01 -0000 1.3 @@ -27,3 +27,4 @@ The application "unknown" has unexpected You must type a file name. X connection to localhost:10.0 broken (explicit kill or server shutdown). Broken pipe +Error 500: Cannot find bean cart in any scope |
|
From: Pete P. <fou...@us...> - 2005-05-10 02:46:04
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4706/plugins Modified Files: weather.pl Log Message: - Give NOAA 8 seconds to give us weather. This is normally enough, and I don't want to block simbot for longer. - Distance is now unit converted for visibility. I'll make cloud heights work next. Maybe snow increasing rapidly, although I've *never* seen that message used. Index: weather.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/weather.pl,v retrieving revision 1.87 retrieving revision 1.88 diff -u -d -p -r1.87 -r1.88 --- weather.pl 9 May 2005 23:26:28 -0000 1.87 +++ weather.pl 10 May 2005 02:45:53 -0000 1.88 @@ -479,7 +479,8 @@ sub got_metar { $cond = lc($cond); my $rmk = $cond; - if($dist) { $rmk .= " $dist mi to the $dir"; } + if($dist) { $rmk .= &dist($dist, 'mi', $flags) + . " to the $dir"; } push(@reply_with, $rmk); } @@ -665,11 +666,11 @@ sub got_xml { $msg .= ', with'; - if(defined $hidx && $hidx !~ m/(Not Applicable|null)/i) { + if(defined $hidx && $hidx !~ m/(Not Applicable|null)/i && $hidx > $temp) { push(@reply_with, 'a heat index of ' . &temp($hidx, 'C', $flags)); } - if(defined $wchill && $wchill !~ m/(Not Applicable|null)/i) { + if(defined $wchill && $wchill !~ m/(Not Applicable|null)/i && $wchill < $temp) { push(@reply_with, 'a wind chill of ' . &temp($wchill, 'C', $flags)); } @@ -697,7 +698,8 @@ sub got_xml { } if(defined $visibility && $visibility !~ m/(Not Applicable|null)/i) { - push(@reply_with, "$visibility visibility"); + my ($vis, $vis_unit) = $visibility =~ m/^([\d\.]+)\s([a-z]+)/i; + push(@reply_with, &distance($vis, $vis_unit, $flags) . ' visibility'); } my $sep; @@ -805,6 +807,7 @@ sub get_forecast { my $weather = SOAP::Lite->new(uri => $soapAction, proxy => $endpoint); + $weather->transport->timeout(8); my $response = $weather->call( SOAP::Data->name($method) => SOAP::Data->type(decimal => $lat )->name('latitude'), @@ -1110,6 +1113,45 @@ sub speed { return (int $speed_mph) . ($flags & NO_UNITS ? '' : ' MPH'). ' (' . (int $speed_kmh) . ($flags & NO_UNITS ? '' : ' km/h') . ')'; } +sub distance { + my ($dist, $unit, $flags) = @_; + if(!defined $unit + || $unit !~ m/mi|km/i) + { + my @caller = caller(1); + warn "unit missing or invalid in distance, called from $caller[3] line $caller[2]"; + return $dist; + } + if( ($unit =~ m/mi/i && $flags & UNITS_METRIC) + || ($unit =~ m/km/i && $flags & UNITS_IMPERIAL)) + { + # Distance is already in the desired units. + return (int $dist) . ($flags & NO_UNITS ? '' : $unit); + } + + my ($dist_mi, $dist_km); + if($unit =~ /km/i) { + $dist_km = $dist; + $dist_mi = $dist * 1.609344; + } elsif($unit =~ /mi/i) { + $dist_mi = $dist; + $dist_km = $dist * 0.621371192; + } + + if($flags & UNITS_METRIC) { + return (int $dist_km) + . ($flags & NO_UNITS ? '' : ' km'); + } + + if($flags & UNITS_IMPERIAL) { + return (int $dist_mi) + . ($flags & NO_UNITS ? '' : ' mi'); + } + + return (int $dist_mi) . ($flags & NO_UNITS ? '' : ' mi') + . ' (' . (int $dist_km) . ($flags & NO_UNITS ? '' : ' km') . ')'; +} + # Register Plugins &SimBot::plugin_register( plugin_id => "weather", |
|
From: Kevin S. <ks...@us...> - 2005-05-10 02:26:05
|
Update of /cvsroot/simbot/simbot In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1647 Modified Files: simbot.pl Log Message: Currency was failing to load and yet, the plugin was still registered, because the code was ordered badly. :) Index: simbot.pl =================================================================== RCS file: /cvsroot/simbot/simbot/simbot.pl,v retrieving revision 1.114 retrieving revision 1.115 diff -u -d -p -r1.114 -r1.115 --- simbot.pl 5 May 2005 03:29:39 -0000 1.114 +++ simbot.pl 10 May 2005 02:25:57 -0000 1.115 @@ -824,6 +824,12 @@ sub plugin_register { } else { die("$data{plugin_id}: a plugin is already registered to this handle"); } + if ($data{event_plugin_load}) { + if (!&plugin_callback($data{plugin_id}, $data{event_plugin_load})) { + die("$data{plugin_id}: the plugin returned an error on load"); + } + + } $event_plugin_call{$data{plugin_id}} = $data{event_plugin_call}; if(!$data{plugin_help}) { &debug(5, $data{plugin_id} . ": this plugin has no help text and will be hidden\n"); @@ -831,12 +837,6 @@ sub plugin_register { $plugin_help{$data{plugin_id}} = $data{plugin_help}; } $plugin_params{$data{plugin_id}} = $data{plugin_params}; - if ($data{event_plugin_load}) { - if (!&plugin_callback($data{plugin_id}, $data{event_plugin_load})) { - die("$data{plugin_id}: the plugin returned an error on load"); - } - - } foreach (keys(%data)) { if ($_ =~ /^event_(plugin|bot|channel|private|server)_.*/) { $$_{$data{plugin_id}} = $data{$_}; |
|
From: Pete P. <fou...@us...> - 2005-05-10 02:23:11
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1060/plugins Modified Files: currency.pl Log Message: Defer creation of the SOAP object until it's first needed. This'll defer the annoying delay when the server is down, so at least SimBot will start in a reasonable time. Index: currency.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/currency.pl,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -p -r1.11 -r1.12 --- currency.pl 8 May 2005 11:44:59 -0000 1.11 +++ currency.pl 10 May 2005 02:23:02 -0000 1.12 @@ -40,12 +40,6 @@ use constant WSDL_FILE_LOCATION use SOAP::Lite; use vars qw( $SOAP ); -sub messup_currency { - $SOAP = new SOAP::Lite - -> service(WSDL_FILE_LOCATION) - or die "Could not set up SOAP::Lite"; -} - sub get_currency { my ($kernel, $nick, $channel, $self, $orig_amount, $from_currency, $to_currency) = @_; @@ -56,6 +50,15 @@ sub get_currency { # first, let's get the exchange rate my $rate; + if(!defined $SOAP) { + unless($SOAP = new SOAP::Lite + -> service(WSDL_FILE_LOCATION) + ->transport->timeout(5)) + { + &SimBot::send_message($channel, "$nick: Sorry, but I am having trouble accessing my source for currency conversions. Please try again later."); + return; + } + } if(eval { $rate = $SOAP->getRate($from_currency, $to_currency) } && defined $rate) { &SimBot::send_message($channel, "$nick: $orig_amount $from_currency is " . $orig_amount * $rate . " $to_currency"); @@ -71,5 +74,5 @@ sub get_currency { '%bold%<amount>%bold% is the amount of currency to exchange %bold%<from country>%bold% and %bold%<to country>%bold% are the %uline%countries%uline% to exchange currency between', event_plugin_call => \&get_currency, - event_plugin_load => \&messup_currency, + #event_plugin_load => \&messup_currency, ); |
|
From: Pete P. <fou...@us...> - 2005-05-09 23:26:41
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29239/plugins Modified Files: weather.pl Log Message: I really should look for warn statements before committing... Index: weather.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/weather.pl,v retrieving revision 1.86 retrieving revision 1.87 diff -u -d -p -r1.86 -r1.87 --- weather.pl 9 May 2005 23:03:20 -0000 1.86 +++ weather.pl 9 May 2005 23:26:28 -0000 1.87 @@ -752,7 +752,6 @@ sub got_alerts { foreach my $cur_cap_info (@{$cap_alert->{'cap:info'}}) { - warn $cur_cap_info->{'cap:area'}->{'cap:geocode'} . " $geocode"; if(defined $cur_cap_info->{'cap:area'}->{'cap:geocode'} && $cur_cap_info->{'cap:area'}->{'cap:geocode'} == $geocode) { |
|
From: Pete P. <fou...@us...> - 2005-05-09 23:03:29
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23685/plugins Modified Files: weather.pl Log Message: - Misplaced comment - Filter out airfield quality color code Index: weather.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/weather.pl,v retrieving revision 1.85 retrieving revision 1.86 diff -u -d -p -r1.85 -r1.86 --- weather.pl 9 May 2005 21:34:19 -0000 1.85 +++ weather.pl 9 May 2005 23:03:20 -0000 1.86 @@ -320,8 +320,6 @@ sub got_metar { } my (undef, $raw_metar) = split(/\n/, $response->content); - # Geo::METAR has issues not ignoring the remarks section of the - # METAR report. Let's strip it out. &SimBot::debug(4, "weather: METAR is " . $raw_metar . "\n"); my $station_name_query = $dbh->prepare_cached( @@ -346,13 +344,15 @@ sub got_metar { "$nick: METAR report for $station_name is $raw_metar."); return; } - - my $wind_mph; - + + + # 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; @@ -369,6 +369,7 @@ 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"; |
|
From: Pete P. <fou...@us...> - 2005-05-09 21:34:30
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1707/plugins Modified Files: weather.pl Log Message: Using ForceArray properly helps. Also, this code worked before... I need to see more feeds to know this change will continue working, in case some feeds don't use cap:area. Index: weather.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/weather.pl,v retrieving revision 1.84 retrieving revision 1.85 diff -u -d -p -r1.84 -r1.85 --- weather.pl 9 May 2005 03:12:48 -0000 1.84 +++ weather.pl 9 May 2005 21:34:19 -0000 1.85 @@ -735,7 +735,7 @@ sub got_alerts { my $cap_alert; - if (!eval { $cap_alert = XMLin($raw_xml, NormaliseSpace => 2, ForceArray => ('cap:info')); }) { + if (!eval { $cap_alert = XMLin($raw_xml, NormaliseSpace => 2, ForceArray => ['cap:info']); }) { &SimBot::debug(3, "weather: XML parse error for alerts\n"); &SimBot::debug(4, "weather: XML parser failure: $@"); @@ -749,9 +749,11 @@ sub got_alerts { my @alerts; my @alerts_link; + foreach my $cur_cap_info (@{$cap_alert->{'cap:info'}}) { - if(defined $cur_cap_info->{'geocode'} - && $cur_cap_info->{'geocode'} == $geocode) + warn $cur_cap_info->{'cap:area'}->{'cap:geocode'} . " $geocode"; + if(defined $cur_cap_info->{'cap:area'}->{'cap:geocode'} + && $cur_cap_info->{'cap:area'}->{'cap:geocode'} == $geocode) { # We have a warning! push(@alerts, $cur_cap_info->{'cap:event'}); |
|
From: Pete P. <fou...@us...> - 2005-05-09 03:12:59
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32084/plugins Modified Files: weather.pl Log Message: Some comments, some dead code removal, and a pinch of OCD. Season to taste. Index: weather.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/weather.pl,v retrieving revision 1.83 retrieving revision 1.84 diff -u -d -p -r1.83 -r1.84 --- weather.pl 9 May 2005 02:53:00 -0000 1.83 +++ weather.pl 9 May 2005 03:12:48 -0000 1.84 @@ -158,7 +158,6 @@ EOT got_xml => \&got_xml, get_alerts => \&get_alerts, got_alerts => \&got_alerts, - got_station_name => \&got_station_name, shutdown => \&shutdown, } ); @@ -186,7 +185,7 @@ sub do_wx { || $flags & DO_ALERTS || $flags & DO_FORECAST) { &SimBot::send_message(&SimBot::option('network', 'channel'), - "$nick: Sorry, something unexpected happened. This has been logged, please try again later."); + "$nick: Sorry, something unexpected happened. This has been logged; please try again later."); &SimBot::debug(1, "weather: in do_wx with nothing to do!\n"); return; } @@ -198,6 +197,9 @@ sub do_wx { { $postalcode = $1; } # UK elsif($location =~ /^[A-Z0-9]{4}$/i) { $station = $location; } + + # OK, now we know what location specification the user gave us. + # now let's try to figure out the other location information if(defined $station) { # try to get lat/long/state from the station my $query = $dbh->prepare_cached( @@ -227,10 +229,15 @@ sub do_wx { $station = &find_closest_station($postalcode); } + # OK, we have all the locations we're gonna get. + # Now let's try to do what we were asked to + if($flags & DO_ALERTS) { if(defined $state && defined $geocode) { $kernel->post($session => 'get_alerts', $nick, $lat, $long, $state, $geocode, $flags); } elsif(!($flags & USING_DEFAULTS)) { + # If we don't have enough information to do the forecast or + # alerts, only complain if we aren't using the default options. &SimBot::send_message(&SimBot::option('network', 'channel'), "$nick: Sorry, but I have no forecast for that location."); } @@ -254,13 +261,13 @@ sub do_wx { # if there is no URL, it's metar, go do that # if there is a URL, it's XML, go do that # if it is not there, it's metar, go do that. - my $query = $dbh->prepare( - 'SELECT name, url FROM stations' + my $query = $dbh->prepare_cached( + 'SELECT url FROM stations' . ' WHERE id = ?' ); $query->execute($station); - my ($station_name, $url); - if((($station_name, $url) = $query->fetchrow_array) + my ($url); + if((($url) = $query->fetchrow_array) && !($flags & RAW_METAR) && !($flags & FORCE_METAR) && (defined $url)) { @@ -271,24 +278,7 @@ sub do_wx { return; } - # Damn, guess we need to parse METAR. - - # do we have a station name? - unless(defined $station_name) { - &SimBot::debug(4, - "weather: Station name not found, looking it up\n"); - my $url = - 'http://weather.noaa.gov/cgi-bin/nsd_lookup.pl?station=' - . $station; - my $request = HTTP::Request->new(GET => $url); - $kernel->post('wxua' => 'request', 'got_station_name', - $request, "$nick!$station!$flags"); - # We're done here - got_station_name will handle requesting - # the weather - return; - } - # we already have the station name... let's request the weather - + # Damn, guess we need to parse METAR. $url = 'http://weather.noaa.gov/pub/data/observations/metar/stations/' . $station . '.TXT'; @@ -298,63 +288,9 @@ sub do_wx { } if($flags & DO_FORECAST && defined $lat) { - - } -} - -sub got_station_name { - my ($kernel, $request_packet, $response_packet) - = @_[KERNEL, ARG0, ARG1]; - my ($nick, $station, $flags) - = (split(/!/, $request_packet->[1], 3)); - my $response = $response_packet->[0]; - - if (!$response->is_error - && $response->content !~ /The supplied value is invalid/ - && $response->content !~ /No station matched the supplied identifier/) - { - - my ($name) = $response->content =~ m|Station Name:.*?<B>(.*?)\s*</B>|s; - $response->content =~ m|State:.*?<B>(.*?)\s*</B>|s; - my $state = ($1 eq $name ? undef : $1); - my ($country) = $response->content =~ m|Country:.*?<B>(.*?)\s*</B>|s; - - my ($lat_deg, $lat_min, $lat_sec, $lat_dir, - $long_deg, $long_min, $long_sec, $long_dir); - if(($lat_deg, $lat_min, $lat_sec, $lat_dir, - $long_deg, $long_min, $long_sec, $long_dir) = - $response->content =~ m|Station Position:.*?<B>(\d+)-(\d+)(?:-(\d+))?([NS]).*?(\d+)-(\d+)(?:-(\d+))?([EW])|s) - { - $lat_deg = &dms_to_degrees($lat_deg, $lat_min, $lat_sec, $lat_dir); - $long_deg = &dms_to_degrees($long_deg, $long_min, $long_sec, $long_dir); - } - - my $update_station_query = $dbh->prepare( - 'INSERT OR REPLACE INTO stations (id, name, state, country, latitude, longitude, url)' - . ' VALUES (?,?,?,?,?,?,?)'); - - { - no warnings qw( uninitialized ); - $update_station_query->execute( - $station, - $name, - $state, - $country, - $lat_deg, - $long_deg, - undef # URL is undef for metar - ); - } - $dbh->commit; + # Right now, forecast is handled as part of alerts. + # FIXME: This should change. } - &SimBot::debug(4, "weather: Got station name for $station\n"); - # ok, now we have the station name... let's request the weather - 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"); } sub got_metar { @@ -388,7 +324,7 @@ sub got_metar { # METAR report. Let's strip it out. &SimBot::debug(4, "weather: METAR is " . $raw_metar . "\n"); - my $station_name_query = $dbh->prepare( + my $station_name_query = $dbh->prepare_cached( 'SELECT name, state, country FROM stations' . ' WHERE id = ?'); $station_name_query->execute($station); @@ -438,7 +374,7 @@ sub got_metar { my $time = "$2:$3"; my $day=$1; - my $reply = "As reported at $time GMT at $station_name"; + my $reply = "As reported at $time UTC at $station_name"; my @reply_with; # There's no point in this exercise unless there's data in there @@ -645,7 +581,7 @@ sub got_xml { # wants rather than letting NOAA's web server decide for him. if ($response->code eq '404' || $response->code =~ /^3/) { &SimBot::debug(3, - "weather: Couldn't get XML weather for $station; falling back to METAR.\n"); + "weather: Couldn't get XML weather for $station; falling back to METAR.\n"); my $url = 'http://weather.noaa.gov/pub/data/observations/metar/stations/' . $station . '.TXT'; @@ -703,7 +639,6 @@ sub got_xml { if(defined $weather && $weather !~ m/^null$/i) { $weather = lc($weather); -# $weather =~ s/^\s*//; # sometimes they have a space in front $weather =~ s/haze/hazy/; $weather =~ s/^(rain|snow)$/$1ing/; @@ -919,12 +854,13 @@ sub get_forecast { } my (@temp_highs, @temp_lows, $temp_highs_unit, $temp_lows_unit); + my $temp_key = $forecast->{'data'}->{'parameters'}->{'temperature'}; - @temp_highs = @{$forecast->{'data'}->{'parameters'}->{'temperature'}->{'maximum'}->{'value'}}; - $temp_highs_unit = $forecast->{'data'}->{'parameters'}->{'temperature'}->{'maximum'}->{'units'}; - @temp_lows = @{$forecast->{'data'}->{'parameters'}->{'temperature'}->{'minimum'}->{'value'}}; - $temp_lows_unit = $forecast->{'data'}->{'parameters'}->{'temperature'}->{'minimum'}->{'units'}; - + @temp_highs = @{$temp_key->{'maximum'}->{'value'}}; + $temp_highs_unit = $temp_key->{'maximum'}->{'units'}; + @temp_lows = @{$temp_key->{'minimum'}->{'value'}}; + $temp_lows_unit = $temp_key->{'minimum'}->{'units'}; + my @conditions; foreach my $cur_weather_conditions (@{$forecast->{'data'}->{'parameters'}->{'weather'}->{'weather-conditions'}}) { push(@conditions, $cur_weather_conditions->{'weather-summary'}); @@ -1030,7 +966,7 @@ sub find_closest_station { my ($zipcode) = @_; # OK, we need the lat/long for that zip code. - my $query = $postalcodes_dbh->prepare( + my $query = $postalcodes_dbh->prepare_cached( 'SELECT latitude, longitude FROM postalcodes WHERE code = ?' ); $query->execute($zipcode); @@ -1039,7 +975,7 @@ sub find_closest_station { $query->finish; # OK, now we need to find potential stations. - $query = $dbh->prepare( + $query = $dbh->prepare_cached( 'SELECT id, latitude, longitude FROM stations' . ' WHERE latitude BETWEEN ? AND ?' . ' AND longitude BETWEEN ? AND ?'); |
|
From: Pete P. <fou...@us...> - 2005-05-09 02:53:09
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28546/plugins Modified Files: weather.pl Log Message: XML weather forecasts now use the unit conversion stuff and honor the metric and imperial arguments to %weather. Index: weather.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/weather.pl,v retrieving revision 1.82 retrieving revision 1.83 diff -u -d -p -r1.82 -r1.83 --- weather.pl 8 May 2005 02:35:44 -0000 1.82 +++ weather.pl 9 May 2005 02:53:00 -0000 1.83 @@ -210,6 +210,7 @@ sub do_wx { # FIXME: OK, now try to get the geocode from the lat/long # (find nearest zip, use it's geocode) + # this would allow %weather kbdl forecast to work } if(defined $postalcode) { # try to get lat/long/state/geocode from the postalcode db @@ -265,7 +266,7 @@ sub do_wx { && (defined $url)) { my $request = HTTP::Request->new(GET=>$url); $kernel->post('wxua' => 'request', 'got_xml', - $request, "$nick!$station"); + $request, "$nick!$station!$flags"); return; } @@ -630,8 +631,8 @@ sub got_metar { sub got_xml { my ($kernel, $request_packet, $response_packet) = @_[KERNEL, ARG0, ARG1]; - my ($nick, $station) - = (split(/!/, $request_packet->[1], 2)); + my ($nick, $station, $flags) + = (split(/!/, $request_packet->[1], 3)); my $response = $response_packet->[0]; # NOAA tries to be very helpful by offering a "did you mean?" list @@ -650,7 +651,7 @@ sub got_xml { . $station . '.TXT'; my $request = HTTP::Request->new(GET=>$url); $kernel->post('wxua' => 'request', 'got_metar', - $request, "$nick!$station!0"); + $request, "$nick!$station!$flags"); return; } elsif ($response->is_error) { &SimBot::debug(3, "weather: Couldn't get XML weather for $station: " . $response->code . " " . $response->message . "\n"); @@ -673,20 +674,20 @@ sub got_xml { . $station . '.TXT'; my $request = HTTP::Request->new(GET=>$url); $kernel->post('wxua' => 'request', 'got_metar', - $request, "$nick!$station!0"); + $request, "$nick!$station!$flags"); return; } my $u_time = $cur_obs->{'observation_time'}; my $location = $cur_obs->{'location'}; my $weather = $cur_obs->{'weather'}; - my $temp = $cur_obs->{'temperature_string'}; + my $temp = $cur_obs->{'temp_c'}; my $rhumid = $cur_obs->{'relative_humidity'}; my $wdir = $cur_obs->{'wind_dir'}; my $wmph = $cur_obs->{'wind_mph'}; my $wgust = $cur_obs->{'wind_gust_mph'}; - my $hidx = $cur_obs->{'heat_index_string'}; - my $wchill = $cur_obs->{'windchill_string'}; + my $hidx = $cur_obs->{'heat_index_c'}; + my $wchill = $cur_obs->{'windchill_c'}; my $visibility = $cur_obs->{'visibility'}; my $msg = 'As reported '; @@ -724,16 +725,16 @@ sub got_xml { $msg .= ' it is '; } - if(defined $temp) { $msg .= $temp; } + if(defined $temp) { $msg .= &temp($temp, 'C', $flags); } $msg .= ', with'; if(defined $hidx && $hidx !~ m/(Not Applicable|null)/i) { - push(@reply_with, "a heat index of $hidx"); + push(@reply_with, 'a heat index of ' . &temp($hidx, 'C', $flags)); } if(defined $wchill && $wchill !~ m/(Not Applicable|null)/i) { - push(@reply_with, "a wind chill of $wchill"); + push(@reply_with, 'a wind chill of ' . &temp($wchill, 'C', $flags)); } if(defined $rhumid && $rhumid != 0) { @@ -745,15 +746,16 @@ sub got_xml { if($wmph <= 0) { $mmsg = 'calm winds'; if(defined $wgust && $wgust > 0) - { $mmsg .= " gusting to $wgust MPH from the $wdir"; } + { $mmsg .= ' gusting to ' . &speed($wgust, 'MPH', $flags) + . " from the $wdir"; } } else { if($wdir =~ m/Variable/i) { $mmsg = 'variable ' }; - $mmsg .= "$wmph MPH winds"; + $mmsg .= &speed($wmph, 'MPH', $flags) . ' winds'; if($wdir !~ m/Variable/i) { $mmsg .= " from the $wdir"; } if(defined $wgust && $wgust > 0) - { $mmsg .= " gusting to $wgust MPH"; } + { $mmsg .= ' gusting to ' . &speed($wgust, 'MPH', $flags); } } push(@reply_with, $mmsg); } @@ -888,15 +890,13 @@ sub get_forecast { return 'The forecast could not be parsed. Blame NOAA.'; } - my $params = $forecast->{'data'}->{'parameters'}; - my $layout = $forecast->{'data'}->{'time-layout'}; - my $title = $forecast->{'head'}->{'product'}->{'title'}; - my $info_url = $forecast->{'head'}->{'source'}->{'more-information'}; - my ($maxperiodkey, $minperiodkey, $condsperiodkey); my @days; - # arrays of keys for the time-periods in the forecast + # Find the time layout we care about. This is certainly not the + # Right Way, and if forecast ever breaks, suspect this. + # (We really should be reading in all the time layouts, and reference + # them against the data we care about to find the right one) foreach my $cur_time_layout (@{$forecast->{'data'}->{'time-layout'}}) { if($cur_time_layout->{'layout-key'} =~ m/k-p24h-n\d-1/) { @days = @{$cur_time_layout->{'start-valid-time'}}; |
|
From: Pete P. <fou...@us...> - 2005-05-09 02:06:43
|
Update of /cvsroot/simbot/simbot In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20066 Modified Files: INSTALL Log Message: Oh, yeah, and time.pl requires DateTime. Index: INSTALL =================================================================== RCS file: /cvsroot/simbot/simbot/INSTALL,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -p -r1.21 -r1.22 --- INSTALL 7 May 2005 02:52:30 -0000 1.21 +++ INSTALL 9 May 2005 02:06:34 -0000 1.22 @@ -45,6 +45,9 @@ features in SimBot: SOAP::Lite: For currency.pl + + DateTime: + For time.pl This all, of course, requires that you have Perl installed. |
|
From: Pete P. <fou...@us...> - 2005-05-09 02:02:49
|
Update of /cvsroot/simbot/simbot In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19243 Modified Files: ChangeLog config.default.ini Log Message: New plugin! %time shows you the current time in SimBot-land and wherever else the bot's owner wants to show, %time <zones> shows SimBot-land plus the requested zones. Zones must be offsets (-0500) or <continent>/<city> (America/New_York), or a few other odd formats. Index: ChangeLog =================================================================== RCS file: /cvsroot/simbot/simbot/ChangeLog,v retrieving revision 1.74 retrieving revision 1.75 diff -u -d -p -r1.74 -r1.75 --- ChangeLog 8 May 2005 02:34:35 -0000 1.74 +++ ChangeLog 9 May 2005 02:02:35 -0000 1.75 @@ -1,3 +1,11 @@ +Version 1.0 alpha: (08 May 2005) + * plugins/time.pl: + - New plugin! + - Shows the current time in a number of time zones. + - %time <zones> shows the local time and the requested zones, + otherwise shows local and those defined in config.ini. + Failing that, local and UTC. + Version 1.0 alpha: (07 May 2005) * plugins/weather.pl: - Some unit conversion support. Add 'm' or 'metric' to show metric units, Index: config.default.ini =================================================================== RCS file: /cvsroot/simbot/simbot/config.default.ini,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -p -r1.25 -r1.26 --- config.default.ini 1 May 2005 16:17:39 -0000 1.25 +++ config.default.ini 9 May 2005 02:02:36 -0000 1.26 @@ -215,4 +215,11 @@ title_style=%green% # the default is 'en', which covers both American and British spellings. lang=en +[plugin.time] +# default_zones is the selection of time zones to display when someone calls +# %time with no arguments. The default is UTC. Local time is always shown. +# use commas for multiple, like default_zones=UTC,America/New_York +default_zones=UTC + + # End of Config |
|
From: Pete P. <fou...@us...> - 2005-05-09 02:02:48
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19243/plugins Added Files: time.pl Log Message: New plugin! %time shows you the current time in SimBot-land and wherever else the bot's owner wants to show, %time <zones> shows SimBot-land plus the requested zones. Zones must be offsets (-0500) or <continent>/<city> (America/New_York), or a few other odd formats. --- NEW FILE: time.pl --- ### # SimBot Time Conversion Plugin # # DESCRIPTION: # The TinyURL plugin watches chat for URLs pointing to TinyURL # style services. When one is recognized, it looks up the URL, and # announces in chat where the URL points. # # COPYRIGHT: # Copyright (C) 2005, Pete Pearson # # This program is free software; you can redistribute and/or modify it # under the terms of version 2 of the GNU General Public License as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # TODO: # * Allow the user to specify a time instead of only showing the current package SimBot::plugin::time; use warnings; use strict; use DateTime; use DateTime::TimeZone; sub do_time { my ($kernel, $nick, $channel, undef, @args) = @_; my $now = DateTime->now(); my @zones; foreach my $cur_arg (@args) { if($cur_arg =~ m/^[\+\-]\d{4}$/) { push(@zones, $cur_arg); } if(DateTime::TimeZone->is_valid_name($cur_arg)) { push(@zones, $cur_arg); } } if(!@zones) { if(my $zonelist = &SimBot::option('plugin.time', 'default_zones')) { @zones = split(/,/, $zonelist); } else { @zones = ('UTC'); } } my $msg = "$nick: My clock shows " . $now->set_time_zone('local')->strftime('%l:%M %P %Z'); foreach(@zones) { $msg .= ', ' . $now->set_time_zone($_)->strftime('%l:%M %P %Z'); } &SimBot::send_message($channel, $msg); } &SimBot::plugin_register(plugin_id => 'time', plugin_params => "[<zones>]", plugin_help => 'Gives you the current time in a selection of time zones. <zones>: Display these timezones. Use four digit offsets (+0400 for example) or <continent>/<city> (America/New_York) or US/<zone> (US/Eastern)', event_plugin_call => \&do_time, ); |
|
From: Kevin S. <ks...@us...> - 2005-05-08 11:45:21
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21677/plugins Modified Files: currency.pl Log Message: This should mean that when the currency server times out, it doesn't crash simbot. However, it takes like 5 minutes to time out.... :( Also, I made it so that if you don't specify enough parameters, it tells you to do that. Index: currency.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/currency.pl,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -p -r1.10 -r1.11 --- currency.pl 4 May 2005 19:50:11 -0000 1.10 +++ currency.pl 8 May 2005 11:44:59 -0000 1.11 @@ -49,12 +49,18 @@ sub messup_currency { sub get_currency { my ($kernel, $nick, $channel, $self, $orig_amount, $from_currency, $to_currency) = @_; + if (!defined $to_currency) { + &SimBot::send_message($channel, "$nick: Sorry, you need to specify an amount, followed by the names of countries to covert from and to."); + return; + } + # first, let's get the exchange rate my $rate; - if($rate = $SOAP->getRate($from_currency, $to_currency)) { + if(eval { $rate = $SOAP->getRate($from_currency, $to_currency) } && defined $rate) { &SimBot::send_message($channel, "$nick: $orig_amount $from_currency is " . $orig_amount * $rate . " $to_currency"); } else { + &SimBot::debug(2, "currency: $@") if defined $@; &SimBot::send_message($channel, "$nick: Sorry, something went wrong. Try using a country name instead of a currency name."); } } @@ -66,5 +72,4 @@ sub get_currency { %bold%<from country>%bold% and %bold%<to country>%bold% are the %uline%countries%uline% to exchange currency between', event_plugin_call => \&get_currency, event_plugin_load => \&messup_currency, - ); |
|
From: Pete P. <fou...@us...> - 2005-05-08 02:35:53
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1379/plugins Modified Files: weather.pl Log Message: Updating help Index: weather.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/weather.pl,v retrieving revision 1.81 retrieving revision 1.82 diff -u -d -p -r1.81 -r1.82 --- weather.pl 8 May 2005 02:04:15 -0000 1.81 +++ weather.pl 8 May 2005 02:35:44 -0000 1.82 @@ -1175,9 +1175,9 @@ sub speed { # Register Plugins &SimBot::plugin_register( plugin_id => "weather", - plugin_params => "(<station ID|zip> [metar|raw] [metric|us] | forecast <zip>)", + plugin_params => "(<station ID|zip|postal code> [metar|raw] [metric|us] | forecast <zip>)", plugin_help => -"Gets a weather report for the given station or zip.\nSpecifying %bold%metar%bold% will force the parsing the metar report instead of using the NOAA XML data.\nSpecifying %bold%raw%bold% will show the METAR report in its original form.\nforecast <zip> will get the forecast for that US zip code.", +"Gets a weather report for the given station, zip, or postal code.\nSpecifying %bold%metar%bold% will force the parsing the metar report instead of using the NOAA XML data.\nSpecifying %bold%raw%bold% will show the METAR report in its original form.\nforecast <zip> will get the forecast for that US zip code.", event_plugin_call => \&handle_user_command, event_plugin_load => \&messup_wx, |
|
From: Pete P. <fou...@us...> - 2005-05-08 02:34:45
|
Update of /cvsroot/simbot/simbot In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1162 Modified Files: ChangeLog Log Message: Adding yesterday's and today's changes into the ChangeLog Index: ChangeLog =================================================================== RCS file: /cvsroot/simbot/simbot/ChangeLog,v retrieving revision 1.73 retrieving revision 1.74 diff -u -d -p -r1.73 -r1.74 --- ChangeLog 6 May 2005 00:01:34 -0000 1.73 +++ ChangeLog 8 May 2005 02:34:35 -0000 1.74 @@ -1,3 +1,17 @@ +Version 1.0 alpha: (07 May 2005) + * plugins/weather.pl: + - Some unit conversion support. Add 'm' or 'metric' to show metric units, + 'us' or 'imp' or 'imperial' for imperial units. + - Support for UK post codes + * tools/create_postalcode_db.pl: + - Replaces tools/create_zip_db.pl + - Includes UK post codes + +Version 1.0 alpha: (06 May 2005) + * plugins/weather.pl: + - Support for %weather <zip> to look up the closest station for + current observations. + Version 1.0 alpha: (05 May 2005) * tools/create_zip_db.pl: - Creates the USzip file, a SQLite DB of US zip codes circa 1999 from |
|
From: Pete P. <fou...@us...> - 2005-05-08 02:04:26
|
Update of /cvsroot/simbot/simbot/tools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27037/tools Added Files: create_postcode_db.pl Removed Files: create_zip_db.pl Log Message: Replaced the USzip file with a postalcodes file. We now have UK post codes, and %weather <uk post code> works. --- NEW FILE: create_postcode_db.pl --- #!/usr/bin/perl # SimBot ZIP1999 Data Importer # # DESCRIPTION: # Imports the US Census ZIP code data from 1999 into a sqlite database # for use by the weather plugin, and anything else that wants it. # You should not need to run this, you should have received a USzip file # with simbot. # # USAGE: # This script needs the following databases to run: # COUNTRY FILENAME # URL # United States zipnov99.DBF # http://www.census.gov/geo/www/tiger/zip1999.html # United Kingdom jibble-postcodes.csv # http://www.jibble.org/ukpostcodes/ # # Download these files into the simbot/tools directory. # Then, run perl create_postalcode_db.pl. When the script completes, you # should have a postalcodes file in your data directory. # # COPYRIGHT: # Copyright (C) 2005, Pete Pearson # # This program is free software; you can redistribute and/or modify it # under the terms of version 2 of the GNU General Public License as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA use warnings; use strict; use CAM::DBF; use DBI; $| = 1; my %states = qw( 01 AL 02 AK 04 AZ 05 AR 06 CA 08 CO 09 CT 10 DE 11 DC 12 FL 13 GA 15 HI 16 ID 17 IL 18 IN 19 IA 20 KS 21 KY 22 LA 23 ME 24 MD 25 MA 26 MI 27 MN 28 MS 29 MO 30 MT 31 NE 32 NV 33 NH 34 NJ 35 NM 36 NY 37 NC 38 ND 39 OH 40 OK 41 OR 42 PA 44 RI 45 SC 46 SC 47 TN 48 TX 49 UT 50 VT 51 VA 53 WA 54 WV 55 WI 56 WY 60 AS 64 FM 66 GU 68 MH 69 MP 70 PW 72 PR 74 UM 78 VI ); # set up the sqlite database our $sqlite_dbh = DBI->connect('dbi:SQLite:dbname=../data/postalcodes','','', { RaiseError => 1, AutoCommit => 0 }) or die 'Could not set up SQLite DB!'; $sqlite_dbh->do(<<EOT); CREATE TABLE postalcodes ( code STRING UNIQUE, latitude REAL, longitude REAL, poname STRING, state STRING, country INTEGER, geocode INTEGER ); EOT $sqlite_dbh->do(<<EOT); CREATE TABLE countries ( id INTEGER PRIMARY KEY, name STRING UNIQUE, code STRING UNIQUE ); EOT # we'll create the index when we are done, supposedly it's faster # that way my $insert_row_query=$sqlite_dbh->prepare( 'INSERT OR REPLACE INTO postalcodes' . ' (code, latitude, longitude, poname, state, country, geocode)' . ' VALUES (?, ?, ?, ?, ?, ?, ?)' ); # ok, that's done, now open the dbase III database if( my $dbase_dbf = new CAM::DBF('zipnov99.DBF')) { my $country_id = &get_country_id('United States', 'us'); my $last_row = $dbase_dbf->nrecords() - 1; print 'Reading US db. ' . $dbase_dbf->nrecords() . " rows to read\n"; for my $row (0 .. $last_row) { if($row % 2500 == 0) { print " row $row, " . int (($row/$last_row)*100) . "%\n"; } my $cur_row = $dbase_dbf->fetchrow_hashref($row); my $lat = $cur_row->{'LATITUDE'}; my $long = $cur_row->{'LONGITUDE'}; my $state = $cur_row->{'STATE'}; my $geocode = $state . sprintf('%03d', $cur_row->{'COUNTY'}); if($states{$state}) { $state = $states{$state}; } $lat =~ s/^\s*//; $long =~ s/^\s*//; if($lat == 24.859832 && $long == -168.021815) { # Bogus lat/long for many zips in Hawai'i # unless there's a post office on the ocean floor. if($cur_row->{'PONAME'} eq 'HONOLULU') { $lat = 21.307039; $long = -157.858343; } else { undef $lat; undef $long; } } { no warnings qw( uninitialized ); $insert_row_query->execute($cur_row->{'ZIP_CODE'}, $lat, $long, $cur_row->{'PONAME'}, $state, $country_id, $geocode); } } print "Done!\n"; } if(open(IN, 'jibble-postcodes.csv')) { my $country_id = &get_country_id('United Kingdom', 'uk'); <IN>; my $line_count = 0; print "Reading UK db"; while(<IN>) { my($postcode, undef, undef, $latitude, $longitude) = split(/,/); ($longitude) = $longitude =~ m/(-?[\d.]+)/; if(++$line_count % 300 == 0) { print '.'; } no warnings qw( uninitialized ); $insert_row_query->execute($postcode, $latitude, $longitude, undef, undef, $country_id, undef); } print " Done! Read $line_count lines\n"; } print "Creating indices..."; $sqlite_dbh->do(<<EOT); CREATE UNIQUE INDEX postalcodescode ON postalcodes (code); CREATE INDEX postalcodesstate ON postalcodes (state, country); EOT print " Done!\nCommitting..."; $sqlite_dbh->commit; print " Done!\n"; sub get_country_id { my ($name, $code) = @_; my $id; my $query = $sqlite_dbh->prepare_cached( 'SELECT id FROM countries' . ' WHERE lower(name) = lower(?)' . ' LIMIT 1' ); $query->execute($name) or die; if(($id) = $query->fetchrow_array()) { # The nickname is known. $query->finish; } else { # The nickname isn't known. We might need to add it. $query->finish; $query = $sqlite_dbh->prepare_cached('INSERT INTO countries (name, code) VALUES (?, ?)'); $query->execute($name, $code); $id = $sqlite_dbh->last_insert_id(undef,undef,'names',undef); $query->finish; } return $id; } --- create_zip_db.pl DELETED --- |