line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Hubot::Scripts::tell; |
2
|
|
|
|
|
|
|
$Hubot::Scripts::tell::VERSION = '0.1.10'; |
3
|
1
|
|
|
1
|
|
972
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
23
|
|
5
|
1
|
|
|
1
|
|
219
|
use DateTime; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub load { |
8
|
|
|
|
|
|
|
my ( $class, $robot ) = @_; |
9
|
|
|
|
|
|
|
$robot->respond( |
10
|
|
|
|
|
|
|
qr/(tell (\w+) (?:.+))$/i, |
11
|
|
|
|
|
|
|
sub { |
12
|
|
|
|
|
|
|
my $msg = shift; |
13
|
|
|
|
|
|
|
my $sender = $msg->message->user->{name}; |
14
|
|
|
|
|
|
|
my ( $post, $recipient ) = ( $msg->match->[0], $msg->match->[1] ); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# XXX: hey, There should be generalized nick matchers, supplied from each adapters. |
17
|
|
|
|
|
|
|
# $robot->exist($room, $nick) |
18
|
|
|
|
|
|
|
if ( my ($user) = $robot->userForName($recipient) |
19
|
|
|
|
|
|
|
and $msg->exist($recipient) ) |
20
|
|
|
|
|
|
|
{ |
21
|
|
|
|
|
|
|
$msg->reply("<$recipient> $post"); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
else { |
24
|
|
|
|
|
|
|
# XXX: hey, There is no time provided from adapters for messages. |
25
|
|
|
|
|
|
|
my $dt = DateTime->now( time_zone => 'Asia/Seoul' ); |
26
|
|
|
|
|
|
|
$robot->brain->{data}{tell}{$recipient}{ +time } |
27
|
|
|
|
|
|
|
= [$sender, $recipient, $post, $dt->ymd . " " . $dt->hms]; |
28
|
|
|
|
|
|
|
$msg->reply( |
29
|
|
|
|
|
|
|
"OK, I'll pass that on when $recipient is around."); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
$robot->enter( |
34
|
|
|
|
|
|
|
sub { |
35
|
|
|
|
|
|
|
my $msg = shift; |
36
|
|
|
|
|
|
|
my $user = $msg->message->user->{name}; |
37
|
|
|
|
|
|
|
for my $recipient ( keys %{ $robot->brain->{data}{tell} } ) { |
38
|
|
|
|
|
|
|
if ( $user =~ /^$recipient$/i ) { |
39
|
|
|
|
|
|
|
for my $post ( |
40
|
|
|
|
|
|
|
values %{ $robot->brain->{data}{tell}{$recipient} } ) |
41
|
|
|
|
|
|
|
{ |
42
|
|
|
|
|
|
|
$msg->send( |
43
|
|
|
|
|
|
|
"$user: $post->[3]: <$post->[0]> $post->[2]"); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
delete $robot->brain->{data}{tell}{$recipient}; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
last; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 NAME |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Hubot::Scripts::tell |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 VERSION |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
version 0.1.10 |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 SYNOPSIS |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
hubot tell - pass on when is around. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 AUTHOR |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Hojung Youn |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |