<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-


"""
:mod:`ezroller` --- Number rolling made easy
============================================

Simple plugin that reacts on "!roll <n>" text message and rolls a random number
between 1 and `n`. `n` is set to 100 by default.
"""


__docformat__ = "restructuredtext en"


import random

from plugin import ChatCommandPlugin


class EzRoller(ChatCommandPlugin):
    def __init__(self, parent):
        super(EzRoller, self).__init__(parent)
        self._commands = {
            "!roll": self.on_roll_command,
        }

    def on_roll_command(self, message):
        max_value = message.Body.strip().split()[1]
        try:
            max_value = int(max_value)
        except ValueError:
            max_value = 100

        value = random.randint(1, max_value)
        message.Chat.SendMessage("{0} has rolled {1} (1-{2})".format(
            message.FromDisplayName, value, max_value
        ))<commit_msg>Bug fix<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-


"""
:mod:`ezroller` --- Number rolling made easy
============================================

Simple plugin that reacts on "!roll <n>" text message and rolls a random number
between 1 and `n`. `n` is set to 100 by default.
"""


__docformat__ = "restructuredtext en"


import random

from plugin import ChatCommandPlugin


class EzRoller(ChatCommandPlugin):
    def __init__(self, parent):
        super(EzRoller, self).__init__(parent)
        self._commands = {
            "!roll": self.on_roll_command,
        }

    def on_roll_command(self, message):
        max_value = message.Body.strip().split()[1]
        try:
            max_value = abs(int(max_value))
        except (ValueError, IndexError):
            max_value = 100

        value = random.randint(1, max_value)
        message.Chat.SendMessage("{0} has rolled {1} (1-{2})".format(
            message.FromDisplayName, value, max_value
        ))
{'fraction_non_alphanumeric': 0.16283818274629913, 'fraction_numerical': 0.014293006636038795, 'mean_word_length': 2.8058252427184467, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 5, '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': '2064361', 'n_tokens_mistral': 608, 'n_tokens_neox': 573, 'n_words': 154}