-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
101 additions
and
66 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package xmpbot::Plugin; | ||
use Moose::Role; | ||
requires 'msg_cb'; | ||
use Carp; | ||
|
||
has 'command' => ( | ||
is => 'rw', | ||
isa => 'Str', | ||
predicate => 'has_command', | ||
); | ||
|
||
has 'description' => ( | ||
is => 'rw', | ||
isa => 'Str', | ||
predicate => 'has_description', | ||
); | ||
|
||
has 'help' => ( | ||
is => 'rw', | ||
isa => 'Str', | ||
predicate => 'has_help', | ||
); | ||
|
||
after 'BUILD' => sub { | ||
my $self = shift; | ||
croak "Command not specified!" unless $self->has_command; | ||
carp "Warning: description not set" unless $self->has_description; | ||
carp "Warning: help message not set" unless $self->has_help; | ||
}; | ||
|
||
1; |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package xmpbot::Plugin::Echo; | ||
use Moose; | ||
with 'xmpbot::Plugin'; | ||
|
||
sub BUILD { | ||
my $self = shift; | ||
$self->command('echo'); | ||
$self->description('echoes what was said'); | ||
$self->help('This plugin simply retypes what the user said'); | ||
} | ||
|
||
sub msg_cb { | ||
my ($self, $msg) = @_; | ||
return $msg; | ||
} | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package xmpbot::Plugin::Help; | ||
use Moose; | ||
with 'xmpbot::Plugin'; | ||
|
||
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'); | ||
} | ||
|
||
sub msg_cb { | ||
my (undef, $args, $bot) = @_; | ||
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 { | ||
$resp = "No help available for '$args'"; | ||
} | ||
} | ||
return $resp; | ||
} | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package xmpbot::Plugin::Ping; | ||
use Moose; | ||
with 'xmpbot::Plugin'; | ||
|
||
sub BUILD { | ||
my $self = shift; | ||
$self->command('ping'); | ||
$self->description('respond to "ping"'); | ||
$self->help('This plugin responds to "ping" with "pong". Yep, that\'s it'); | ||
} | ||
|
||
sub msg_cb { | ||
return "pong"; | ||
} | ||
|
||
1; |
File renamed without changes.
File renamed without changes.