<commit_before>package RoboBot::Plugin::Roll;

use v5.20;

use namespace::autoclean;

use Moose;
use MooseX::SetOnce;

use Number::Format;

extends 'RoboBot::Plugin';

has '+name' => (
    default => 'Roll',
);

has '+description' => (
    default => 'Random number generator in the style of arbitrary-sided dice-rolling.',
);

has '+commands' => (
    default => sub {{
        'roll' => { method          => 'roll',
                    preprocess_args => 1,
                    usage           => '<die size> [<die count>]',
                    example         => '2 10',
                    result          => '17' },
    }},
);

sub roll {
    my ($self, $message, $command, @args) = @_;

    my $nf = Number::Format->new();

    unless (@args && @args > 0) {<commit_msg>add simple random function to Roll<commit_after>package RoboBot::Plugin::Roll;

use v5.20;

use namespace::autoclean;

use Moose;
use MooseX::SetOnce;

use Number::Format;

extends 'RoboBot::Plugin';

has '+name' => (
    default => 'Roll',
);

has '+description' => (
    default => 'Random number generator in the style of arbitrary-sided dice-rolling.',
);

has '+commands' => (
    default => sub {{
        'roll' => { method          => 'roll',
                    preprocess_args => 1,
                    usage           => '<die size> [<die count>]',
                    example         => '2 10',
                    result          => '17' },

        'random' => { method      => 'random_int',
                      description => 'Returns a random integer between 0 and <max> (defaults to 1).',
                      usage       => '[<max>]', },
    }},
);

sub random_int {
    my ($self, $message, $command, $max) = @_;

    $max //= 1;
    return unless $max =~ m{^\d+$};

    return int(rand($max+1));
}

sub roll {
    my ($self, $message, $command, @args) = @_;

    my $nf = Number::Format->new();

    unless (@args && @args > 0) {
{'fraction_non_alphanumeric': 0.17384535547483135, 'fraction_numerical': 0.012454592631032694, 'mean_word_length': 1.9435114503816795, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '743157', 'n_tokens_mistral': 627, 'n_tokens_neox': 580, 'n_words': 163}