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