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