import random


def rnd(argv, user):
    """Random roll. Usage: roll [max] | roll [min] [max]"""
    min_roll = 1
    max_roll = 100

    try:
        if len(argv) > 2:
            min_roll = int(argv[1])
            max_roll = int(argv[2])
        elif len(argv) > 1:
            max_roll = int(argv[1])

        roll = random.randint(min_roll, max_roll)
        if min_roll == 1:
            return '%s rolls %d out of %d!' % (user.nick, roll, max_roll)
        else:
            return '%s rolls %d between %d and %d!' % (user.nick, roll, min_roll, max_roll)
    except:
        pass