| Home | Trees | Index | Help |
|
|---|
| Package lyntin :: Module exported |
|
This is the API for lyntin internals and is guaranteed to change very rarely even though we might change Lyntin's internals. If it does change it'll be between major Lyntin versions.
write_hook:
The write_hook allows you to persist data. Functions that register
with this hook should return a list of strings.
For example, the alias plugin would register with this hook and if
I had an alias vv, it would return:
[ "alias {vv} {this is my alias}" ]
as its data. If quiet == 1, then it would return:
[ "alias {vv} {this is my alias} quiet={true}" ]
because "quiet" is an argument for the alias command which quells
output when it's called (assuming the output isn't error output).
Arg mapping: {"session": Session, "quiet": boolean }
session - the session in question
quiet - whether (1) or not (0) to append an argument that causes
the command to quell input when it is later read in
| Exceptions | |
|---|---|
DoneSpammingException |
|
StopSpammingException |
This is what you raise when you're implementing a handler hook and you've handled the data. |
| Function Summary | |
|---|---|
This function allows you to add additional commands to Lyntin. | |
Adds a new configuration item. | |
| string |
Adds a help topic to the structure. |
Registers a manager with the engine. | |
| string |
Grabs the variable manager (which we're hoping is using the same expand_vars as what's registered--only time will tell) and expands variables using the variable manager and its varmap. |
This is the mapping function to use for filter-style hooks. | |
This is a slightly optimized filter_mapper hook because it's used so often in the system. | |
| list of session.Session's |
Returns a list of the active sessions including the common one. |
| list of strings |
Returns a list of the existing commands in Lyntin. |
Gets a value for a config item. | |
| session.Session |
Returns the current session. |
This is a helper function provided for backwards compatibility with older modules. | |
| string |
Retrieves a help topic via a fully qualified name. |
| list of strings |
Retrieves the history as a oldest to youngest list of strings. |
| Hook |
If the hook exists, returns the hook. |
| manager.Manager |
Retrieves a manager from the engine. |
| int |
Returns the total number of errors Lyntin has had thus far. |
| session.Session |
Returns a named session or None if the session doesn't exist. |
| tuple of (int, int, int) |
Returns Lyntin's version number as a tuple. |
| list of strings |
Calls the write_hook and retrieves data from all the functions that have registered with the hook. |
Registers a function with a hook. | |
| map of output arguments |
Sends out input to all the registrants of a hook. |
If the hook exists, unregisters the func from the hook. | |
The best way of executing a Lyntin command as if the user had typed it. | |
This is the done hook function to go with the query mapper for proper behaviour. | |
This is the mapping function to be used for query-style hooks. | |
| boolean |
Removes a command from Lyntin. |
Allows you to remove a configuration item from the system. | |
Removes a help topic from Lyntin. | |
| boolean |
Removes a manager from the engine. |
Changes the current session to another session. | |
Sets the number of errors Lyntin has had thus far. | |
This adds one to the current error count and checks to see if we're over our limit. | |
Calls engine.myengine.writeError which writes ERROR message. | |
Calls engine.myengine.writeMessage which writes LTDATA message. | |
Calls engine.myengine.writeMudData which writes a MUDDATA message. | |
Convenience method for grabbing the traceback, formatting it, piping it through write_error, with a message for the user. | |
Calls engine.myengine.writeUI which writes a message to the ui. | |
Calls engine.myengine.writeUserData which writes a USERDATA message. | |
| Variable Summary | |
|---|---|
int |
FIRST = 1 |
int |
LAST = 99 |
NoneType |
myengine = None |
| Function Details |
|---|
add_command(cmd, func, arguments=None, argoptions=None, helptext='')This function allows you to add additional commands to Lyntin. Note, if you add a command that has the same name as an existing command, we'll first remove the existing command and then add the new command (this is done in the CommandManager). If you add a ^ to the beginning of the command name, then the user has to type the entire command name for it to kick off. For example, if I specified "^end", then the user has to type "#end" to execute that command. If I had specified "end", then the user could type "e", "en", or "end". If you don't specify helptext and the function has a doc_string, then we'll pull the helptext from the function's doc_string. This creates a basic command that has no arguments or argoptions and adds it to the CommandManager:
import os
from lyntin.exported import add_command
ht = "This command does an os.system("who") to let you see " + "who's online\nright now."
def who_cmd(ses, args, input):
os.system("who")
add_command("who", who_cmd, "", None, ht)
Same thing, but the help text is in the doc_string of the
command:
import os
from lyntin.exported import add_command
def who_cmd(ses, args, input):
"""
This command does an os.system("who") to let you see who's
online right now.
"""
os.system("who")
add_command("who", who_cmd)
|
add_config(name, configitem, ses=None)Adds a new configuration item. Configuration items allow you to present the user with options that they can change which control the behavior of your module. Examples of this abound in Lyntin. Here we create a boolean config item to control whether we're ignoring actions or not for the session named "a":
from lyntin import config
from lyntin.exported import add_config
tc = config.BoolConfig("ignoreactions", 0, 1, "Allows you to turn off action handling")
add_config("ignoreactions", tc, get_session("a"))
|
add_help(fqn, helptext)Adds a help topic to the structure. See the helpmanager documentation for more details as to what the helptext should look like. Note: If you're building commands, the add_command function allows you to pass in help text for the command. If you don't pass in help text and the command function has a doc_string, then we'll try to extract the help text from the doc_string.
|
add_manager(name, mgr)Registers a manager with the engine. example of usage:
from lyntin.exported import add_manager
from lyntin import manager
class MyManager(manager.Manager):
def __init__(self):
pass
add_manager("mymanager", MyManager)
Managers are pretty straightforward especially considering that
Lyntin makes great use of them so there are lots of examples.
|
expand_ses_vars(text, ses)Grabs the variable manager (which we're hoping is using the same expand_vars as what's registered--only time will tell) and expands variables using the variable manager and its varmap.
|
filter_mapper(x, y)This is the mapping function to use for filter-style hooks. Spamhook should be called as:
|
filter_mapper_hook_spam(hookname, argmap={}, emptyfunc=<function <lambda> at 0x4025f924>, donefunc=<function <lambda> at 0x4025f95c>)This is a slightly optimized filter_mapper hook because it's used so often in the system. It incorproates the filter_mapper, but skips any exception handling. Arguments correspond to hook_spam. |
get_active_sessions()Returns a list of the active sessions including the common one.
|
get_commands()Returns a list of the existing commands in Lyntin.
|
get_config(name, ses=None, defaultvalue='No default value')Gets a value for a config item. If the default value is not specified, then it will raise a ValueError. This gets the snoopdefault config value. Since we're not specifying a session, it'll get the global one:
from lyntin.exported import get_config
snoopdefault = get_config("snoopdefault", defaultvalue=0)
This gets the ignoreactions setting for the session named
"a":
from lyntin.exported import get_config, get_session
ia = get_config("ignoreactions", get_session("a"), defaultvalue=0)
|
get_current_session()Returns the current session.
|
get_engine()This is a helper function provided for backwards compatibility with older modules. |
get_help(fqn)Retrieves a help topic via a fully qualified name.
|
get_history(count=30)Retrieves the history as a oldest to youngest list of strings.
|
get_hook(hookname)If the hook exists, returns the hook. Otherwise it creates a new hook and returns that.
|
get_manager(name)Retrieves a manager from the engine.
|
get_num_errors()Returns the total number of errors Lyntin has had thus far.
|
get_session(name)Returns a named session or None if the session doesn't exist.
|
get_version()Returns Lyntin's version number as a tuple. For example, if this were Lyntin version 4.0, the tuple would be (4, 0, 0). If this were Lyntin version 55.3.2 the tuple would be (55, 3, 2).
|
get_write_data(ses, quiet=0)Calls the write_hook and retrieves data from all the functions that have registered with the hook. It passes in the session involved, and also the "quiet" argument. For example, the alias module might have one alias for session a. It would return:
[ "alias {vv %1} {evoke %1}" ]
If quiet was 1, then it would return:
[ "alias {vv %1} {evoke %1} quiet={true}" ]
Then this method would take all those lists of strings and generate one list of all the strings and return it. Exceptions kicked up by poorly written plugins (and bad Lyntin code) will get percolated upwards. i.e. if exceptions are raised, then you won't get any return data.
|
hook_register(hookname, func, place=99)Registers a function with a hook.
|
hook_spam(hookname, argmap={}, mappingfunc=<function <lambda> at 0x4025f844>, emptyfunc=<function <lambda> at 0x4025f87c>, donefunc=<function <lambda> at 0x4025f8b4>)Sends out input to all the registrants of a hook.
|
hook_unregister(hookname, func)If the hook exists, unregisters the func from the hook.
|
lyntin_command(text, internal=0, session=None)The best way of executing a Lyntin command as if the user had typed it. This executes "#help", doesn't create an entry in the history, and doesn't spam the from_user_hook:
from lyntin.exported import lyntin_command
lyntin_command("#help", internal=1, session=None)
This executes "#action {killing blow} {reclaim}", creates
an entry in the history, spams the from_user_hook, and does it in the
session named "a":
from lyntin.exported import lyntin_command, get_session
lyntin_command("#action {killing blow} {reclaim}", internal=0, session=get_session("a"))
|
query_done(x)This is the done hook function to go with the query mapper for proper behaviour. |
query_mapper(x, y)This is the mapping function to be used for query-style hooks. Spamhook should be called as:
|
remove_command(text)Removes a command from Lyntin.
|
remove_config(name, ses=None)Allows you to remove a configuration item from the system.
|
remove_help(fqn)Removes a help topic from Lyntin.
|
remove_manager(name)Removes a manager from the engine.
|
set_current_session(ses)Changes the current session to another session.
|
set_num_errors(num)Sets the number of errors Lyntin has had thus far. Do be careful when setting this because Lyntin keeps track of errors for the purposes of shutting down the client in case we get into a runaway exception loop.
|
tally_error()This adds one to the current error count and checks to see if we're over our limit. If we are, it enqueues a shutdown event which will shutdown Lyntin. |
write_error(text, ses=None)Calls engine.myengine.writeError which writes ERROR message. If there is no engine instance available, it prints it to sysout.
|
write_message(text, ses=None)Calls engine.myengine.writeMessage which writes LTDATA message. If there is no engine instance available, it prints it to sysout.
|
write_mud_data(text, ses=None)Calls engine.myengine.writeMudData which writes a MUDDATA message. If there is no engine instance available, it prints it to sysout.
|
write_traceback(message='', ses=None)Convenience method for grabbing the traceback, formatting it, piping it through write_error, with a message for the user.
|
write_ui(text)Calls engine.myengine.writeUI which writes a message to the ui. If there is no engine instance available, it prints it to sysout.
|
write_user_data(text, ses=None)Calls engine.myengine.writeUserData which writes a USERDATA message. If there is no engine instance available, it prints it to sysout.
|
| Variable Details |
|---|
FIRST
|
LAST
|
myengine
|
| Home | Trees | Index | Help |
|
|---|
| Generated by Epydoc 2.1 on Mon Aug 9 09:17:42 2004 | http://epydoc.sf.net |