| 1 | package POE::Component::IRC::Plugin::WWW::OhNoRobotCom::Search; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 1 | our $VERSION = '0.002'; | |||||||||
| 7 | |||||||||||
| 8 | 1 | ▶ | use POE::Component::WWW::OhNoRobotCom::Search; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 1 | ▶ | use base 'POE::Component::IRC::Plugin::BasePoCoWrap'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | sub _make_default_args { | ||||||||||
| 12 | return ( | ||||||||||
| 13 | 0 | ▶ | response_event => 'irc_ohnorobot_results', | ||||||||
|
Subroutine
_make_default_args: not called CC=1 SCAR=6.9
| |||||||||||
| 14 | trigger => qr/^comics?\s+(?=\S+)/i, | ||||||||||
| 15 | obj_args => { }, | ||||||||||
| 16 | max_results => 3, | ||||||||||
| 17 | ); | ||||||||||
| 18 | } | ||||||||||
| 19 | |||||||||||
| 20 | sub _make_poco { | ||||||||||
| 21 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
_make_poco: not called CC=2 SCAR=17.9
| |||||||||||
| 22 | return POE::Component::WWW::OhNoRobotCom::Search->spawn( | ||||||||||
| 23 | 0 | ▶ | %{ $self->{obj_args} || {} } | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | ); | ||||||||||
| 25 | } | ||||||||||
| 26 | |||||||||||
| 27 | sub _make_response_message { | ||||||||||
| 28 | 0 | ▶ | my ( $self, $in_ref ) = @_; | ||||||||
|
Subroutine
_make_response_message: not called CC=2 SCAR=17.9
| |||||||||||
| 29 | my @out = exists $in_ref->{error} | ||||||||||
| 30 | ? $in_ref->{error} | ||||||||||
| 31 | 0 | ▶ | : sort keys %{ $in_ref->{results} }; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 32 | |||||||||||
| 33 | 0 | @out = splice @out, 0, $self->{max_results}; | |||||||||
| 34 | |||||||||||
| 35 | 0 | return [ join ' ', @out ]; | |||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | sub _make_response_event { | ||||||||||
| 39 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
_make_response_event: not called CC=2 SCAR=17.9
| |||||||||||
| 40 | 0 | my $in_ref = shift; | |||||||||
| 41 | |||||||||||
| 42 | return { | ||||||||||
| 43 | ( exists $in_ref->{error} | ||||||||||
| 44 | ? ( error => $in_ref->{error} ) | ||||||||||
| 45 | : ( results => $in_ref->{results} ) | ||||||||||
| 46 | ), | ||||||||||
| 47 | term => $in_ref->{term}, | ||||||||||
| 48 | 0 | ▶ | map { $_ => $in_ref->{"_$_"} } | ||||||||
|
Branch: 1 branch
| |||||||||||
| 49 | qw( who channel message type ), | ||||||||||
| 50 | } | ||||||||||
| 51 | } | ||||||||||
| 52 | |||||||||||
| 53 | sub _make_poco_call { | ||||||||||
| 54 | 0 | ▶ | my ( $self, $data_ref ) = @_; | ||||||||
|
Subroutine
_make_poco_call: not called CC=2 SCAR=17.9
| |||||||||||
| 55 | |||||||||||
| 56 | $self->{poco}->search({ | ||||||||||
| 57 | event => '_poco_done', | ||||||||||
| 58 | term => delete $data_ref->{what}, | ||||||||||
| 59 | map( +( exists $self->{$_} ? ( $_ => $self->{$_} ) : () ), | ||||||||||
| 60 | qw(max_results comic_id include lucky) | ||||||||||
| 61 | ), | ||||||||||
| 62 | 0 | ▶ | map +( "_$_" => $data_ref->{$_} ), | ||||||||
|
Branch: 1 branch
| |||||||||||
| 63 | keys %$data_ref, | ||||||||||
| 64 | } | ||||||||||
| 65 | ); | ||||||||||
| 66 | } | ||||||||||
| 67 | |||||||||||
| 68 | 1 | 1; | |||||||||
| 69 | __END__ | ||||||||||