line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: Bot::IRC plugin for leaving messages for nicks |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
use 5.014; |
4
|
1
|
|
|
1
|
|
353730
|
use exact; |
|
1
|
|
|
|
|
10
|
|
5
|
1
|
|
|
1
|
|
6
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
6
|
|
|
|
|
|
|
use DateTime; |
7
|
1
|
|
|
1
|
|
1274
|
use DateTime::Format::Human::Duration; |
|
1
|
|
|
|
|
358779
|
|
|
1
|
|
|
|
|
38
|
|
8
|
1
|
|
|
1
|
|
454
|
|
|
1
|
|
|
|
|
1509
|
|
|
1
|
|
|
|
|
443
|
|
9
|
|
|
|
|
|
|
our $VERSION = '1.06'; # VERSION |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my ($bot) = @_; |
12
|
|
|
|
|
|
|
$bot->load('Store'); |
13
|
1
|
|
|
1
|
0
|
6762
|
|
14
|
1
|
|
|
|
|
5
|
$bot->hook( |
15
|
|
|
|
|
|
|
{ |
16
|
|
|
|
|
|
|
to_me => 1, |
17
|
|
|
|
|
|
|
text => qr/^(?:message|tell|ask)\s+(?<nick>\S+)\s+(?<msg>.+)\s*/, |
18
|
|
|
|
|
|
|
}, |
19
|
|
|
|
|
|
|
sub { |
20
|
|
|
|
|
|
|
my ( $bot, $in, $m ) = @_; |
21
|
|
|
|
|
|
|
|
22
|
0
|
|
|
0
|
|
0
|
my $nick = lc( $m->{nick} ); |
23
|
|
|
|
|
|
|
my @msgs = @{ $bot->store->get($nick) || [] }; |
24
|
0
|
|
|
|
|
0
|
|
25
|
0
|
0
|
|
|
|
0
|
push( @msgs, { |
|
0
|
|
|
|
|
0
|
|
26
|
|
|
|
|
|
|
in => $in, |
27
|
|
|
|
|
|
|
time => time, |
28
|
|
|
|
|
|
|
msg => $m->{msg}, |
29
|
|
|
|
|
|
|
} ); |
30
|
|
|
|
|
|
|
$bot->store->set( $nick => \@msgs ); |
31
|
0
|
|
|
|
|
0
|
|
32
|
0
|
|
|
|
|
0
|
$bot->reply_to('OK.'); |
33
|
|
|
|
|
|
|
}, |
34
|
0
|
|
|
|
|
0
|
); |
35
|
|
|
|
|
|
|
|
36
|
1
|
|
|
|
|
1023
|
my $duration = DateTime::Format::Human::Duration->new; |
37
|
|
|
|
|
|
|
$bot->hook( |
38
|
1
|
|
|
|
|
13
|
{ |
39
|
|
|
|
|
|
|
command => 'JOIN', |
40
|
|
|
|
|
|
|
}, |
41
|
|
|
|
|
|
|
sub { |
42
|
|
|
|
|
|
|
my ( $bot, $in ) = @_; |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
0
|
|
0
|
my $nick = lc( $in->{nick} ); |
45
|
|
|
|
|
|
|
my @msgs = @{ $bot->store->get($nick) || [] }; |
46
|
0
|
|
|
|
|
0
|
|
47
|
0
|
0
|
|
|
|
0
|
$bot->store->set( $nick => [] ); |
|
0
|
|
|
|
|
0
|
|
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
0
|
for ( my $i = 0; $i < @msgs; $i++ ) { |
50
|
|
|
|
|
|
|
$bot->reply_to( |
51
|
0
|
|
|
|
|
0
|
"$msgs[$i]->{in}{nick} left a message for you " . |
52
|
|
|
|
|
|
|
$duration->format_duration_between( |
53
|
|
|
|
|
|
|
map { DateTime->from_epoch( epoch => $_ ) } $msgs[$i]->{time}, time |
54
|
|
|
|
|
|
|
) . |
55
|
0
|
|
|
|
|
0
|
" ago. \"$msgs[$i]->{msg}\"" |
56
|
0
|
|
|
|
|
0
|
); |
57
|
|
|
|
|
|
|
sleep 1 if ( $i + 1 < @msgs ); |
58
|
|
|
|
|
|
|
} |
59
|
0
|
0
|
|
|
|
0
|
|
60
|
|
|
|
|
|
|
return; |
61
|
|
|
|
|
|
|
}, |
62
|
0
|
|
|
|
|
0
|
); |
63
|
|
|
|
|
|
|
|
64
|
1
|
|
|
|
|
10
|
$bot->helps( message => 'Leave a message for a nick. Usage: <bot nick> message <target nick> <message>'); |
65
|
|
|
|
|
|
|
} |
66
|
1
|
|
|
|
|
10
|
|
67
|
|
|
|
|
|
|
1; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=pod |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=encoding UTF-8 |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 NAME |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Bot::IRC::X::Message - Bot::IRC plugin for leaving messages for nicks |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 VERSION |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
version 1.06 |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=for markdown [![test](https://github.com/gryphonshafer/Bot-IRC-X-Message/workflows/test/badge.svg)](https://github.com/gryphonshafer/Bot-IRC-X-Message/actions?query=workflow%3Atest) |
83
|
|
|
|
|
|
|
[![codecov](https://codecov.io/gh/gryphonshafer/Bot-IRC-X-Message/graph/badge.svg)](https://codecov.io/gh/gryphonshafer/Bot-IRC-X-Message) |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 SYNOPSIS |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
use Bot::IRC; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Bot::IRC->new( |
90
|
|
|
|
|
|
|
connect => { server => 'irc.perl.org' }, |
91
|
|
|
|
|
|
|
plugins => ['Message'], |
92
|
|
|
|
|
|
|
)->run; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 DESCRIPTION |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
This L<Bot::IRC> plugin provides the means for the bot to keep messages for |
97
|
|
|
|
|
|
|
nicks. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
<user1> bot message user2 This is a message for you. |
100
|
|
|
|
|
|
|
<bot> user1: OK. |
101
|
|
|
|
|
|
|
*** user2 has joined #this_channel |
102
|
|
|
|
|
|
|
<bot> user2: user1 left a message for you. "This is a message for you." |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 SEE ALSO |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
You can look for additional information at: |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=over 4 |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=item * |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
L<Bot::IRC> |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=item * |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
L<GitHub|https://github.com/gryphonshafer/Bot-IRC-X-Message> |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=item * |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
L<MetaCPAN|https://metacpan.org/pod/Bot::IRC::X::Message> |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=item * |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
L<GitHub Actions|https://github.com/gryphonshafer/Bot-IRC-X-Message/actions> |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=item * |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
L<Codecov|https://codecov.io/gh/gryphonshafer/Bot-IRC-X-Message> |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=item * |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
L<CPANTS|http://cpants.cpanauthors.org/dist/Bot-IRC-X-Message> |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=item * |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
L<CPAN Testers|http://www.cpantesters.org/distro/T/Bot-IRC-X-Message.html> |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=back |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=for Pod::Coverage init |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head1 AUTHOR |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Gryphon Shafer <gryphon@cpan.org> |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
This software is Copyright (c) 2016-2050 by Gryphon Shafer. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
This is free software, licensed under: |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=cut |