[SimBot-commits] CVS: simbot/plugins currency.pl,1.11,1.12
Status: Abandoned
Brought to you by:
kstange
|
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, ); |