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