use strict;
require 'plugins/infobot/exchange.pl';
sub getparam {};
&RegisterFlag("currency");
&RegisterCommand(command => "!convert",
handler => \&plugin_currency_convert,
desc => "Converts from one currency to another",
usage => "<amount> <from-curr> to <to-curr>");
sub plugin_currency_convert {
my $message = shift;
my $conversion = shift;
my $fromJID = $message->GetFrom("jid");
return unless &CheckFlag($fromJID->GetJID(),"currency");
my ($amount, $from, undef, $to) =
$conversion =~ m|^([\d\.]+)\s+(\w+)\s+(to\s+)?(\w+)|;
unless (defined($amount) and defined($from) and defined($to)) {
return ($message->GetType(),
$fromJID->GetResource().": sorry, I don't understand");
}
return ($message->GetType(),"[convert]:". exchange($from, $to, $amount));
}
1;