line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Hubot::Response; |
2
|
|
|
|
|
|
|
$Hubot::Response::VERSION = '0.2.7'; |
3
|
1
|
|
|
1
|
|
2008
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
use namespace::autoclean; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
has 'robot' => ( is => 'ro', isa => 'Hubot::Robot', ); |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
has 'message' => ( is => 'rw', isa => 'Hubot::Message', ); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has 'match' => ( is => 'rw', isa => 'ArrayRef' ); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub send { |
13
|
|
|
|
|
|
|
my ( $self, @strings ) = @_; |
14
|
|
|
|
|
|
|
$self->robot->adapter->send( $self->message->user, @strings ); |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub whisper { |
18
|
|
|
|
|
|
|
my ( $self, $to, @strings ) = @_; |
19
|
|
|
|
|
|
|
$self->robot->adapter->whisper( $self->message->user, $to, @strings ); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub topic { |
23
|
|
|
|
|
|
|
my ( $self, @strings ) = @_; |
24
|
|
|
|
|
|
|
$self->robot->adapter->topic( $self->message->user, @strings ); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub reply { |
28
|
|
|
|
|
|
|
my ( $self, @strings ) = @_; |
29
|
|
|
|
|
|
|
$self->robot->adapter->reply( $self->message->user, @strings ); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub random { |
33
|
|
|
|
|
|
|
my ( $self, @items ) = @_; |
34
|
|
|
|
|
|
|
return $items[rand( scalar(@items) )]; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub finish { |
38
|
|
|
|
|
|
|
my $self = shift; |
39
|
|
|
|
|
|
|
$self->message->finish(); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub http { |
43
|
|
|
|
|
|
|
my ( $self, $url ) = @_; |
44
|
|
|
|
|
|
|
return $self->robot->http($url); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub exist { |
48
|
|
|
|
|
|
|
my ( $self, $nick ) = @_; |
49
|
|
|
|
|
|
|
$self->robot->adapter->exist( $self->message->user, $nick ); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
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.7 |
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 |