blib/lib/Bot/BasicBot/Pluggable/Module/StripFormatting.pm

filter: Statementstmt 80.0% 16 / 20 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 83.3% 5 / 6 Podpod 100% 1 / 1 totaltotal 75.8% 22 / 29 CC 2 SCAR 8.9
CC
2
Cov
73%
said
6.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.4
↑ Summary
1 package Bot::BasicBot::Pluggable::Module::StripFormatting;
2  
3 1 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use base 'Bot::BasicBot::Pluggable::Module';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use IRC::Utils;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 our $VERSION = '0.01';
10  
11 =head1 NAME
12  
13 Bot::BasicBot::Pluggable::Module::StripFormatting - Strip IRC formatting codes from incoming messages!
14  
15 =head1 DESCRIPTION
16  
17 A L<Bot::BasicBot::Pluggable> module to strip IRC formatting escapes from all
18 incoming messages.
19  
20 Generally, an IRC bot will only want to operate on text, and won't care about
21 formatting at all.
22  
23 This plugin just listens at priority 1, and removes all formatting from incoming
24 messages.
25  
26 It's trivially simple, but I didn't find anything when I searched, so I'm
27 releasing it in case it's of use to others.
28  
29  
30 =head1 SYNOPSIS
31  
32 Load it as you would any other B::BB::P module, and it will strip formatting
33 from incoming messages.
34  
35 =cut
36  
37 # Listen at pri 1, strip formatting from each message we see
38 0 ▶sub said {
Subroutine said: not called CC=2 SCAR=17.9
Pod documented
39 0 my ($self, $mess, $pri) = @_;
40 0 ▶ return unless $pri == 1;
Branch: 1 branch
BranchTrueFalseTotal
unless $pri == 1 0 0 0
41 0 $mess->{body} = IRC::Utils::strip_formatting($mess->{body});
42 0 return;
43 }
44  
45  
46  
47 =head1 AUTHOR
48  
49 David Precious, C<< <davidp at preshweb.co.uk> >>
50  
51 =head1 BUGS
52  
53 Please report any bugs or feature requests to C<bug-bot-basicbot-pluggable-module-stripformatting at rt.cpan.org>, or through
54 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Bot-BasicBot-Pluggable-Module-StripFormatting>. I will be notified, and then you'll
55 automatically be notified of progress on your bug as I make changes.
56  
57  
58  
59  
60  
61  
62 =head1 LICENSE AND COPYRIGHT
63  
64 Copyright 2017 David Precious.
65  
66 This program is free software; you can redistribute it and/or modify it
67 under the terms of the the Artistic License (2.0). You may obtain a
68 copy of the full license at:
69  
70 L<http://www.perlfoundation.org/artistic_license_2_0>
71  
72 Any use, modification, and distribution of the Standard or Modified
73 Versions is governed by this Artistic License. By using, modifying or
74 distributing the Package, you accept this license. Do not use, modify,
75 or distribute the Package, if you do not accept this license.
76  
77 If your Modified Version has been derived from a Modified Version made
78 by someone other than you, you are nevertheless required to ensure that
79 your Modified Version complies with the requirements of this license.
80  
81 This license does not grant you the right to use any trademark, service
82 mark, tradename, or logo of the Copyright Holder.
83  
84 This license includes the non-exclusive, worldwide, free-of-charge
85 patent license to make, have made, use, offer to sell, sell, import and
86 otherwise transfer the Package with respect to any patent claims
87 licensable by the Copyright Holder that are necessarily infringed by the
88 Package. If you institute patent litigation (including a cross-claim or
89 counterclaim) against any party alleging that the Package constitutes
90 direct or contributory patent infringement, then this Artistic License
91 to you shall terminate on the date that such litigation is filed.
92  
93 Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
94 AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
95 THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
96 PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
97 YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
98 CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
99 CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
100 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
101  
102  
103 =cut
104  
105 1 1; # End of Bot::BasicBot::Pluggable::Module::StripFormatting
↑ Summary