| 1 | package Hubot::Listener; | ||||||||||
| 2 | 6 | $Hubot::Listener::VERSION = '0.2.8'; | |||||||||
| 3 | 6 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 6 | ▶ | use namespace::autoclean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 6 | ▶ | use Hubot::Response; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 6 | has 'robot' => ( is => 'ro', isa => 'Hubot::Robot', ); | |||||||||
| 9 | 6 | has 'matcher' => ( | |||||||||
| 10 | traits => ['Code'], | ||||||||||
| 11 | is => 'rw', | ||||||||||
| 12 | isa => 'CodeRef', | ||||||||||
| 13 | handles => { matching => 'execute', }, | ||||||||||
| 14 | ); | ||||||||||
| 15 | 6 | has 'callback' => ( | |||||||||
| 16 | traits => ['Code'], | ||||||||||
| 17 | is => 'rw', | ||||||||||
| 18 | isa => 'CodeRef', | ||||||||||
| 19 | handles => { cb => 'execute', }, | ||||||||||
| 20 | ); | ||||||||||
| 21 | |||||||||||
| 22 | 168 | ▶ | sub call { | ||||||||
|
Subroutine
call: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 23 | 168 | my ( $self, $message ) = @_; | |||||||||
| 24 | 168 | ▶ | if ( my @match = $self->matching($message) ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 25 | 26 | $self->cb( | |||||||||
| 26 | new Hubot::Response( | ||||||||||
| 27 | robot => $self->robot, | ||||||||||
| 28 | message => $message, | ||||||||||
| 29 | match => \@match, | ||||||||||
| 30 | ) | ||||||||||
| 31 | ); | ||||||||||
| 32 | |||||||||||
| 33 | 26 | return 1; | |||||||||
| 34 | } | ||||||||||
| 35 | else { | ||||||||||
| 36 | 142 | return 0; | |||||||||
| 37 | } | ||||||||||
| 38 | } | ||||||||||
| 39 | |||||||||||
| 40 | 6 | __PACKAGE__->meta->make_immutable; | |||||||||
| 41 | |||||||||||
| 42 | 6 | 1; | |||||||||
| 43 | |||||||||||
| 44 | =pod | ||||||||||
| 45 | |||||||||||
| 46 | =encoding utf-8 | ||||||||||
| 47 | |||||||||||
| 48 | =head1 NAME | ||||||||||
| 49 | |||||||||||
| 50 | Hubot::Listener | ||||||||||
| 51 | |||||||||||
| 52 | =head1 VERSION | ||||||||||
| 53 | |||||||||||
| 54 | version 0.2.8 | ||||||||||
| 55 | |||||||||||
| 56 | =head1 SYNOPSIS | ||||||||||
| 57 | |||||||||||
| 58 | Nope. | ||||||||||
| 59 | |||||||||||
| 60 | =head1 DESCRIPTION | ||||||||||
| 61 | |||||||||||
| 62 | base class of L<Hubot::TextListener> | ||||||||||
| 63 | |||||||||||
| 64 | try to match all registered regex then execute callback with matching result and input messages. | ||||||||||
| 65 | |||||||||||
| 66 | =head1 SEE ALSO | ||||||||||
| 67 | |||||||||||
| 68 | L<Hubot::TextListener> | ||||||||||
| 69 | |||||||||||
| 70 | =head1 AUTHOR | ||||||||||
| 71 | |||||||||||
| 72 | Hyungsuk Hong <hshong@perl.kr> | ||||||||||
| 73 | |||||||||||
| 74 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 75 | |||||||||||
| 76 | This software is copyright (c) 2012 by Hyungsuk Hong. | ||||||||||
| 77 | |||||||||||
| 78 | This is free software; you can redistribute it and/or modify it under | ||||||||||
| 79 | the same terms as the Perl 5 programming language system itself. | ||||||||||
| 80 | |||||||||||
| 81 | =cut | ||||||||||