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