]>
iEval git - poe-component-irc-plugin-seen.git/blob - Seen.pm
90a13a61be37da4766b43936ca71db13a1cddf0d
1 package POE
::Component
::IRC
::Plugin
::Seen
;
3 our $VERSION = 0.001001;
11 use IRC
::Utils qw
/lc_irc parse_user/;
12 use POE
::Component
::IRC
::Plugin qw
/PCI_EAT_NONE PCI_EAT_PLUGIN/;
14 ##################################################
20 $self->{dbobj
} = tie
my %db, DB_File
=> $self->{filename
};
26 my ($self, $nick, $event) = @_;
28 $self->{db
}->{$nick} = "$time $event";
34 my ($self, $irc, $nick, $to, $from) = @_;
35 if (exists $self->{db
}->{$nick}) {
36 $irc->yield(privmsg
=> $to => "I last saw $nick $self->{db}->{$nick}")
38 $irc->yield(privmsg
=> $to => "I haven't seen $nick")
44 my ($self, $irc) = @_;
45 $irc->plugin_register($self, SERVER
=> qw
/ctcp_action join part public msg/);
49 sub PCI_unregister
{ 1 }
52 my ($self, $irc, $rfullname, $rchannels, $rmessage) = @_;
53 my $nick = parse_user
$$rfullname;
55 log_event
$self, $nick => "on $$rchannels->[0] doing: * $$rmessage"
59 my ($self, $irc, $rfullname, $rchannels, $rmessage) = @_;
60 my $nick = parse_user
$$rfullname;
61 my $mynick = $irc->nick_name;
63 seen
$self, $irc, $1, $$rchannels->[0], $nick if $$rmessage =~ /^(?:$mynick [,:])?\s*!?seen\s+([^ ]+)/x;
64 log_event
$self, $nick => "on $$rchannels->[0] saying $$rmessage"
68 my ($self, $irc, $rfullname, $rchannel) = @_;
69 my $nick = parse_user
$$rfullname;
71 log_event
$self, $nick => "joining $$rchannel"
75 my ($self, $irc, $rfullname, $rchannel, $rmessage) = @_;
76 my $nick = parse_user
$$rfullname;
77 my $msg = $$rmessage ?
" with message '$$rmessage'" : '';
79 log_event
$self, $nick => "parting $$rchannel$msg"
83 my ($self, $irc, $rfullname, $rtargets, $rmessage) = @_;
84 my $nick = parse_user
$$rfullname;
86 seen
$self, $irc, $1, $$rtargets->[0], $nick if $$rmessage =~ /^\s*!?seen\s+([^ ]+)/
94 POE::Component::IRC::Plugin::Seen - PoCo-IRC plugin that remembers seeing people
98 use POE::Component::IRC::Plugin::Seen;
100 my $irc = POE::Component::IRC->spawn;
101 $irc->plugin_add(Seen => POE::Component::IRC::Plugin::Seen->new(filename => 'mycache.db'));
106 # <bot> I last saw mgv [DATE] on channel #whatever saying Hi there!
110 POE::Component::IRC::Plugin::Seen is a PoCo-IRC plugin that remembers
111 what each person around it did last. It remembers public messages,
114 When somebody sends him a private message of the form 'seen NICKNAME'
115 or somebody says 'seen NICKNAME' or 'botnick: seen NICKNAME' in a
116 channel with the bot, the plugin answers with the last action NICKNAME
117 did. There can be an exclamation mark before the word 'seen'.
123 =item B<new>([I<filename> => value])
125 Creates a new plugin object suitable for L<POE::Component::IRC>'s
126 C<plugin_add> method.
128 Takes one optional argument, C<filename>, the name of the file to
129 store the plugin's state in. If C<undef> or not given, it keeps the
136 L<POE::Component::IRC::Plugin>
140 Marius Gavrilescu C<< <marius@ieval.ro> >>
142 =head1 COPYRIGHT AND LICENSE
144 Copyright (C) 2013-2015 by Marius Gavrilescu
146 This library is free software; you can redistribute it and/or modify
147 it under the same terms as Perl itself, either Perl version 5.14.2 or,
148 at your option, any later version of Perl 5 you may have available.
This page took 0.057334 seconds and 3 git commands to generate.