Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Plugins ported to i18ncommands

  • Loading branch information...
commit b05762beab583272161fe8519c4a87d798274667 1 parent 95c05b1
@dotevo dotevo authored
View
20 xmpbot/Plugin/Aspell.pm
@@ -4,16 +4,27 @@ no utf8;
use Encode;
use Moose;
with 'xmpbot::Plugin';
+with 'xmpbot::Translations';
sub BUILD {
my $self = shift;
- $self->command('aspell');
- $self->description('validation words');
- $self->help('example: aspell en who');
+ $self->register_command('aspell');
+ $self->name("aspell");
}
-sub msg_cb {
+sub getDescription{
+ my($self) = @_;
+ return $self->loc->localize('validation word');
+}
+
+sub getHelp{
+ my($self) = @_;
+ return $self->loc->localize('example: aspell en who');
+}
+
+
+sub aspell{
my ($self, $msg) = @_;
my ($lang,$word) = split(/ /, $msg);
print "Aspell.pm:".$lang."-".$word."\n";
@@ -46,4 +57,5 @@ sub msg_cb {
}
}
+
1;
View
20 xmpbot/Plugin/Cloudmade.pm
@@ -3,16 +3,27 @@ use Geo::Cloudmade;
use utf8;
use Moose;
with 'xmpbot::Plugin';
+with 'xmpbot::Translations';
sub BUILD {
my $self = shift;
- $self->command('map');
- $self->description('routing and POIs');
- $self->help("examples:\n map ROUTE:Rynek,Wrocław&Damrota,Wrocław \n map POI:restaurant:Rynek,Wrocław");
+ $self->register_command('map');
+ $self->name("cloudmade");
}
-sub msg_cb {
+sub getDescription{
+ my($self) = @_;
+ return $self->loc->localize('routing and POIs');
+}
+
+sub getHelp{
+ my($self) = @_;
+ return $self->loc->localize('examples:\n map ROUTE:Rynek,Wrocław&Damrota,Wrocław \n map POI:restaurant:Rynek,Wrocław');
+}
+
+
+sub map{
my ($self, $msg) = @_;
my ($parametr,$values) = split(/:/, $msg,2);
#Api key
@@ -95,6 +106,7 @@ sub msg_cb {
}
}
+
1;
View
22 xmpbot/Plugin/Echo.pm
@@ -1,16 +1,28 @@
package xmpbot::Plugin::Echo;
use Moose;
with 'xmpbot::Plugin';
+with 'xmpbot::Translations';
sub BUILD {
my $self = shift;
- $self->command('echo');
- $self->description('echoes what was said');
- $self->help('This plugin simply retypes what the user said');
+ $self->register_command('echo');
+ $self->name("echo");
}
-sub msg_cb {
- my ($self, $msg) = @_;
+
+sub getDescription{
+ my($self) = @_;
+ return $self->loc->localize('echoes what was said');
+}
+
+sub getHelp{
+ my($self) = @_;
+ return $self->loc->localize('This plugin simply retypes what the user said');
+}
+
+
+sub echo{
+ my($self, $msg) = @_;
return $msg;
}
View
23 xmpbot/Plugin/Get.pm
@@ -1,22 +1,31 @@
package xmpbot::Plugin::Get;
use Moose;
with 'xmpbot::Plugin';
+with 'xmpbot::Translations';
sub BUILD {
my $self = shift;
- $self->command('get');
- $self->description('get option');
- $self->help('example: get lang');
+ $self->register_command('get');
+ $self->name("get");
}
-#TODO: global franek@jabber.org
-# local franek@jabber.org/work
+sub getDescription{
+ my($self) = @_;
+ return $self->loc->localize('get option');
+}
+
+sub getHelp{
+ my($self) = @_;
+ return $self->loc->localize('example: get lang');
+}
-sub msg_cb {
+
+sub get{
my($self, $msg,$bot,$a) = @_;
my @user=split(/\//, $a->from);
- return $bot->db->getOption($user[0],$msg);
+ return $bot->db->getOption($user[0],$msg);
}
+
1;
View
37 xmpbot/Plugin/Help.pm
@@ -1,32 +1,39 @@
package xmpbot::Plugin::Help;
+use Data::Dumper;
use Moose;
with 'xmpbot::Plugin';
+with 'xmpbot::Translations';
sub BUILD {
my $self = shift;
- $self->command('help');
- $self->description('list all available commands');
- $self->help('This plugin shows a list of available commands with short descriptions, or a longer help for a specified command');
+ $self->register_command('help');
+ $self->name("help");
}
-sub msg_cb {
+
+sub getDescription{
+ my($self) = @_;
+ return $self->loc->localize('This plugin shows a list of available commands with short descriptions, or a longer help for a specified command');
+}
+
+sub getHelp{
+ my($self) = @_;
+ return $self->loc->localize('show this message');
+}
+
+
+sub help{
my ($self, $args, $bot) = @_;
+ #get language without db? TODO
my $resp;
if (not defined $args) {
- for my $pair ($bot->plugins_pairs) {
- $resp .= "$pair->[0]\t".$pair->[1]->description."\n";
- }
+
} else {
- my $comm = $bot->get_plugin($args);
- if ($comm) {
- $resp = $comm->help;
- } else {
- #TODO CHANGE this!
- $resp= $self->{loc}->localize('No help available for') ." ". $args;
-# $resp = "No help available for '%s'",$args;
- }
+ #TODO!
}
return $resp;
}
+
+
1;
View
25 xmpbot/Plugin/Translate.pm
@@ -1,27 +1,36 @@
package xmpbot::Plugin::Translate;
use Lingua::Translate;
-
no utf8;
use Encode;
use Moose;
with 'xmpbot::Plugin';
+with 'xmpbot::Translations';
sub BUILD {
my $self = shift;
- $self->command('tr');
- $self->description('translate');
- $self->help('example: translate pl2en Co u Ciebie?');
+ $self->register_command('tr');
+ $self->name("translate");
+}
+
+
+sub getDescription{
+ my($self) = @_;
+ return $self->loc->localize('translate');
+}
+
+sub getHelp{
+ my($self) = @_;
+ return $self->loc->localize('example: translate pl2en Co u Ciebie?');
}
-sub msg_cb {
+
+
+sub tr{
#TODO: Another engines(get option from db)
#TODO: security-src,desc
my ($self, $msg) = @_;
my ($langs,$text) = split(/ /, $msg,2);
my ($src,$desc) = split(/2/, $langs);
-
Lingua::Translate::config(back_end => 'Google');
-
-
my $xl8r = Lingua::Translate->new(src => $src,
dest => $desc)
or return "Nie obsługiwane tłumaczenie $src -> $desc";
View
20 xmpbot/Plugin/Wikipedia.pm
@@ -3,17 +3,26 @@ use LWP::Simple;
use utf8;
use Moose;
with 'xmpbot::Plugin';
-
+with 'xmpbot::Translations';
sub BUILD {
my $self = shift;
- $self->command('wiki');
- $self->description('query wikipedia.org');
- $self->help('this plugin looks up desired article on wikipedia.org and prints it to the user');
+ $self->register_command('wiki');
+ $self->name("wikipedia");
+}
+
+sub getDescription{
+ my($self) = @_;
+ return $self->loc->localize('query wikipedia.org');
+}
+
+sub getHelp{
+ my($self) = @_;
+ return $self->loc->localize('This plugin looks up desired article on wikipedia.org and prints it to the user');
}
-sub msg_cb {
+sub wiki{
my ($self, $msg) = @_;
$msg=~ tr/ /_/; #changing white spaces
my ($wiki,$rozdzial) = split(/#/, $msg);
@@ -64,4 +73,5 @@ sub msg_cb {
return $ret;
}
+
1;
Please sign in to comment.
Something went wrong with that request. Please try again.