Add generate list

This commit is contained in:
Robert Miles 2019-11-03 14:01:49 -05:00
parent 01a070158e
commit b8db724ed2

View File

@ -5,7 +5,7 @@ NAME = re.compile(r'\$([^\s]+)')
SUB = r"#\1#" SUB = r"#\1#"
replace_name = lambda x: NAME.sub(SUB,x) replace_name = lambda x: NAME.sub(SUB,x)
GENERATORS = [ GENERATORS_LIST = [
"book_fantasy", "book_fantasy",
"book_horror", "book_horror",
"book_hp", "book_hp",
@ -29,8 +29,10 @@ def get_generator(name):
GENERATORS = utils.LazyLoadedDict(get_generator) GENERATORS = utils.LazyLoadedDict(get_generator)
@plugin.command("generate") @plugin.command("generate","<{}>".format("|".join(GENERATORS_LIST)))
def generate(bot,channel,nick,generator): def generate(bot,channel,nick,generator):
if generator not in GENERATORS_LIST:
bot.say(channel,"{}: Invalid generator!".format(nick))
res = GENERATORS[generator]() res = GENERATORS[generator]()
if generator!="idea": if generator!="idea":
res = titlecase.titlecase(res) res = titlecase.titlecase(res)