2012-02-23 23:40:26 +01:00
|
|
|
# Plugin by Lukeroge
|
2012-04-02 18:17:55 +02:00
|
|
|
from util import hook
|
|
|
|
from util import molecular
|
2012-04-24 17:07:01 +02:00
|
|
|
from util.text import get_text_list
|
2011-11-22 02:36:12 +01:00
|
|
|
|
2012-04-02 18:17:55 +02:00
|
|
|
|
2012-04-23 11:38:21 +02:00
|
|
|
@hook.command(autohelp=False)
|
|
|
|
def namegen(inp, notice=None):
|
2012-05-16 05:07:27 +02:00
|
|
|
"namegen [modules] -- Generates some names using the chosen modules. " \
|
|
|
|
"'namegen list' will display a list of all modules."
|
2011-11-22 02:36:12 +01:00
|
|
|
|
2012-02-23 23:40:26 +01:00
|
|
|
gen = molecular.Molecule()
|
2011-11-22 02:36:12 +01:00
|
|
|
|
2012-04-23 11:38:21 +02:00
|
|
|
# get a list of available modules
|
|
|
|
all_modules = gen.list_modules()
|
2011-11-22 02:36:12 +01:00
|
|
|
|
2012-04-23 11:38:21 +02:00
|
|
|
# command to return a list of all available modules
|
2011-11-22 02:36:12 +01:00
|
|
|
if inp == "list":
|
2012-02-23 23:40:26 +01:00
|
|
|
message = "Available modules: "
|
2012-04-23 11:38:21 +02:00
|
|
|
message += get_text_list(all_modules, 'and')
|
2012-02-23 23:40:26 +01:00
|
|
|
notice(message)
|
2011-11-22 02:45:30 +01:00
|
|
|
return
|
2012-02-02 14:05:11 +01:00
|
|
|
|
2012-04-23 11:38:21 +02:00
|
|
|
if inp:
|
|
|
|
# split the input into a list of modules
|
|
|
|
selected_modules = inp.split(' ')
|
|
|
|
else:
|
|
|
|
# make some generic fantasy names
|
|
|
|
selected_modules = ["fantasy"]
|
2012-02-23 23:40:26 +01:00
|
|
|
|
2012-04-23 11:38:21 +02:00
|
|
|
# loop over the "selected_modules" list, and load any valid modules
|
|
|
|
for module in selected_modules:
|
2011-11-22 02:36:12 +01:00
|
|
|
if module in all_modules:
|
|
|
|
gen.load(module.encode('ascii'))
|
|
|
|
|
2012-04-23 11:38:21 +02:00
|
|
|
# lets try making a name to see if any modules actually got loaded
|
|
|
|
if not gen.name():
|
2011-11-22 02:36:12 +01:00
|
|
|
return "No valid modules specified :("
|
|
|
|
|
2012-02-23 23:40:26 +01:00
|
|
|
# time to generate some names and put them in a list
|
|
|
|
name_list = []
|
2012-04-23 11:38:21 +02:00
|
|
|
for i in xrange(10):
|
2012-02-23 23:40:26 +01:00
|
|
|
name_list.append(gen.name())
|
|
|
|
|
2012-04-23 11:38:21 +02:00
|
|
|
# and finally return the final message :D
|
|
|
|
return "Some names to ponder: %s." % get_text_list(name_list, 'and')
|