App-RoboBot

 view release on metacpan or  search on metacpan

lib/App/RoboBot/Plugin/Bot/Logging.pm  view on Meta::CPAN

package App::RoboBot::Plugin::Bot::Logging;
$App::RoboBot::Plugin::Bot::Logging::VERSION = '4.004';
use v5.20;

use namespace::autoclean;

use Moose;
use MooseX::SetOnce;

use Number::Format;
use Term::ExtendedColor qw( fg bold );

extends 'App::RoboBot::Plugin';

=head1 bot.logging

Provides basic message logging and recall capabilities.

In addition to the exported functions, this module installs both pre and post
hooks into the message processing pipeline for the purposes of logging all
incoming and outgoing messages on all connected networks.

Logging functionality is enabled by default wherever the bot is connected, but
it may be disabled per-channel using ``(disable-logging)`` and re-enabled by
using ``(enable-logging)``. Any messages that occurred while logging was
disabled are lost permanently, and any functions which require logging to be
active will fail when it is disabled.

=cut

has '+name' => (
    default => 'Bot::Logging',
);

has '+description' => (
    default => 'Provides basic message logging and recall capabilities.',
);

has '+before_hook' => (
    default => 'log_incoming',
);

has '+after_hook' => (
    default => 'log_outgoing',
);

=head2 last

=head3 Description

Returns a previous message uttered in the current channel. The ``step`` is how
many messages backward to count, with ``1`` assumed and being the most recent
message available. A nick is optional, but if provided will limit the messages
considered to only those sent by the named user.

By default, any messages which had S-Expressions in them are skipped, but those
may be included by adding the ``:include-expressions`` symbol.

=head3 Usage

[:include-expressions] [<step>] [<nick>]

=head3 Examples

    (last)



( run in 0.796 second using v1.01-cache-2.11-cpan-39bf76dae61 )