1POE::Component::IRC::CoUmsmeorn(C3o)ntributed Perl DocumPeOnEt:a:tCioomnponent::IRC::Common(3)
2
3
4

NAME

6       POE::Component::IRC::Common - provides a set of common functions for
7       the POE::Component::IRC suite.
8

SYNOPSIS

10         use strict;
11         use warnings;
12
13         use POE::Component::IRC::Common qw( :ALL );
14
15         my $nickname = '^Lame⎪BOT[moo]';
16
17         my $uppercase_nick = u_irc( $nickname );
18         my $lowercase_nick = l_irc( $nickname );
19
20         my $mode_line = 'ov+b-i Bob sue stalin*!*@*';
21         my $hashref = parse_mode_line( $mode_line );
22
23         my $banmask = 'stalin*';
24         $full_banmask = parse_ban_mask( $banmask );
25
26         if ( matches_mask( $full_banmask, 'stalin!joe@kremlin.ru' ) ) {
27               print "EEK!";
28         }
29
30         my $results_hashref = matches_mask_array( \@masks, \@items_to_match_against );
31
32         my $nick = parse_user( 'stalin!joe@kremlin.ru' );
33         my ($nick,$user,$host) = parse_user( 'stalin!joe@kremlin.ru' );
34

DESCRIPTION

36       POE::Component::IRC::Common provides a set of common functions for the
37       POE::Component::IRC suite. There are included functions for uppercase
38       and lowercase nicknames/channelnames and for parsing mode lines and ban
39       masks.
40

FUNCTIONS

42       u_irc
43           Takes one mandatory parameter, a string to convert to IRC upper‐
44           case, and one optional parameter, the casemapping of the ircd (
45           which can be 'rfc1459', 'strict-rfc1459' or 'ascii'. Default is
46           'rfc1459' ). Returns the IRC uppercase equivalent of the passed
47           string.
48
49       l_irc
50           Takes one mandatory parameter, a string to convert to IRC lower‐
51           case, and one optional parameter, the casemapping of the ircd (
52           which can be 'rfc1459', 'strict-rfc1459' or 'ascii'. Default is
53           'rfc1459' ). Returns the IRC lowercase equivalent of the passed
54           string.
55
56       parse_mode_line
57           Takes a list representing an IRC mode line. Returns a hashref. If
58           the modeline couldn't be parsed the hashref will be empty. On suc‐
59           cess the following keys will be available in the hashref:
60
61              'modes', an arrayref of normalised modes;
62              'args', an arrayref of applicable arguments to the modes;
63
64           Example:
65
66              my $hashref = parse_mode_line( 'ov+b-i', 'Bob', 'sue', 'stalin*!*@*' );
67
68              $hashref will be
69              {
70                   'modes' => [ '+o', '+v', '+b', '-i' ],
71                   'args'  => [ 'Bob', 'sue', 'stalin*!*@*' ],
72              };
73
74       parse_ban_mask
75           Takes one parameter, a string representing an IRC ban mask. Returns
76           a normalised full banmask.
77
78           Example:
79
80              $fullbanmask = parse_ban_mask( 'stalin*' );
81
82              $fullbanmask will be 'stalin*!*@*';
83
84       matches_mask
85           Takes two parameters, a string representing an IRC mask ( it'll be
86           processed with parse_ban_mask() to ensure that it is normalised )
87           and something to match against the IRC mask, such as a
88           nick!user@hostname string. Returns 1 if they match, 0 otherwise.
89           Returns undef if parameters are missing. Optionally, one may pass
90           the casemapping ( see u_irc() ), as this function ises u_irc()
91           internally.
92
93       matches_mask_array
94           Takes two array references, the first being a list of strings rep‐
95           resenting IRC mask, the second a list of somethings to test against
96           the masks. Returns an empty hashref if there are no matches.
97           Matches are returned are arrayrefs keyed on the mask that they
98           matched.
99
100       parse_user
101           Takes one parameter, a string representing a user in the form
102           nick!user@hostname. In a scalar context it returns just the nick‐
103           name. In a list context it returns a list consisting of the nick,
104           user and hostname, respectively.
105
106       irc_ip_get_version
107           Try to guess the IP version of an IP address.
108
109               Params  : IP address
110               Returns : 4, 6, undef(unable to determine)
111
112           "$version = ip_get_version ($ip)"
113
114       irc_ip_is_ipv4
115           Check if an IP address is of type 4.
116
117               Params  : IP address
118               Returns : 1 (yes) or 0 (no)
119
120           "ip_is_ipv4($ip) and print "$ip is IPv4";"
121
122       irc_ip_is_ipv6
123           Check if an IP address is of type 6.
124
125               Params            : IP address
126               Returns           : 1 (yes) or 0 (no)
127
128           "ip_is_ipv6($ip) and print "$ip is IPv6";"
129

AUTHOR

131       Chris 'BinGOs' Williams
132
133       IP functions are shamelessly 'borrowed' from Net::IP by Manuel Valente
134

SEE ALSO

136       POE::Component::IRC
137
138       Net::IP
139
140
141
142perl v5.8.8                       2005-10-25    POE::Component::IRC::Common(3)
Impressum