summaryrefslogtreecommitdiffstats
path: root/lib/Crawl/Bot.pm
blob: 47738fbc6a5c28ca5a4f8f8adf8f5f2743ba7544 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package Crawl::Bot;
use Moose;
use MooseX::NonMoose;
extends 'Bot::BasicBot';

use File::Path;

has [qw(username name)] => (
    # don't need (or want) accessors, just want to initialize the hash slot
    # for B::BB to use
    is      => 'bare',
    isa     => 'Str',
    default => sub { shift->nick },
);

has data_dir => (
    is      => 'ro',
    isa     => 'Str',
    lazy    => 1,
    default => 'dat',
);

has update_time => (
    is      => 'ro',
    isa     => 'Int',
    default => 300,
);

has mantis => (
    is      => 'ro',
    isa     => 'Crawl::Bot::Mantis',
    lazy    => 1,
    default => sub {
        my $self = shift;
        require Crawl::Bot::Mantis;
        Crawl::Bot::Mantis->new(bot => $self);
    },
);

has wiki => (
    is      => 'ro',
    isa     => 'Crawl::Bot::Wiki',
    lazy    => 1,
    default => sub {
        my $self = shift;
        require Crawl::Bot::Wiki;
        Crawl::Bot::Wiki->new(bot => $self);
    },
);

sub BUILD {
    my $self = shift;
    File::Path::mkpath($self->data_dir);
    $self->mantis;
    $self->wiki;
}

before say => sub {
    my $self = shift;
    my %params = @_;
    warn "sending '$params{body}' to $params{channel}";
};

sub tick {
    my $self = shift;
    $self->mantis->tick;
    $self->wiki->tick;
    return $self->update_time;
}

1;