1POE::Component::IRC::PlUusgeirn:C:oFnotlrliobwuTtaePidOlE(P:3e:)rClomDpoocnuemnetn:t:aItRiCo:n:Plugin::FollowTail(3)
2
3
4

NAME

6       POE::Component::IRC::Plugin::FollowTail - A PoCo-IRC plugin to follow
7       the tail of an ever-growing file
8

SYNOPSIS

10        use POE qw(Component::IRC Component::IRC::Plugin::FollowTail);
11
12        my $nickname = 'Flibble' . $$;
13        my $ircname = 'Flibble the Sailor Bot';
14        my $ircserver = 'irc.blahblahblah.irc';
15        my $filename = '/some/such/file/here';
16        my @channels = ( '#Blah', '#Foo', '#Bar' );
17
18        my $irc = POE::Component::IRC->spawn(
19            nick => $nickname,
20            server => $ircserver,
21            port => $port,
22            ircname => $ircname,
23        ) or die "Oh noooo! $!";
24
25        POE::Session->create(
26            package_states => [
27                main => [ qw(_start irc_001 irc_tail_input irc_tail_error irc_tail_reset) ],
28            ],
29        );
30
31         $poe_kernel->run();
32
33        sub _start {
34            $irc->plugin_add( 'FollowTail' => POE::Component::IRC::Plugin::FollowTail->new(
35                filename => $filename,
36            ));
37            $irc->yield( register => 'all' );
38            $irc->yield( connect => { } );
39            return;
40        }
41
42        sub irc_001 {
43            $irc->yield( join => $_ ) for @channels;
44            return;
45        }
46
47        sub irc_tail_input {
48            my ($kernel, $sender, $filename, $input) = @_[KERNEL, SENDER, ARG0, ARG1];
49            $kernel->post( $sender, 'privmsg', $_, "$filename: $input" ) for @channels;
50            return;
51        }
52
53        sub irc_tail_error {
54            my ($kernel, $sender, $filename, $errnum, $errstring)
55                = @_[KERNEL, SENDER, ARG0 .. ARG2];
56            $kernel->post( $sender, 'privmsg', $_, "$filename: ERROR: $errnum $errstring" ) for @channels;
57            $irc->plugin_del( 'FollowTail' );
58            return;
59        }
60
61        sub irc_tail_reset {
62            my ($kernel, $sender, $filename) = @_[KERNEL, SENDER, ARG0];
63            $kernel->post( $sender, 'privmsg', $_, "$filename: RESET EVENT" ) for @channels;
64            return;
65        }
66

DESCRIPTION

68       POE::Component::IRC::Plugin::FollowTail is a POE::Component::IRC plugin
69       that uses POE::Wheel::FollowTail to follow the end of an ever-growing
70       file. It generates "irc_tail_" prefixed events for each new record that
71       is appended to its file.
72

METHODS

74   "new"
75       Takes two arguments:
76
77       'filename', the name of the file to tail, mandatory;
78
79       'filter', a POE::Filter object to pass to POE::Wheel::FollowTail,
80       optional;
81
82       Returns a plugin object suitable for feeding to POE::Component::IRC's
83       "plugin_add" method.
84

OUTPUT EVENTS

86       The plugin generates the following additional POE::Component::IRC
87       events:
88
89   "irc_tail_input"
90       Emitted for every complete record read. "ARG0" will be the filename,
91       "ARG1" the record which was read.
92
93   "irc_tail_error"
94       Emitted whenever an error occurs. "ARG0" will be the filename, "ARG1"
95       and "ARG2" hold numeric and string values for $!, respectively.
96
97   "irc_tail_reset"
98       Emitted every time a file is reset. "ARG0" will be the filename.
99

AUTHOR

101       Chris 'BinGOs' Williams
102

SEE ALSO

104       POE::Component::IRC
105
106       POE::Wheel::FollowTail
107
108
109
110perl v5.32.0                      202P0O-E0:7:-C2o8mponent::IRC::Plugin::FollowTail(3)
Impressum