line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bot::IRC::X::Dice; |
2
|
|
|
|
|
|
|
# ABSTRACT: Bot::IRC plugin for dice rolling |
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
420759
|
use 5.014; |
|
1
|
|
|
|
|
12
|
|
5
|
1
|
|
|
1
|
|
6
|
use exact; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
1255
|
use Games::Dice 'roll'; |
|
1
|
|
|
|
|
1540
|
|
|
1
|
|
|
|
|
235
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '1.04'; # VERSION |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub init { |
12
|
1
|
|
|
1
|
0
|
7754
|
my ($bot) = @_; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
$bot->hook( |
15
|
|
|
|
|
|
|
{ |
16
|
|
|
|
|
|
|
command => 'PRIVMSG', |
17
|
|
|
|
|
|
|
text => qr/^roll\s+(?<expr>\d*d[\d%]+(?:[+\-*\/]\d+)?)/, |
18
|
|
|
|
|
|
|
}, |
19
|
|
|
|
|
|
|
sub { |
20
|
1
|
|
|
1
|
|
402
|
my ( $bot, $in, $m ) = @_; |
21
|
1
|
|
|
|
|
6
|
$bot->reply( roll( $m->{expr} ) ); |
22
|
|
|
|
|
|
|
}, |
23
|
1
|
|
|
|
|
15
|
); |
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
|
|
9
|
$bot->helps( dice => 'Simulated dice rolls. Usage: roll <dice expression like "2d6+2">.' ); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
1; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
__END__ |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=pod |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=encoding UTF-8 |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 NAME |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Bot::IRC::X::Dice - Bot::IRC plugin for dice rolling |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 VERSION |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
version 1.04 |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=for markdown [![test](https://github.com/gryphonshafer/Bot-IRC-X-Dice/workflows/test/badge.svg)](https://github.com/gryphonshafer/Bot-IRC-X-Dice/actions?query=workflow%3Atest) |
45
|
|
|
|
|
|
|
[![codecov](https://codecov.io/gh/gryphonshafer/Bot-IRC-X-Dice/graph/badge.svg)](https://codecov.io/gh/gryphonshafer/Bot-IRC-X-Dice) |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 SYNOPSIS |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
use Bot::IRC; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Bot::IRC->new( |
52
|
|
|
|
|
|
|
connect => { server => 'irc.perl.org' }, |
53
|
|
|
|
|
|
|
plugins => ['Dice'], |
54
|
|
|
|
|
|
|
)->run; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 DESCRIPTION |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
This L<Bot::IRC> plugin provides the means for the bot to perform simulated |
59
|
|
|
|
|
|
|
dice rolls. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
roll <dice expression like "2d6+2"> |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 SEE ALSO |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
You can look for additional information at: |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=over 4 |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=item * |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
L<Bot::IRC> |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=item * |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
L<GitHub|https://github.com/gryphonshafer/Bot-IRC-X-Dice> |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=item * |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
L<MetaCPAN|https://metacpan.org/pod/Bot::IRC::X::Dice> |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=item * |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
L<GitHub Actions|https://github.com/gryphonshafer/Bot-IRC-X-Dice/actions> |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=item * |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
L<Codecov|https://codecov.io/gh/gryphonshafer/Bot-IRC-X-Dice> |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=item * |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
L<CPANTS|http://cpants.cpanauthors.org/dist/Bot-IRC-X-Dice> |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=item * |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
L<CPAN Testers|http://www.cpantesters.org/distro/T/Bot-IRC-X-Dice.html> |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=back |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=for Pod::Coverage init |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 AUTHOR |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Gryphon Shafer <gryphon@cpan.org> |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
This software is Copyright (c) 2016-2021 by Gryphon Shafer. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
This is free software, licensed under: |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=cut |