---------------
- 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.
98 lines
3.1 KiB
Python
98 lines
3.1 KiB
Python
from django.contrib.auth.models import User
|
|
from apps.objects.models import Attribute, Object
|
|
import functions_db
|
|
import functions_general
|
|
import defines_global
|
|
|
|
"""
|
|
Commands that are available from the connect screen.
|
|
"""
|
|
|
|
def cmd_connect(cdat):
|
|
"""
|
|
This is the connect command at the connection screen. Fairly simple,
|
|
uses the Django database API and User model to make it extremely simple.
|
|
"""
|
|
|
|
session = cdat['session']
|
|
|
|
# Argument check.
|
|
if not functions_general.cmd_check_num_args(session, cdat['uinput']['splitted'], 2):
|
|
return
|
|
|
|
uemail = cdat['uinput']['splitted'][1]
|
|
password = cdat['uinput']['splitted'][2]
|
|
|
|
# Match an email address to an account.
|
|
email_matches = functions_db.get_user_from_email(uemail)
|
|
|
|
autherror = "Specified email does not match any accounts!"
|
|
# No username match
|
|
if email_matches.count() == 0:
|
|
session.msg(autherror)
|
|
return
|
|
|
|
# We have at least one result, so we can check the password.
|
|
user = email_matches[0]
|
|
|
|
if not user.check_password(password):
|
|
session.msg(autherror)
|
|
else:
|
|
uname = user.username
|
|
session.login(user)
|
|
|
|
def cmd_create(cdat):
|
|
"""
|
|
Handle the creation of new accounts.
|
|
"""
|
|
session = cdat['session']
|
|
|
|
# Argument check.
|
|
if not functions_general.cmd_check_num_args(session, cdat['uinput']['splitted'], 2):
|
|
return
|
|
|
|
server = session.server
|
|
quote_split = ' '.join(cdat['uinput']['splitted']).split("\"")
|
|
|
|
if len(quote_split) < 2:
|
|
session.msg("You must enclose your username in quotation marks.")
|
|
return
|
|
|
|
uname = quote_split[1]
|
|
lastarg_split = quote_split[2].split()
|
|
|
|
if len(lastarg_split) != 2:
|
|
session.msg("You must specify an email address, followed by a password!")
|
|
return
|
|
|
|
email = lastarg_split[0]
|
|
password = lastarg_split[1]
|
|
|
|
# Search for a user object with the specified username.
|
|
account = User.objects.filter(username=uname)
|
|
# Match an email address to an account.
|
|
email_matches = functions_db.get_user_from_email(email)
|
|
# Look for any objects with an 'Alias' attribute that matches
|
|
# the requested username
|
|
alias_matches = Object.objects.filter(attribute__attr_name__exact="ALIAS",
|
|
attribute__attr_value__iexact=uname).filter(
|
|
type=defines_global.OTYPE_PLAYER)
|
|
|
|
if not account.count() == 0 or not alias_matches.count() == 0:
|
|
session.msg("There is already a player with that name!")
|
|
elif not email_matches.count() == 0:
|
|
session.msg("There is already a player with that email address!")
|
|
elif len(password) < 3:
|
|
session.msg("Your password must be 3 characters or longer.")
|
|
else:
|
|
functions_db.create_user(cdat, uname, email, password)
|
|
|
|
def cmd_quit(cdat):
|
|
"""
|
|
We're going to maintain a different version of the quit command
|
|
here for unconnected users for the sake of simplicity. The logged in
|
|
version will be a bit more complicated.
|
|
"""
|
|
session = cdat['session']
|
|
session.msg("Disconnecting...")
|
|
session.handle_close()
|