App-MonM-Notifier
view release on metacpan or search on metacpan
lib/App/MonM/Notifier/Monotifier.pm view on Meta::CPAN
#print App::MonM::Util::explain($store);
return $self; # CTK requires!
}
sub store {
my $self = shift;
return $self->{store};
}
sub raise {
my $self = shift;
say STDERR red(@_);
return 0;
}
__PACKAGE__->register_handler(
handler => "info",
description => "Show statistic information",
code => sub {
### CODE:
my ($self, $meta, @arguments) = @_;
my $store = $self->store;
lib/App/MonM/Notifier/Monotifier.pm view on Meta::CPAN
$tbl->row("Status", $info{status} // '');
$tbl->row("Published", $info{published} ? dtf(DATE_FORMAT, $info{published}) : '');
$tbl->row("Scheduled", $info{scheduled} ? dtf(DATE_FORMAT, $info{scheduled}) : '');
$tbl->row("Expired", dtf(DATE_FORMAT, $exp)) if $exp;
$tbl->row("Sent", dtf(DATE_FORMAT, $info{sent})) if $info{sent};
$tbl->row("Attempt", $info{attempt}) if $info{attempt};
$tbl->row("Errcode", $info{errcode} // 0);
$tbl->row("Errmsg", encode( locale => $info{errmsg} // '' ));
$tbl->hr;
$tbl->row("SUMMARY", ($exp < time) ? "EXPIRED" : $info{status} // '');
say $tbl->draw();
# Show attributes (dump)
if ($self->verbosemode) {
say "Attributes of channel:";
print(explain($info{attributes}));
print "\n";
# Show message
printf("%s BEGIN MESSAGE ~~~\n", "~" x (SCREENWIDTH()-18));
say encode( locale => $info{message} // '' );
printf("%s END MESSAGE ~~~\n", "~" x (SCREENWIDTH()-16));
}
} else {
my @table = $store->getAll(ROWS_LIMIT);
return $self->raise($store->error) if $store->error;
# Check data
my $n = scalar(@table) || 0;
if ($n) {
printf("Number of records: %d\n", $n);
lib/App/MonM/Notifier/Monotifier.pm view on Meta::CPAN
$tbl->row(
$rec->[0] // 0, # id
variant_stf($rec->[1] // '', 20), # to
variant_stf($rec->[2] // '', 20), # channel
variant_stf(encode( locale => $rec->[3] // '' ), 32), # subject
$rec->[11] // '', # status
$rec->[12] // 0, # errcode
);
push @errors, $rec->[13] if $rec->[12];
}
say $tbl->draw();
if ($self->verbosemode && @errors) {
foreach my $err (@errors) {
say magenta($err);
}
}
}
return 1;
});
__PACKAGE__->register_handler(
handler => "remove",
description => "Remove message by id",
( run in 0.562 second using v1.01-cache-2.11-cpan-d7a12ab2c7f )