Hubot/Response.pm

filter: Statementstmt 57.1% 16 / 28 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 40.0% 4 / 10 Podpod 0.0% 0 / 8 totaltotal 43.4% 20 / 46 CC 1 SCAR 4.7
CC
1
Cov
57%
whisper
2.0
topic
2.0
reply
2.0
CRAP 1.6
« Hubot/Scripts/help.pm ↑ Summary Hubot/User.pm »
1 package Hubot::Response;
2 6 $Hubot::Response::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 has 'robot' => ( is => 'ro', isa => 'Hubot::Robot', );
7  
8 6 has 'message' => ( is => 'rw', isa => 'Hubot::Message', );
9  
10 6 has 'match' => ( is => 'rw', isa => 'ArrayRef' );
11  
12 18 ▶sub send {
Subroutine send: called CC=1 SCAR=0.0
Pod undocumented
13 18 my ( $self, @strings ) = @_;
14 18 $self->robot->adapter->send( $self->message->user, @strings );
15 }
16  
17 0 ▶sub whisper {
Subroutine whisper: not called CC=1 SCAR=6.9
Pod undocumented
18 0 my ( $self, $to, @strings ) = @_;
19 0 $self->robot->adapter->whisper( $self->message->user, $to, @strings );
20 }
21  
22 0 ▶sub topic {
Subroutine topic: not called CC=1 SCAR=6.9
Pod undocumented
23 0 my ( $self, @strings ) = @_;
24 0 $self->robot->adapter->topic( $self->message->user, @strings );
25 }
26  
27 0 ▶sub reply {
Subroutine reply: not called CC=1 SCAR=6.9
Pod undocumented
28 0 my ( $self, @strings ) = @_;
29 0 $self->robot->adapter->reply( $self->message->user, @strings );
30 }
31  
32 0 ▶sub random {
Subroutine random: not called CC=1 SCAR=6.9
Pod undocumented
33 0 my ( $self, @items ) = @_;
34 0 return $items[rand( scalar(@items) )];
35 }
36  
37 0 ▶sub finish {
Subroutine finish: not called CC=1 SCAR=6.9
Pod undocumented
38 0 my $self = shift;
39 0 $self->message->finish();
40 }
41  
42 4 ▶sub http {
Subroutine http: called CC=1 SCAR=0.0
Pod undocumented
43 4 my ( $self, $url ) = @_;
44 4 return $self->robot->http($url);
45 }
46  
47 0 ▶sub exist {
Subroutine exist: not called CC=1 SCAR=6.9
Pod undocumented
48 0 my ( $self, $nick ) = @_;
49 0 $self->robot->adapter->exist( $self->message->user, $nick );
50 }
51  
52 6 __PACKAGE__->meta->make_immutable;
53  
54 6 1;
55  
56 =pod
57  
58 =encoding utf-8
59  
60 =head1 NAME
61  
62 Hubot::Response
63  
64 =head1 VERSION
65  
66 version 0.2.8
67  
68 =head1 SYNOPSIS
69  
70 ## generally Hubot::Response used to Hubot::Script::* callback.
71 ## assume this is a callback subroutine.
72 $robot->hear(
73 qr/echo (.+)/i,
74 sub {
75 my $res = shift;
76 $res->reply($res->match->[0]); # aanoaa> echo 123
77 # hubot> aanoaa: 123
78 }
79 );
80  
81 =head1 DESCRIPTION
82  
83 Interface between C<Hubot::Script::*> callback and C<Hubot::Adapter::*>
84  
85 =head1 AUTHOR
86  
87 Hyungsuk Hong <hshong@perl.kr>
88  
89 =head1 COPYRIGHT AND LICENSE
90  
91 This software is copyright (c) 2012 by Hyungsuk Hong.
92  
93 This is free software; you can redistribute it and/or modify it under
94 the same terms as the Perl 5 programming language system itself.
95  
96 =cut
« Hubot/Scripts/help.pm ↑ Summary Hubot/User.pm »