Major recoding of plugins/namegen.py and associated files
This commit is contained in:
parent
cb4a27e2a2
commit
265f2815d8
4 changed files with 35 additions and 17 deletions
|
@ -1,33 +1,42 @@
|
||||||
from util import hook,molecular
|
# Plugin by Lukeroge
|
||||||
|
# <lukeroge@gmail.com> <https://github.com/lukeroge/CloudBot/>
|
||||||
|
|
||||||
|
from util import hook, molecular
|
||||||
import unicodedata
|
import unicodedata
|
||||||
|
|
||||||
@hook.command()
|
@hook.command()
|
||||||
def namegen(inp, say = None, nick = None, input=None, notice=None):
|
def namegen(inp, say = None, nick = None, input=None, notice=None):
|
||||||
".namegen [modules] -- generates some names using the chosen modules. \".namegen list\" will display a list of all modules"
|
".namegen [modules] -- generates some names using the chosen modules. \".namegen list\" will display a list of all modules"
|
||||||
|
|
||||||
gen = molecular.Molecule()
|
gen = molecular.Molecule()
|
||||||
|
|
||||||
all_modules = ["dever_f", "dwarves", "elves_m", "fantasy", "harn_cln", "harn_gar", "harn_m2", " harn_s_m", "human_m", "narn", "dever_m", "elves_d", "elves_n", "felana", " harn_f2", "harn_k_f", "harn_m", "hobbits", "inns", " orcs_t", "dragon", "elves_f", "elves_t", "general", "harn_f", "harn_k_m", "harn_s_f", "human_f", "items", "orcs_wh", "wc_tribes", "wc_cats"]
|
all_modules = gen.list_modules() # get a list of available name files
|
||||||
|
|
||||||
|
# return a list of all available modules
|
||||||
|
if inp == "list":
|
||||||
|
message = "Available modules: "
|
||||||
|
message += ', '.join(map(str, all_modules))
|
||||||
|
notice(message)
|
||||||
|
return
|
||||||
|
|
||||||
modules = []
|
modules = []
|
||||||
|
|
||||||
if inp == "list":
|
selected_modules = inp.split(' ') # split the input into a list of modules
|
||||||
notice("Available modules: dever_f, dwarves, elves_m, fantasy, harn_cln, harn_gar, harn_m2, harn_s_m, human_m, narn, dever_m, elves_d, elves_n, felana, harn_f2, harn_k_f, harn_m, hobbits, inns, orcs_t, dragon, elves_f, elves_t, general, harn_f, harn_k_m, harn_s_f, human_f, items, orcs_wh, wc_tribes, wc_cats")
|
|
||||||
return
|
|
||||||
|
|
||||||
if inp:
|
for module in selected_modules: # loop over the "selected_modules" list, and load any valid modules
|
||||||
modules = inp.split(' ')
|
|
||||||
else:
|
|
||||||
modules = ["human_m", "human_f"]
|
|
||||||
|
|
||||||
for module in modules:
|
|
||||||
if module in all_modules:
|
if module in all_modules:
|
||||||
gen.load(module.encode('ascii'))
|
gen.load(module.encode('ascii'))
|
||||||
|
|
||||||
if not gen.name():
|
if not gen.name(): # lets try making a name to see if any modules actually got loaded
|
||||||
return "No valid modules specified :("
|
return "No valid modules specified :("
|
||||||
|
|
||||||
|
# time to generate some names and put them in a list
|
||||||
|
name_list = []
|
||||||
|
for i in range(8):
|
||||||
|
name_list.append(gen.name())
|
||||||
|
|
||||||
|
# and finally render the final message :D
|
||||||
message = "Here are some names: "
|
message = "Here are some names: "
|
||||||
for i in range(6):
|
message += ', '.join(map(str, name_list))
|
||||||
message += gen.name() + ", "
|
|
||||||
|
|
||||||
return message
|
return message
|
||||||
|
|
|
@ -184,7 +184,14 @@ class Molecule:
|
||||||
else:
|
else:
|
||||||
self.cursection.append(line)
|
self.cursection.append(line)
|
||||||
fp.close()
|
fp.close()
|
||||||
|
|
||||||
|
def list_modules(self):
|
||||||
|
files = os.listdir(NAMEDIR)
|
||||||
|
modules = []
|
||||||
|
for i in files:
|
||||||
|
modules.append(os.path.splitext(i)[0])
|
||||||
|
return modules
|
||||||
|
|
||||||
def name(self):
|
def name(self):
|
||||||
n = []
|
n = []
|
||||||
if len(self.nametbl["first"]) > 0:
|
if len(self.nametbl["first"]) > 0:
|
||||||
|
|
|
@ -84,7 +84,7 @@ Blaze
|
||||||
|
|
||||||
[final]
|
[final]
|
||||||
tail
|
tail
|
||||||
shine
|
shine
|
||||||
shade
|
shade
|
||||||
breeze
|
breeze
|
||||||
foot
|
foot
|
||||||
|
@ -103,7 +103,7 @@ talon
|
||||||
feather
|
feather
|
||||||
storm
|
storm
|
||||||
leap
|
leap
|
||||||
flight
|
flight
|
||||||
petal
|
petal
|
||||||
fall
|
fall
|
||||||
wing
|
wing
|
||||||
|
@ -125,3 +125,4 @@ shard
|
||||||
scar
|
scar
|
||||||
blade
|
blade
|
||||||
flame
|
flame
|
||||||
|
[end]
|
||||||
|
|
|
@ -67,3 +67,4 @@ Ashes
|
||||||
Flowers
|
Flowers
|
||||||
Petals
|
Petals
|
||||||
Blossoms
|
Blossoms
|
||||||
|
[end]
|
||||||
|
|
Reference in a new issue