line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::TeleGramma::PluginManager; |
2
|
|
|
|
|
|
|
$App::TeleGramma::PluginManager::VERSION = '0.12'; |
3
|
|
|
|
|
|
|
# ABSTRACT: Plugin manager for the TeleGramma bot |
4
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
71180
|
use Mojo::Base -base; |
|
3
|
|
|
|
|
1860
|
|
|
3
|
|
|
|
|
21
|
|
6
|
3
|
|
|
3
|
|
479
|
use File::Spec::Functions qw/catdir/; |
|
3
|
|
|
|
|
19
|
|
|
3
|
|
|
|
|
924
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
require Module::Pluggable; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has 'config'; |
11
|
|
|
|
|
|
|
has 'search_dirs' => sub { [catdir($ENV{HOME}, '.telegramma', 'plugins')] }; |
12
|
|
|
|
|
|
|
has 'list' => sub { [] }; |
13
|
|
|
|
|
|
|
has 'listeners' => sub { [] }; |
14
|
|
|
|
|
|
|
has 'app'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub load_plugins { |
17
|
2
|
|
|
2
|
0
|
1029
|
my $self = shift; |
18
|
2
|
|
|
|
|
12
|
$self->list([]); |
19
|
|
|
|
|
|
|
|
20
|
2
|
|
|
|
|
25
|
Module::Pluggable->import( |
21
|
|
|
|
|
|
|
search_path => ['App::TeleGramma::Plugin'], |
22
|
|
|
|
|
|
|
search_dirs => $self->search_dirs, |
23
|
|
|
|
|
|
|
require => 1, |
24
|
|
|
|
|
|
|
except => [qw/App::TeleGramma::Plugin::Base/] |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
2
|
|
|
|
|
221
|
foreach my $p ($self->plugins) { |
28
|
12
|
50
|
|
|
|
11313
|
if (! $p->check_prereqs()) { |
29
|
0
|
|
|
|
|
0
|
warn "$p - failed prereq check\n"; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# instantiate it |
33
|
12
|
|
|
|
|
41
|
my $o = $p->new(app_config => $self->config, app => $self->app); |
34
|
12
|
|
|
|
|
221
|
$o->create_default_config_if_necessary; |
35
|
|
|
|
|
|
|
|
36
|
12
|
100
|
|
|
|
4940
|
if ($o->read_config->{enable} =~ /yes/i) { |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# register it |
39
|
1
|
|
|
|
|
20
|
my @botactions = $o->register; |
40
|
1
|
|
|
|
|
5
|
foreach my $ba (@botactions) { |
41
|
0
|
0
|
|
|
|
0
|
if ($ba->can_listen) { |
42
|
0
|
|
|
|
|
0
|
push @{ $self->listeners }, $ba; |
|
0
|
|
|
|
|
0
|
|
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# add it to our list of plugins |
47
|
1
|
|
|
|
|
2
|
push @{ $self->list }, $o; |
|
1
|
|
|
|
|
6
|
|
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
__END__ |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=pod |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=encoding UTF-8 |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 NAME |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
App::TeleGramma::PluginManager - Plugin manager for the TeleGramma bot |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 VERSION |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
version 0.12 |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 AUTHOR |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Justin Hawkins <justin@eatmorecode.com> |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Justin Hawkins <justin@eatmorecode.com>. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
77
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=cut |