diff --git a/modules/rand.py b/modules/rand.py index bda6b6e..15ae926 100755 --- a/modules/rand.py +++ b/modules/rand.py @@ -4,6 +4,7 @@ Pick some random numbers. """ import sys import random +import string from module import commands, example @@ -36,3 +37,22 @@ def rand(bot, trigger): number = random.randint(low, high) bot.reply(f"random({low}, {high}) = {number}") + + +@commands('letters') +@example('.letters', 'iloynlle') +@example('.letters 16', 'oaotordbwaauouxk') +def rand_letters(bot, trigger): + """ + usage: .letters [num_letters] [num_vowels] + + Generates a series of string of random letters. + """ + num_letters = int(trigger.group(3)) if trigger.group(3) else 8 + num_vowels = int(trigger.group(4)) if trigger.group(4) else 2 + + msg = [] + for _ in range(num_letters): + c = random.choice(string.ascii_lowercase + "aioue" * num_vowels) + msg.append(c) + bot.msg(''.join(msg))