add rand_letters()

This commit is contained in:
iou1name 2019-12-31 19:23:28 -05:00
parent 8962e93d3c
commit 7159deb7f8

View File

@ -4,6 +4,7 @@ Pick some random numbers.
""" """
import sys import sys
import random import random
import string
from module import commands, example from module import commands, example
@ -36,3 +37,22 @@ def rand(bot, trigger):
number = random.randint(low, high) number = random.randint(low, high)
bot.reply(f"random({low}, {high}) = {number}") 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))