inp -> text
This commit is contained in:
parent
3378fb081f
commit
8e4ce31c0e
2 changed files with 10 additions and 9 deletions
13
core/main.py
13
core/main.py
|
@ -8,6 +8,7 @@ from sqlalchemy.orm import scoped_session
|
||||||
_thread.stack_size(1024 * 512) # reduce vm size
|
_thread.stack_size(1024 * 512) # reduce vm size
|
||||||
|
|
||||||
|
|
||||||
|
#TODO: redesign this messy thing
|
||||||
class Input(dict):
|
class Input(dict):
|
||||||
def __init__(self, bot, conn, raw, prefix, command, params,
|
def __init__(self, bot, conn, raw, prefix, command, params,
|
||||||
nick, user, host, mask, paraml, msg):
|
nick, user, host, mask, paraml, msg):
|
||||||
|
@ -57,8 +58,8 @@ def run(bot, func, input):
|
||||||
uses_db = True
|
uses_db = True
|
||||||
# TODO: change to bot.get_db_session()
|
# TODO: change to bot.get_db_session()
|
||||||
print(input)
|
print(input)
|
||||||
if 'inp' not in input:
|
if 'text' not in input:
|
||||||
input.inp = input.paraml
|
input.text = input.paraml
|
||||||
|
|
||||||
if uses_db:
|
if uses_db:
|
||||||
# create SQLAlchemy session
|
# create SQLAlchemy session
|
||||||
|
@ -97,7 +98,7 @@ class Handler(object):
|
||||||
_thread.start_new_thread(self.start, ())
|
_thread.start_new_thread(self.start, ())
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
uses_db = 'db' in self.func._args
|
uses_db = True
|
||||||
while True:
|
while True:
|
||||||
input = self.input_queue.get()
|
input = self.input_queue.get()
|
||||||
|
|
||||||
|
@ -173,8 +174,8 @@ def main(bot, conn, out):
|
||||||
elif command in bot.commands:
|
elif command in bot.commands:
|
||||||
input = Input(bot, conn, *out)
|
input = Input(bot, conn, *out)
|
||||||
input.trigger = trigger
|
input.trigger = trigger
|
||||||
input.inp_unstripped = m.group(2)
|
input.text_unstripped = m.group(2)
|
||||||
input.inp = input.inp_unstripped.strip()
|
input.text = input.text_unstripped.strip()
|
||||||
|
|
||||||
func, args = bot.commands[command]
|
func, args = bot.commands[command]
|
||||||
dispatch(bot, input, "command", func, args, autohelp=True)
|
dispatch(bot, input, "command", func, args, autohelp=True)
|
||||||
|
@ -184,6 +185,6 @@ def main(bot, conn, out):
|
||||||
m = args['re'].search(inp.lastparam)
|
m = args['re'].search(inp.lastparam)
|
||||||
if m:
|
if m:
|
||||||
input = Input(bot, conn, *out)
|
input = Input(bot, conn, *out)
|
||||||
input.inp = m
|
input.text = m
|
||||||
|
|
||||||
dispatch(bot, input, "regex", func, args)
|
dispatch(bot, input, "regex", func, args)
|
||||||
|
|
|
@ -14,12 +14,12 @@ def get_generator(_json):
|
||||||
|
|
||||||
|
|
||||||
@hook.command(autohelp=False)
|
@hook.command(autohelp=False)
|
||||||
def namegen(inp, notice=None):
|
def namegen(input, conn):
|
||||||
"""namegen [generator] -- Generates some names using the chosen generator.
|
"""namegen [generator] -- Generates some names using the chosen generator.
|
||||||
'namegen list' will display a list of all generators."""
|
'namegen list' will display a list of all generators."""
|
||||||
|
|
||||||
# clean up the input
|
# clean up the input
|
||||||
inp = inp.strip().lower()
|
inp = input.text.strip().lower()
|
||||||
|
|
||||||
# get a list of available name generators
|
# get a list of available name generators
|
||||||
files = os.listdir(GEN_DIR)
|
files = os.listdir(GEN_DIR)
|
||||||
|
@ -33,7 +33,7 @@ def namegen(inp, notice=None):
|
||||||
if inp == "list":
|
if inp == "list":
|
||||||
message = "Available generators: "
|
message = "Available generators: "
|
||||||
message += text.get_text_list(all_modules, 'and')
|
message += text.get_text_list(all_modules, 'and')
|
||||||
notice(message)
|
input.notice(message)
|
||||||
return
|
return
|
||||||
|
|
||||||
if inp:
|
if inp:
|
||||||
|
|
Reference in a new issue