2008-06-15 17:21:02 +00:00
|
|
|
"""
|
|
|
|
|
This is the command processing module. It is instanced once in the main
|
|
|
|
|
server module and the handle() function is hit every time a player sends
|
|
|
|
|
something.
|
|
|
|
|
"""
|
2007-04-30 14:21:48 +00:00
|
|
|
from traceback import format_exc
|
2007-05-09 15:28:12 +00:00
|
|
|
import time
|
2007-05-22 15:11:56 +00:00
|
|
|
|
2008-06-15 19:06:31 +00:00
|
|
|
from apps.objects.models import Object
|
2007-05-22 15:11:56 +00:00
|
|
|
import defines_global
|
2007-05-11 15:23:27 +00:00
|
|
|
import cmdtable
|
2008-06-15 20:31:25 +00:00
|
|
|
import logger
|
|
|
|
|
import comsys
|
|
|
|
|
from util import functions_general
|
2006-12-03 00:40:19 +00:00
|
|
|
|
2006-11-28 21:51:36 +00:00
|
|
|
class UnknownCommand(Exception):
|
2008-06-17 00:38:59 +00:00
|
|
|
"""
|
|
|
|
|
Throw this when a user enters an an invalid command.
|
|
|
|
|
"""
|
2008-12-14 20:21:02 +00:00
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
class Command(object):
|
|
|
|
|
# Reference to the master server object.
|
|
|
|
|
server = None
|
|
|
|
|
# The player session that the command originated from.
|
|
|
|
|
session = None
|
|
|
|
|
# The entire raw, un-parsed command.
|
|
|
|
|
raw_input = None
|
|
|
|
|
# Just the root command. IE: if input is "look dog", this is just "look".
|
|
|
|
|
command_string = None
|
|
|
|
|
# A list of switches in the form of strings.
|
|
|
|
|
command_switches = []
|
|
|
|
|
# The un-parsed argument provided. IE: if input is "look dog", this is "dog".
|
|
|
|
|
command_argument = None
|
|
|
|
|
|
|
|
|
|
def parse_command_switches(self):
|
|
|
|
|
"""
|
|
|
|
|
Splits any switches out of a command_string into the command_switches
|
|
|
|
|
list, and yanks the switches out of the original command_string.
|
|
|
|
|
"""
|
|
|
|
|
splitted_command = self.command_string.split('/')
|
|
|
|
|
self.command_switches = splitted_command[1:]
|
|
|
|
|
self.command_string = splitted_command[0]
|
|
|
|
|
|
|
|
|
|
def parse_command(self):
|
|
|
|
|
"""
|
|
|
|
|
Breaks the command up into the main command string, a list of switches,
|
|
|
|
|
and a string containing the argument provided with the command. More
|
|
|
|
|
specific processing is left up to the individual command functions.
|
|
|
|
|
"""
|
|
|
|
|
try:
|
|
|
|
|
"""
|
|
|
|
|
Break the command in half into command and argument. If the
|
|
|
|
|
command string can't be parsed, it has no argument and is
|
|
|
|
|
handled by the except ValueError block below.
|
|
|
|
|
"""
|
|
|
|
|
(self.command_string, self.command_argument) = self.raw_input.split(' ', 1)
|
|
|
|
|
self.command_argument = self.command_argument.strip()
|
|
|
|
|
if self.command_argument == '':
|
|
|
|
|
self.command_argument = None
|
|
|
|
|
except ValueError:
|
|
|
|
|
"""
|
|
|
|
|
No arguments. IE: look, who.
|
|
|
|
|
"""
|
|
|
|
|
self.command_string = self.raw_input
|
|
|
|
|
finally:
|
|
|
|
|
# Parse command_string for switches, regardless of what happens.
|
|
|
|
|
self.parse_command_switches()
|
|
|
|
|
|
|
|
|
|
def __init__(self, raw_input, server=None, session=None):
|
|
|
|
|
self.server = server
|
|
|
|
|
self.raw_input = raw_input
|
|
|
|
|
self.session = session
|
|
|
|
|
self.parse_command()
|
|
|
|
|
|
|
|
|
|
def arg_has_target(self):
|
|
|
|
|
"""
|
|
|
|
|
Returns true if the argument looks to be target-style. IE:
|
|
|
|
|
page blah=hi
|
|
|
|
|
kick ball=north
|
|
|
|
|
"""
|
|
|
|
|
return "=" in self.command_argument
|
|
|
|
|
|
|
|
|
|
def get_arg_targets(self, delim=','):
|
|
|
|
|
"""
|
|
|
|
|
Returns a list of targets from the argument. These happen before
|
|
|
|
|
the '=' sign and may be separated by a delimiter.
|
|
|
|
|
"""
|
|
|
|
|
# Make sure we even have a target (= sign).
|
|
|
|
|
if not self.arg_has_target():
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
target = self.command_argument.split('=', 1)[0]
|
|
|
|
|
return [targ.strip() for targ in target.split(delim)]
|
|
|
|
|
|
|
|
|
|
def get_arg_target_value(self):
|
|
|
|
|
"""
|
|
|
|
|
In a case of something like: page bob=Hello there, the target is "bob",
|
|
|
|
|
while the value is "Hello there". This function returns the portion
|
|
|
|
|
of the command that takes place after the first equal sign.
|
|
|
|
|
"""
|
|
|
|
|
# Make sure we even have a target (= sign).
|
|
|
|
|
if not self.arg_has_target():
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
return self.command_argument.split('=', 1)[1]
|
2006-11-28 21:51:36 +00:00
|
|
|
|
2006-12-25 06:04:06 +00:00
|
|
|
def match_exits(pobject, searchstr):
|
2008-06-17 00:38:59 +00:00
|
|
|
"""
|
|
|
|
|
See if we can find an input match to exits.
|
|
|
|
|
"""
|
2008-12-14 20:21:02 +00:00
|
|
|
exits = pobject.get_location().get_contents(filter_type=defines_global.OTYPE_EXIT)
|
|
|
|
|
return Object.objects.list_search_object_namestr(exits,
|
|
|
|
|
searchstr,
|
|
|
|
|
match_type="exact")
|
2006-12-25 06:04:06 +00:00
|
|
|
|
2008-12-14 20:21:02 +00:00
|
|
|
def handle(command):
|
2008-06-17 00:38:59 +00:00
|
|
|
"""
|
|
|
|
|
Use the spliced (list) uinput variable to retrieve the correct
|
|
|
|
|
command, or return an invalid command error.
|
basicobject.py
---------------
- Checks for NULL description on objects- if Null, it doesn't print the extra line any more.
- Made the checks for contents a little less ambiguous
cmdhandler.py
--------------
- Added new method 'parse_command' which takes a command string and tries to break it up based on common command parsing rules. Mostly complete, but could use some work on the edge cases. Check out the docstring on the function- I tried to make it fairly well documented.
- Changed the check for 'non-standard characters' to just return, rather than throw an Exception. Not sure if this causes any issues, but I noticed that when you hit enter without entering a command it would trigger this code. Now it just fails silently.
- The handle function now calls the parse_command function now and stores the results in parsed_input['parsed_command']. This then gets put into cdat['uinput'] at the end of handle() like before. The old data in parsed_input is still there, this is just a new field.
- Added cdat['raw_input'] to pass the full, untouched command string on. This is also stored in parsed_input['parsed_command']['raw_command'] so not sure fi this is necessary any longer, probably not.
cmdtable.py
------------
- Just cleaned it up a bit and straightened out the columns after changing 3-4 space indentation.
apps/objects/models.py
-----------------------
- set_description now sets the description attribute to 'None' (or Null in the db) when given a blank description. This is used for the change mentioned above in basicobject.py
- get_description now returns None if self.description is None
- used defines_global in the comparison methods like is_player
functions_db.py
----------------
- Changed import defines_global as defines_global to just 'import defines_global'- wasn't sure why this was this way, if I broke something (I didn't seem to) let me know.
- renamed player_search to player_name_search. Removed the use of local_and_global_search inside of it. local_and_global_search now calls it when it receives a search_string that starts with *.
- alias_search now only looks at attributes with attr_name == ALIAS. It used to just look at attr_value, which could match anything, it seemed.
- added 'dbref_search'
- local_and_global_search changes:
- Now uses dbref_search & player_search if the string starts with "#" or "*" respectively
- Changed when it uses dbref_search to whenever the search_string is a dbref. It used to check that it was a dbref, and that search_contents & search_location were set, but I *believe* in most MU*'s when you supply a dbref it never fails to find the object.
commands/unloggedin.py
-----------------------
- removed hardcoded object type #'s and started using defines_global instead
- when creating a new account, made sure that no object with an alias matching the player name requested exists. This is behavior from TinyMUSH, and I think most MUSHs follow this, but if not this is easy enough to change back.
commands/general.py
--------------------
- Rewrote cmd_page:
- New Features
- Page by dbref
- Page multiple people
- pose (:) and no space pose (;) pages
- When someone hits page without a target or data, it now will tell the player who they last paged, or say they haven't paged anyone if they don't have a LASTPAGED
- uses parse_command, made it a lot easier to work through the extra functionality added above
- When there are multiple words in a page target, it first tries to find a player that matches the entire string. If that fails, then it goes through each word, assuming each is a separate target, and works out paging them.
commands/objmanip.py
---------------------
- I started to muck with cmd_name & cmd_page, but decided to hold off for now. Largely, if everyone is cool with the idea that names & aliases should be totally unique, then we need to go ahead and re-write these. I'll do that if everyone is cool with it.
2008-06-13 18:15:54 +00:00
|
|
|
|
2008-06-17 00:38:59 +00:00
|
|
|
We're basically grabbing the player's command by tacking
|
|
|
|
|
their input on to 'cmd_' and looking it up in the GenCommands
|
|
|
|
|
class.
|
|
|
|
|
"""
|
2008-12-14 20:21:02 +00:00
|
|
|
session = command.session
|
|
|
|
|
server = command.server
|
2008-06-17 00:38:59 +00:00
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
# TODO: Protect against non-standard characters.
|
2008-12-14 20:21:02 +00:00
|
|
|
if command.raw_input == '':
|
|
|
|
|
# Nothing sent in of value, ignore it.
|
2008-06-17 00:38:59 +00:00
|
|
|
return
|
|
|
|
|
|
|
|
|
|
# Now we'll see if the user is using an alias. We do a dictionary lookup,
|
2008-12-14 20:21:02 +00:00
|
|
|
# if the key (the player's command_string) doesn't exist on the dict,
|
|
|
|
|
# just keep the command_string the same. If the key exists, its value
|
|
|
|
|
# replaces the command_string. For example, sa -> say.
|
|
|
|
|
command.command_string = server.cmd_alias_list.get(
|
|
|
|
|
command.command_string,
|
|
|
|
|
command.command_string)
|
basicobject.py
---------------
- Checks for NULL description on objects- if Null, it doesn't print the extra line any more.
- Made the checks for contents a little less ambiguous
cmdhandler.py
--------------
- Added new method 'parse_command' which takes a command string and tries to break it up based on common command parsing rules. Mostly complete, but could use some work on the edge cases. Check out the docstring on the function- I tried to make it fairly well documented.
- Changed the check for 'non-standard characters' to just return, rather than throw an Exception. Not sure if this causes any issues, but I noticed that when you hit enter without entering a command it would trigger this code. Now it just fails silently.
- The handle function now calls the parse_command function now and stores the results in parsed_input['parsed_command']. This then gets put into cdat['uinput'] at the end of handle() like before. The old data in parsed_input is still there, this is just a new field.
- Added cdat['raw_input'] to pass the full, untouched command string on. This is also stored in parsed_input['parsed_command']['raw_command'] so not sure fi this is necessary any longer, probably not.
cmdtable.py
------------
- Just cleaned it up a bit and straightened out the columns after changing 3-4 space indentation.
apps/objects/models.py
-----------------------
- set_description now sets the description attribute to 'None' (or Null in the db) when given a blank description. This is used for the change mentioned above in basicobject.py
- get_description now returns None if self.description is None
- used defines_global in the comparison methods like is_player
functions_db.py
----------------
- Changed import defines_global as defines_global to just 'import defines_global'- wasn't sure why this was this way, if I broke something (I didn't seem to) let me know.
- renamed player_search to player_name_search. Removed the use of local_and_global_search inside of it. local_and_global_search now calls it when it receives a search_string that starts with *.
- alias_search now only looks at attributes with attr_name == ALIAS. It used to just look at attr_value, which could match anything, it seemed.
- added 'dbref_search'
- local_and_global_search changes:
- Now uses dbref_search & player_search if the string starts with "#" or "*" respectively
- Changed when it uses dbref_search to whenever the search_string is a dbref. It used to check that it was a dbref, and that search_contents & search_location were set, but I *believe* in most MU*'s when you supply a dbref it never fails to find the object.
commands/unloggedin.py
-----------------------
- removed hardcoded object type #'s and started using defines_global instead
- when creating a new account, made sure that no object with an alias matching the player name requested exists. This is behavior from TinyMUSH, and I think most MUSHs follow this, but if not this is easy enough to change back.
commands/general.py
--------------------
- Rewrote cmd_page:
- New Features
- Page by dbref
- Page multiple people
- pose (:) and no space pose (;) pages
- When someone hits page without a target or data, it now will tell the player who they last paged, or say they haven't paged anyone if they don't have a LASTPAGED
- uses parse_command, made it a lot easier to work through the extra functionality added above
- When there are multiple words in a page target, it first tries to find a player that matches the entire string. If that fails, then it goes through each word, assuming each is a separate target, and works out paging them.
commands/objmanip.py
---------------------
- I started to muck with cmd_name & cmd_page, but decided to hold off for now. Largely, if everyone is cool with the idea that names & aliases should be totally unique, then we need to go ahead and re-write these. I'll do that if everyone is cool with it.
2008-06-13 18:15:54 +00:00
|
|
|
|
2008-06-17 00:38:59 +00:00
|
|
|
# This will hold the reference to the command's function.
|
|
|
|
|
cmd = None
|
basicobject.py
---------------
- Checks for NULL description on objects- if Null, it doesn't print the extra line any more.
- Made the checks for contents a little less ambiguous
cmdhandler.py
--------------
- Added new method 'parse_command' which takes a command string and tries to break it up based on common command parsing rules. Mostly complete, but could use some work on the edge cases. Check out the docstring on the function- I tried to make it fairly well documented.
- Changed the check for 'non-standard characters' to just return, rather than throw an Exception. Not sure if this causes any issues, but I noticed that when you hit enter without entering a command it would trigger this code. Now it just fails silently.
- The handle function now calls the parse_command function now and stores the results in parsed_input['parsed_command']. This then gets put into cdat['uinput'] at the end of handle() like before. The old data in parsed_input is still there, this is just a new field.
- Added cdat['raw_input'] to pass the full, untouched command string on. This is also stored in parsed_input['parsed_command']['raw_command'] so not sure fi this is necessary any longer, probably not.
cmdtable.py
------------
- Just cleaned it up a bit and straightened out the columns after changing 3-4 space indentation.
apps/objects/models.py
-----------------------
- set_description now sets the description attribute to 'None' (or Null in the db) when given a blank description. This is used for the change mentioned above in basicobject.py
- get_description now returns None if self.description is None
- used defines_global in the comparison methods like is_player
functions_db.py
----------------
- Changed import defines_global as defines_global to just 'import defines_global'- wasn't sure why this was this way, if I broke something (I didn't seem to) let me know.
- renamed player_search to player_name_search. Removed the use of local_and_global_search inside of it. local_and_global_search now calls it when it receives a search_string that starts with *.
- alias_search now only looks at attributes with attr_name == ALIAS. It used to just look at attr_value, which could match anything, it seemed.
- added 'dbref_search'
- local_and_global_search changes:
- Now uses dbref_search & player_search if the string starts with "#" or "*" respectively
- Changed when it uses dbref_search to whenever the search_string is a dbref. It used to check that it was a dbref, and that search_contents & search_location were set, but I *believe* in most MU*'s when you supply a dbref it never fails to find the object.
commands/unloggedin.py
-----------------------
- removed hardcoded object type #'s and started using defines_global instead
- when creating a new account, made sure that no object with an alias matching the player name requested exists. This is behavior from TinyMUSH, and I think most MUSHs follow this, but if not this is easy enough to change back.
commands/general.py
--------------------
- Rewrote cmd_page:
- New Features
- Page by dbref
- Page multiple people
- pose (:) and no space pose (;) pages
- When someone hits page without a target or data, it now will tell the player who they last paged, or say they haven't paged anyone if they don't have a LASTPAGED
- uses parse_command, made it a lot easier to work through the extra functionality added above
- When there are multiple words in a page target, it first tries to find a player that matches the entire string. If that fails, then it goes through each word, assuming each is a separate target, and works out paging them.
commands/objmanip.py
---------------------
- I started to muck with cmd_name & cmd_page, but decided to hold off for now. Largely, if everyone is cool with the idea that names & aliases should be totally unique, then we need to go ahead and re-write these. I'll do that if everyone is cool with it.
2008-06-13 18:15:54 +00:00
|
|
|
|
2008-06-17 00:38:59 +00:00
|
|
|
if session.logged_in:
|
|
|
|
|
# Store the timestamp of the user's last command.
|
|
|
|
|
session.cmd_last = time.time()
|
basicobject.py
---------------
- Checks for NULL description on objects- if Null, it doesn't print the extra line any more.
- Made the checks for contents a little less ambiguous
cmdhandler.py
--------------
- Added new method 'parse_command' which takes a command string and tries to break it up based on common command parsing rules. Mostly complete, but could use some work on the edge cases. Check out the docstring on the function- I tried to make it fairly well documented.
- Changed the check for 'non-standard characters' to just return, rather than throw an Exception. Not sure if this causes any issues, but I noticed that when you hit enter without entering a command it would trigger this code. Now it just fails silently.
- The handle function now calls the parse_command function now and stores the results in parsed_input['parsed_command']. This then gets put into cdat['uinput'] at the end of handle() like before. The old data in parsed_input is still there, this is just a new field.
- Added cdat['raw_input'] to pass the full, untouched command string on. This is also stored in parsed_input['parsed_command']['raw_command'] so not sure fi this is necessary any longer, probably not.
cmdtable.py
------------
- Just cleaned it up a bit and straightened out the columns after changing 3-4 space indentation.
apps/objects/models.py
-----------------------
- set_description now sets the description attribute to 'None' (or Null in the db) when given a blank description. This is used for the change mentioned above in basicobject.py
- get_description now returns None if self.description is None
- used defines_global in the comparison methods like is_player
functions_db.py
----------------
- Changed import defines_global as defines_global to just 'import defines_global'- wasn't sure why this was this way, if I broke something (I didn't seem to) let me know.
- renamed player_search to player_name_search. Removed the use of local_and_global_search inside of it. local_and_global_search now calls it when it receives a search_string that starts with *.
- alias_search now only looks at attributes with attr_name == ALIAS. It used to just look at attr_value, which could match anything, it seemed.
- added 'dbref_search'
- local_and_global_search changes:
- Now uses dbref_search & player_search if the string starts with "#" or "*" respectively
- Changed when it uses dbref_search to whenever the search_string is a dbref. It used to check that it was a dbref, and that search_contents & search_location were set, but I *believe* in most MU*'s when you supply a dbref it never fails to find the object.
commands/unloggedin.py
-----------------------
- removed hardcoded object type #'s and started using defines_global instead
- when creating a new account, made sure that no object with an alias matching the player name requested exists. This is behavior from TinyMUSH, and I think most MUSHs follow this, but if not this is easy enough to change back.
commands/general.py
--------------------
- Rewrote cmd_page:
- New Features
- Page by dbref
- Page multiple people
- pose (:) and no space pose (;) pages
- When someone hits page without a target or data, it now will tell the player who they last paged, or say they haven't paged anyone if they don't have a LASTPAGED
- uses parse_command, made it a lot easier to work through the extra functionality added above
- When there are multiple words in a page target, it first tries to find a player that matches the entire string. If that fails, then it goes through each word, assuming each is a separate target, and works out paging them.
commands/objmanip.py
---------------------
- I started to muck with cmd_name & cmd_page, but decided to hold off for now. Largely, if everyone is cool with the idea that names & aliases should be totally unique, then we need to go ahead and re-write these. I'll do that if everyone is cool with it.
2008-06-13 18:15:54 +00:00
|
|
|
|
2008-06-17 00:38:59 +00:00
|
|
|
# Lets the users get around badly configured NAT timeouts.
|
2008-12-14 20:21:02 +00:00
|
|
|
if command.command_string == 'idle':
|
2008-06-17 00:38:59 +00:00
|
|
|
return
|
basicobject.py
---------------
- Checks for NULL description on objects- if Null, it doesn't print the extra line any more.
- Made the checks for contents a little less ambiguous
cmdhandler.py
--------------
- Added new method 'parse_command' which takes a command string and tries to break it up based on common command parsing rules. Mostly complete, but could use some work on the edge cases. Check out the docstring on the function- I tried to make it fairly well documented.
- Changed the check for 'non-standard characters' to just return, rather than throw an Exception. Not sure if this causes any issues, but I noticed that when you hit enter without entering a command it would trigger this code. Now it just fails silently.
- The handle function now calls the parse_command function now and stores the results in parsed_input['parsed_command']. This then gets put into cdat['uinput'] at the end of handle() like before. The old data in parsed_input is still there, this is just a new field.
- Added cdat['raw_input'] to pass the full, untouched command string on. This is also stored in parsed_input['parsed_command']['raw_command'] so not sure fi this is necessary any longer, probably not.
cmdtable.py
------------
- Just cleaned it up a bit and straightened out the columns after changing 3-4 space indentation.
apps/objects/models.py
-----------------------
- set_description now sets the description attribute to 'None' (or Null in the db) when given a blank description. This is used for the change mentioned above in basicobject.py
- get_description now returns None if self.description is None
- used defines_global in the comparison methods like is_player
functions_db.py
----------------
- Changed import defines_global as defines_global to just 'import defines_global'- wasn't sure why this was this way, if I broke something (I didn't seem to) let me know.
- renamed player_search to player_name_search. Removed the use of local_and_global_search inside of it. local_and_global_search now calls it when it receives a search_string that starts with *.
- alias_search now only looks at attributes with attr_name == ALIAS. It used to just look at attr_value, which could match anything, it seemed.
- added 'dbref_search'
- local_and_global_search changes:
- Now uses dbref_search & player_search if the string starts with "#" or "*" respectively
- Changed when it uses dbref_search to whenever the search_string is a dbref. It used to check that it was a dbref, and that search_contents & search_location were set, but I *believe* in most MU*'s when you supply a dbref it never fails to find the object.
commands/unloggedin.py
-----------------------
- removed hardcoded object type #'s and started using defines_global instead
- when creating a new account, made sure that no object with an alias matching the player name requested exists. This is behavior from TinyMUSH, and I think most MUSHs follow this, but if not this is easy enough to change back.
commands/general.py
--------------------
- Rewrote cmd_page:
- New Features
- Page by dbref
- Page multiple people
- pose (:) and no space pose (;) pages
- When someone hits page without a target or data, it now will tell the player who they last paged, or say they haven't paged anyone if they don't have a LASTPAGED
- uses parse_command, made it a lot easier to work through the extra functionality added above
- When there are multiple words in a page target, it first tries to find a player that matches the entire string. If that fails, then it goes through each word, assuming each is a separate target, and works out paging them.
commands/objmanip.py
---------------------
- I started to muck with cmd_name & cmd_page, but decided to hold off for now. Largely, if everyone is cool with the idea that names & aliases should be totally unique, then we need to go ahead and re-write these. I'll do that if everyone is cool with it.
2008-06-13 18:15:54 +00:00
|
|
|
|
2008-06-17 00:38:59 +00:00
|
|
|
# Increment our user's command counter.
|
|
|
|
|
session.cmd_total += 1
|
|
|
|
|
# Player-visible idle time, not used in idle timeout calcs.
|
|
|
|
|
session.cmd_last_visible = time.time()
|
basicobject.py
---------------
- Checks for NULL description on objects- if Null, it doesn't print the extra line any more.
- Made the checks for contents a little less ambiguous
cmdhandler.py
--------------
- Added new method 'parse_command' which takes a command string and tries to break it up based on common command parsing rules. Mostly complete, but could use some work on the edge cases. Check out the docstring on the function- I tried to make it fairly well documented.
- Changed the check for 'non-standard characters' to just return, rather than throw an Exception. Not sure if this causes any issues, but I noticed that when you hit enter without entering a command it would trigger this code. Now it just fails silently.
- The handle function now calls the parse_command function now and stores the results in parsed_input['parsed_command']. This then gets put into cdat['uinput'] at the end of handle() like before. The old data in parsed_input is still there, this is just a new field.
- Added cdat['raw_input'] to pass the full, untouched command string on. This is also stored in parsed_input['parsed_command']['raw_command'] so not sure fi this is necessary any longer, probably not.
cmdtable.py
------------
- Just cleaned it up a bit and straightened out the columns after changing 3-4 space indentation.
apps/objects/models.py
-----------------------
- set_description now sets the description attribute to 'None' (or Null in the db) when given a blank description. This is used for the change mentioned above in basicobject.py
- get_description now returns None if self.description is None
- used defines_global in the comparison methods like is_player
functions_db.py
----------------
- Changed import defines_global as defines_global to just 'import defines_global'- wasn't sure why this was this way, if I broke something (I didn't seem to) let me know.
- renamed player_search to player_name_search. Removed the use of local_and_global_search inside of it. local_and_global_search now calls it when it receives a search_string that starts with *.
- alias_search now only looks at attributes with attr_name == ALIAS. It used to just look at attr_value, which could match anything, it seemed.
- added 'dbref_search'
- local_and_global_search changes:
- Now uses dbref_search & player_search if the string starts with "#" or "*" respectively
- Changed when it uses dbref_search to whenever the search_string is a dbref. It used to check that it was a dbref, and that search_contents & search_location were set, but I *believe* in most MU*'s when you supply a dbref it never fails to find the object.
commands/unloggedin.py
-----------------------
- removed hardcoded object type #'s and started using defines_global instead
- when creating a new account, made sure that no object with an alias matching the player name requested exists. This is behavior from TinyMUSH, and I think most MUSHs follow this, but if not this is easy enough to change back.
commands/general.py
--------------------
- Rewrote cmd_page:
- New Features
- Page by dbref
- Page multiple people
- pose (:) and no space pose (;) pages
- When someone hits page without a target or data, it now will tell the player who they last paged, or say they haven't paged anyone if they don't have a LASTPAGED
- uses parse_command, made it a lot easier to work through the extra functionality added above
- When there are multiple words in a page target, it first tries to find a player that matches the entire string. If that fails, then it goes through each word, assuming each is a separate target, and works out paging them.
commands/objmanip.py
---------------------
- I started to muck with cmd_name & cmd_page, but decided to hold off for now. Largely, if everyone is cool with the idea that names & aliases should be totally unique, then we need to go ahead and re-write these. I'll do that if everyone is cool with it.
2008-06-13 18:15:54 +00:00
|
|
|
|
2008-06-17 00:38:59 +00:00
|
|
|
# Just in case. Prevents some really funky-case crashes.
|
2008-12-14 20:21:02 +00:00
|
|
|
if len(command.command_string) == 0:
|
2008-06-17 00:38:59 +00:00
|
|
|
raise UnknownCommand
|
basicobject.py
---------------
- Checks for NULL description on objects- if Null, it doesn't print the extra line any more.
- Made the checks for contents a little less ambiguous
cmdhandler.py
--------------
- Added new method 'parse_command' which takes a command string and tries to break it up based on common command parsing rules. Mostly complete, but could use some work on the edge cases. Check out the docstring on the function- I tried to make it fairly well documented.
- Changed the check for 'non-standard characters' to just return, rather than throw an Exception. Not sure if this causes any issues, but I noticed that when you hit enter without entering a command it would trigger this code. Now it just fails silently.
- The handle function now calls the parse_command function now and stores the results in parsed_input['parsed_command']. This then gets put into cdat['uinput'] at the end of handle() like before. The old data in parsed_input is still there, this is just a new field.
- Added cdat['raw_input'] to pass the full, untouched command string on. This is also stored in parsed_input['parsed_command']['raw_command'] so not sure fi this is necessary any longer, probably not.
cmdtable.py
------------
- Just cleaned it up a bit and straightened out the columns after changing 3-4 space indentation.
apps/objects/models.py
-----------------------
- set_description now sets the description attribute to 'None' (or Null in the db) when given a blank description. This is used for the change mentioned above in basicobject.py
- get_description now returns None if self.description is None
- used defines_global in the comparison methods like is_player
functions_db.py
----------------
- Changed import defines_global as defines_global to just 'import defines_global'- wasn't sure why this was this way, if I broke something (I didn't seem to) let me know.
- renamed player_search to player_name_search. Removed the use of local_and_global_search inside of it. local_and_global_search now calls it when it receives a search_string that starts with *.
- alias_search now only looks at attributes with attr_name == ALIAS. It used to just look at attr_value, which could match anything, it seemed.
- added 'dbref_search'
- local_and_global_search changes:
- Now uses dbref_search & player_search if the string starts with "#" or "*" respectively
- Changed when it uses dbref_search to whenever the search_string is a dbref. It used to check that it was a dbref, and that search_contents & search_location were set, but I *believe* in most MU*'s when you supply a dbref it never fails to find the object.
commands/unloggedin.py
-----------------------
- removed hardcoded object type #'s and started using defines_global instead
- when creating a new account, made sure that no object with an alias matching the player name requested exists. This is behavior from TinyMUSH, and I think most MUSHs follow this, but if not this is easy enough to change back.
commands/general.py
--------------------
- Rewrote cmd_page:
- New Features
- Page by dbref
- Page multiple people
- pose (:) and no space pose (;) pages
- When someone hits page without a target or data, it now will tell the player who they last paged, or say they haven't paged anyone if they don't have a LASTPAGED
- uses parse_command, made it a lot easier to work through the extra functionality added above
- When there are multiple words in a page target, it first tries to find a player that matches the entire string. If that fails, then it goes through each word, assuming each is a separate target, and works out paging them.
commands/objmanip.py
---------------------
- I started to muck with cmd_name & cmd_page, but decided to hold off for now. Largely, if everyone is cool with the idea that names & aliases should be totally unique, then we need to go ahead and re-write these. I'll do that if everyone is cool with it.
2008-06-13 18:15:54 +00:00
|
|
|
|
2008-12-14 20:21:02 +00:00
|
|
|
if comsys.plr_has_channel(session, command.command_string,
|
|
|
|
|
alias_search=True, return_muted=True):
|
2008-06-17 00:38:59 +00:00
|
|
|
|
2008-12-14 20:21:02 +00:00
|
|
|
calias = command.command_string
|
2008-06-17 00:38:59 +00:00
|
|
|
cname = comsys.plr_cname_from_alias(session, calias)
|
|
|
|
|
|
2008-12-14 20:21:02 +00:00
|
|
|
if command.command_argument == "who":
|
2008-06-17 00:38:59 +00:00
|
|
|
comsys.msg_cwho(session, cname)
|
|
|
|
|
return
|
2008-12-14 20:21:02 +00:00
|
|
|
elif command.command_argument == "on":
|
2008-06-17 00:38:59 +00:00
|
|
|
comsys.plr_chan_on(session, calias)
|
|
|
|
|
return
|
2008-12-14 20:21:02 +00:00
|
|
|
elif command.command_argument == "off":
|
2008-06-17 00:38:59 +00:00
|
|
|
comsys.plr_chan_off(session, calias)
|
|
|
|
|
return
|
2008-12-14 20:21:02 +00:00
|
|
|
elif command.command_argument == "last":
|
2008-06-17 00:38:59 +00:00
|
|
|
comsys.msg_chan_hist(session, cname)
|
|
|
|
|
return
|
|
|
|
|
|
2008-12-14 20:21:02 +00:00
|
|
|
second_arg = "%s=%s" % (cname, command.command_argument)
|
|
|
|
|
command.command_string = "@cemit"
|
|
|
|
|
command.command_switches = ["sendername", "quiet"]
|
basicobject.py
---------------
- Checks for NULL description on objects- if Null, it doesn't print the extra line any more.
- Made the checks for contents a little less ambiguous
cmdhandler.py
--------------
- Added new method 'parse_command' which takes a command string and tries to break it up based on common command parsing rules. Mostly complete, but could use some work on the edge cases. Check out the docstring on the function- I tried to make it fairly well documented.
- Changed the check for 'non-standard characters' to just return, rather than throw an Exception. Not sure if this causes any issues, but I noticed that when you hit enter without entering a command it would trigger this code. Now it just fails silently.
- The handle function now calls the parse_command function now and stores the results in parsed_input['parsed_command']. This then gets put into cdat['uinput'] at the end of handle() like before. The old data in parsed_input is still there, this is just a new field.
- Added cdat['raw_input'] to pass the full, untouched command string on. This is also stored in parsed_input['parsed_command']['raw_command'] so not sure fi this is necessary any longer, probably not.
cmdtable.py
------------
- Just cleaned it up a bit and straightened out the columns after changing 3-4 space indentation.
apps/objects/models.py
-----------------------
- set_description now sets the description attribute to 'None' (or Null in the db) when given a blank description. This is used for the change mentioned above in basicobject.py
- get_description now returns None if self.description is None
- used defines_global in the comparison methods like is_player
functions_db.py
----------------
- Changed import defines_global as defines_global to just 'import defines_global'- wasn't sure why this was this way, if I broke something (I didn't seem to) let me know.
- renamed player_search to player_name_search. Removed the use of local_and_global_search inside of it. local_and_global_search now calls it when it receives a search_string that starts with *.
- alias_search now only looks at attributes with attr_name == ALIAS. It used to just look at attr_value, which could match anything, it seemed.
- added 'dbref_search'
- local_and_global_search changes:
- Now uses dbref_search & player_search if the string starts with "#" or "*" respectively
- Changed when it uses dbref_search to whenever the search_string is a dbref. It used to check that it was a dbref, and that search_contents & search_location were set, but I *believe* in most MU*'s when you supply a dbref it never fails to find the object.
commands/unloggedin.py
-----------------------
- removed hardcoded object type #'s and started using defines_global instead
- when creating a new account, made sure that no object with an alias matching the player name requested exists. This is behavior from TinyMUSH, and I think most MUSHs follow this, but if not this is easy enough to change back.
commands/general.py
--------------------
- Rewrote cmd_page:
- New Features
- Page by dbref
- Page multiple people
- pose (:) and no space pose (;) pages
- When someone hits page without a target or data, it now will tell the player who they last paged, or say they haven't paged anyone if they don't have a LASTPAGED
- uses parse_command, made it a lot easier to work through the extra functionality added above
- When there are multiple words in a page target, it first tries to find a player that matches the entire string. If that fails, then it goes through each word, assuming each is a separate target, and works out paging them.
commands/objmanip.py
---------------------
- I started to muck with cmd_name & cmd_page, but decided to hold off for now. Largely, if everyone is cool with the idea that names & aliases should be totally unique, then we need to go ahead and re-write these. I'll do that if everyone is cool with it.
2008-06-13 18:15:54 +00:00
|
|
|
|
2008-06-17 00:38:59 +00:00
|
|
|
# Get the command's function reference (Or False)
|
2008-12-14 20:21:02 +00:00
|
|
|
cmdtuple = cmdtable.GLOBAL_CMD_TABLE.get_command_tuple(command.command_string)
|
2008-06-17 00:38:59 +00:00
|
|
|
if cmdtuple:
|
|
|
|
|
# If there is a permissions element to the entry, check perms.
|
|
|
|
|
if cmdtuple[1]:
|
|
|
|
|
if not session.get_pobject().user_has_perm_list(cmdtuple[1]):
|
|
|
|
|
session.msg(defines_global.NOPERMS_MSG)
|
|
|
|
|
return
|
|
|
|
|
# If flow reaches this point, user has perms and command is ready.
|
|
|
|
|
cmd = cmdtuple[0]
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
# Not logged in, look through the unlogged-in command table.
|
2008-12-14 20:21:02 +00:00
|
|
|
cmdtuple = cmdtable.GLOBAL_UNCON_CMD_TABLE.get_command_tuple(command.command_string)
|
2008-06-17 00:38:59 +00:00
|
|
|
if cmdtuple:
|
|
|
|
|
cmd = cmdtuple[0]
|
basicobject.py
---------------
- Checks for NULL description on objects- if Null, it doesn't print the extra line any more.
- Made the checks for contents a little less ambiguous
cmdhandler.py
--------------
- Added new method 'parse_command' which takes a command string and tries to break it up based on common command parsing rules. Mostly complete, but could use some work on the edge cases. Check out the docstring on the function- I tried to make it fairly well documented.
- Changed the check for 'non-standard characters' to just return, rather than throw an Exception. Not sure if this causes any issues, but I noticed that when you hit enter without entering a command it would trigger this code. Now it just fails silently.
- The handle function now calls the parse_command function now and stores the results in parsed_input['parsed_command']. This then gets put into cdat['uinput'] at the end of handle() like before. The old data in parsed_input is still there, this is just a new field.
- Added cdat['raw_input'] to pass the full, untouched command string on. This is also stored in parsed_input['parsed_command']['raw_command'] so not sure fi this is necessary any longer, probably not.
cmdtable.py
------------
- Just cleaned it up a bit and straightened out the columns after changing 3-4 space indentation.
apps/objects/models.py
-----------------------
- set_description now sets the description attribute to 'None' (or Null in the db) when given a blank description. This is used for the change mentioned above in basicobject.py
- get_description now returns None if self.description is None
- used defines_global in the comparison methods like is_player
functions_db.py
----------------
- Changed import defines_global as defines_global to just 'import defines_global'- wasn't sure why this was this way, if I broke something (I didn't seem to) let me know.
- renamed player_search to player_name_search. Removed the use of local_and_global_search inside of it. local_and_global_search now calls it when it receives a search_string that starts with *.
- alias_search now only looks at attributes with attr_name == ALIAS. It used to just look at attr_value, which could match anything, it seemed.
- added 'dbref_search'
- local_and_global_search changes:
- Now uses dbref_search & player_search if the string starts with "#" or "*" respectively
- Changed when it uses dbref_search to whenever the search_string is a dbref. It used to check that it was a dbref, and that search_contents & search_location were set, but I *believe* in most MU*'s when you supply a dbref it never fails to find the object.
commands/unloggedin.py
-----------------------
- removed hardcoded object type #'s and started using defines_global instead
- when creating a new account, made sure that no object with an alias matching the player name requested exists. This is behavior from TinyMUSH, and I think most MUSHs follow this, but if not this is easy enough to change back.
commands/general.py
--------------------
- Rewrote cmd_page:
- New Features
- Page by dbref
- Page multiple people
- pose (:) and no space pose (;) pages
- When someone hits page without a target or data, it now will tell the player who they last paged, or say they haven't paged anyone if they don't have a LASTPAGED
- uses parse_command, made it a lot easier to work through the extra functionality added above
- When there are multiple words in a page target, it first tries to find a player that matches the entire string. If that fails, then it goes through each word, assuming each is a separate target, and works out paging them.
commands/objmanip.py
---------------------
- I started to muck with cmd_name & cmd_page, but decided to hold off for now. Largely, if everyone is cool with the idea that names & aliases should be totally unique, then we need to go ahead and re-write these. I'll do that if everyone is cool with it.
2008-06-13 18:15:54 +00:00
|
|
|
|
2008-06-17 00:38:59 +00:00
|
|
|
# Debugging stuff.
|
|
|
|
|
#session.msg("ROOT : %s" % (parsed_input['root_cmd'],))
|
|
|
|
|
#session.msg("SPLIT: %s" % (parsed_input['splitted'],))
|
|
|
|
|
|
|
|
|
|
if callable(cmd):
|
|
|
|
|
try:
|
2008-12-14 20:21:02 +00:00
|
|
|
cmd(command)
|
2008-06-17 00:38:59 +00:00
|
|
|
except:
|
|
|
|
|
session.msg("Untrapped error, please file a bug report:\n%s" % (format_exc(),))
|
|
|
|
|
logger.log_errmsg("Untrapped error, evoker %s: %s" %
|
|
|
|
|
(session, format_exc()))
|
|
|
|
|
return
|
2007-05-11 15:23:27 +00:00
|
|
|
|
2008-06-17 00:38:59 +00:00
|
|
|
if session.logged_in:
|
|
|
|
|
# If we're not logged in, don't check exits.
|
|
|
|
|
pobject = session.get_pobject()
|
2008-12-14 20:21:02 +00:00
|
|
|
exit_matches = match_exits(pobject, command.command_string)
|
2008-06-17 00:38:59 +00:00
|
|
|
if exit_matches:
|
|
|
|
|
targ_exit = exit_matches[0]
|
2008-12-14 20:21:02 +00:00
|
|
|
if targ_exit.get_home():
|
2008-06-17 00:38:59 +00:00
|
|
|
# SCRIPT: See if the player can traverse the exit
|
2008-06-21 02:05:44 +00:00
|
|
|
if not targ_exit.scriptlink.default_lock({
|
2008-06-17 00:38:59 +00:00
|
|
|
"pobject": pobject
|
|
|
|
|
}):
|
|
|
|
|
session.msg("You can't traverse that exit.")
|
|
|
|
|
else:
|
|
|
|
|
pobject.move_to(targ_exit.get_home())
|
|
|
|
|
session.execute_cmd("look")
|
|
|
|
|
else:
|
|
|
|
|
session.msg("That exit leads to nowhere.")
|
basicobject.py
---------------
- Checks for NULL description on objects- if Null, it doesn't print the extra line any more.
- Made the checks for contents a little less ambiguous
cmdhandler.py
--------------
- Added new method 'parse_command' which takes a command string and tries to break it up based on common command parsing rules. Mostly complete, but could use some work on the edge cases. Check out the docstring on the function- I tried to make it fairly well documented.
- Changed the check for 'non-standard characters' to just return, rather than throw an Exception. Not sure if this causes any issues, but I noticed that when you hit enter without entering a command it would trigger this code. Now it just fails silently.
- The handle function now calls the parse_command function now and stores the results in parsed_input['parsed_command']. This then gets put into cdat['uinput'] at the end of handle() like before. The old data in parsed_input is still there, this is just a new field.
- Added cdat['raw_input'] to pass the full, untouched command string on. This is also stored in parsed_input['parsed_command']['raw_command'] so not sure fi this is necessary any longer, probably not.
cmdtable.py
------------
- Just cleaned it up a bit and straightened out the columns after changing 3-4 space indentation.
apps/objects/models.py
-----------------------
- set_description now sets the description attribute to 'None' (or Null in the db) when given a blank description. This is used for the change mentioned above in basicobject.py
- get_description now returns None if self.description is None
- used defines_global in the comparison methods like is_player
functions_db.py
----------------
- Changed import defines_global as defines_global to just 'import defines_global'- wasn't sure why this was this way, if I broke something (I didn't seem to) let me know.
- renamed player_search to player_name_search. Removed the use of local_and_global_search inside of it. local_and_global_search now calls it when it receives a search_string that starts with *.
- alias_search now only looks at attributes with attr_name == ALIAS. It used to just look at attr_value, which could match anything, it seemed.
- added 'dbref_search'
- local_and_global_search changes:
- Now uses dbref_search & player_search if the string starts with "#" or "*" respectively
- Changed when it uses dbref_search to whenever the search_string is a dbref. It used to check that it was a dbref, and that search_contents & search_location were set, but I *believe* in most MU*'s when you supply a dbref it never fails to find the object.
commands/unloggedin.py
-----------------------
- removed hardcoded object type #'s and started using defines_global instead
- when creating a new account, made sure that no object with an alias matching the player name requested exists. This is behavior from TinyMUSH, and I think most MUSHs follow this, but if not this is easy enough to change back.
commands/general.py
--------------------
- Rewrote cmd_page:
- New Features
- Page by dbref
- Page multiple people
- pose (:) and no space pose (;) pages
- When someone hits page without a target or data, it now will tell the player who they last paged, or say they haven't paged anyone if they don't have a LASTPAGED
- uses parse_command, made it a lot easier to work through the extra functionality added above
- When there are multiple words in a page target, it first tries to find a player that matches the entire string. If that fails, then it goes through each word, assuming each is a separate target, and works out paging them.
commands/objmanip.py
---------------------
- I started to muck with cmd_name & cmd_page, but decided to hold off for now. Largely, if everyone is cool with the idea that names & aliases should be totally unique, then we need to go ahead and re-write these. I'll do that if everyone is cool with it.
2008-06-13 18:15:54 +00:00
|
|
|
return
|
|
|
|
|
|
2008-06-17 00:38:59 +00:00
|
|
|
# If we reach this point, we haven't matched anything.
|
|
|
|
|
raise UnknownCommand
|
2007-05-11 15:23:27 +00:00
|
|
|
|
2008-06-17 00:38:59 +00:00
|
|
|
except UnknownCommand:
|
|
|
|
|
session.msg("Huh? (Type \"help\" for help.)")
|
2007-05-11 15:23:27 +00:00
|
|
|
|