line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bot::IRC::X::MetarTaf; |
2
|
|
|
|
|
|
|
# ABSTRACT: Bot::IRC plugin for METAR and TAF reporting |
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
339448
|
use 5.014; |
|
1
|
|
|
|
|
10
|
|
5
|
1
|
|
|
1
|
|
5
|
use exact; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
4
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
1033
|
use LWP::Simple 'get'; |
|
1
|
|
|
|
|
40109
|
|
|
1
|
|
|
|
|
7
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '1.02'; # VERSION |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub init { |
12
|
1
|
|
|
1
|
0
|
6269
|
my ($bot) = @_; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
$bot->hook( |
15
|
|
|
|
|
|
|
{ |
16
|
|
|
|
|
|
|
to_me => 1, |
17
|
|
|
|
|
|
|
text => qr/^(?<type>metar|taf)\s+(?<code>\S+)/i, |
18
|
|
|
|
|
|
|
}, |
19
|
|
|
|
|
|
|
sub { |
20
|
0
|
|
|
0
|
|
0
|
my ( $bot, $in, $m ) = @_; |
21
|
0
|
|
|
|
|
0
|
my $code = uc( $m->{code} ); |
22
|
0
|
0
|
|
|
|
0
|
$code = 'K' . $code if ( length $code == 3 ); |
23
|
|
|
|
|
|
|
|
24
|
0
|
0
|
|
|
|
0
|
if ( lc( $m->{type} ) eq 'taf' ) { |
25
|
0
|
|
|
|
|
0
|
my $content = get( |
26
|
|
|
|
|
|
|
'http://tgftp.nws.noaa.gov/data/forecasts/taf/stations/' . $code . '.TXT', |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
|
29
|
0
|
0
|
|
|
|
0
|
if ($content) { |
30
|
0
|
|
|
|
|
0
|
my @content = split( /\r?\n/, $content ); |
31
|
0
|
|
|
|
|
0
|
shift @content for ( 0 .. 1 ); |
32
|
0
|
|
|
|
|
0
|
$bot->reply_to( join( '; ', map { s/^\s+|\s+$//g; $_ } @content ) ); |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
else { |
35
|
0
|
|
|
|
|
0
|
$bot->reply_to("Unable to find TAF data for $code."); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
else { |
39
|
0
|
|
|
|
|
0
|
my $content = get( |
40
|
|
|
|
|
|
|
'http://tgftp.nws.noaa.gov/data/observations/metar/stations/' . $code . '.TXT', |
41
|
|
|
|
|
|
|
); |
42
|
0
|
0
|
|
|
|
0
|
if ($content) { |
43
|
0
|
|
|
|
|
0
|
$bot->reply_to( ( split( /\r?\n/, $content ) )[1] ); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
else { |
46
|
0
|
|
|
|
|
0
|
$bot->reply_to("Unable to find METAR data for $code."); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
}, |
50
|
1
|
|
|
|
|
14
|
); |
51
|
|
|
|
|
|
|
|
52
|
1
|
|
|
|
|
9
|
$bot->helps( |
53
|
|
|
|
|
|
|
metartaf => |
54
|
|
|
|
|
|
|
'Get airport weather from NOAA. ' . |
55
|
|
|
|
|
|
|
'Usage: <bot> metar <airport code>; <bot> taf <airport code>.', |
56
|
|
|
|
|
|
|
); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__END__ |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=pod |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=encoding UTF-8 |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 NAME |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Bot::IRC::X::MetarTaf - Bot::IRC plugin for METAR and TAF reporting |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 VERSION |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
version 1.02 |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=for markdown [![test](https://github.com/gryphonshafer/Bot-IRC-X-MetarTaf/workflows/test/badge.svg)](https://github.com/gryphonshafer/Bot-IRC-X-MetarTaf/actions?query=workflow%3Atest) |
76
|
|
|
|
|
|
|
[![codecov](https://codecov.io/gh/gryphonshafer/Bot-IRC-X-MetarTaf/graph/badge.svg)](https://codecov.io/gh/gryphonshafer/Bot-IRC-X-MetarTaf) |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 SYNOPSIS |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
use Bot::IRC; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Bot::IRC->new( |
83
|
|
|
|
|
|
|
connect => { server => 'irc.perl.org' }, |
84
|
|
|
|
|
|
|
plugins => ['MetarTaf'], |
85
|
|
|
|
|
|
|
)->run; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 DESCRIPTION |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
This L<Bot::IRC> plugin is for METAR and TAF reporting. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
bot metar <airport code> |
92
|
|
|
|
|
|
|
bot taf <airport code> |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 SEE ALSO |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
You can look for additional information at: |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=over 4 |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=item * |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
L<Bot::IRC> |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=item * |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
L<GitHub|https://github.com/gryphonshafer/Bot-IRC-X-MetarTaf> |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=item * |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
L<MetaCPAN|https://metacpan.org/pod/Bot::IRC::X::MetarTaf> |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=item * |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
L<GitHub Actions|https://github.com/gryphonshafer/Bot-IRC-X-MetarTaf/actions> |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=item * |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
L<Codecov|https://codecov.io/gh/gryphonshafer/Bot-IRC-X-MetarTaf> |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=item * |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
L<CPANTS|http://cpants.cpanauthors.org/dist/Bot-IRC-X-MetarTaf> |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=item * |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
L<CPAN Testers|http://www.cpantesters.org/distro/T/Bot-IRC-X-MetarTaf.html> |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=back |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=for Pod::Coverage init |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 AUTHOR |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Gryphon Shafer <gryphon@cpan.org> |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
This software is Copyright (c) 2016-2021 by Gryphon Shafer. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
This is free software, licensed under: |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=cut |