mirror of
https://github.com/evennia/evennia.git
synced 2026-03-19 14:26:30 +01:00
Added 'exact' keyword to player_search, allowing for fuzzy matching of player names. Resolves #422.
This commit is contained in:
parent
9770786486
commit
dd150ef3bb
1 changed files with 8 additions and 3 deletions
|
|
@ -103,19 +103,24 @@ class PlayerManager(TypedObjectManager, UserManager):
|
|||
return None
|
||||
|
||||
@returns_typeclass_list
|
||||
def player_search(self, ostring):
|
||||
def player_search(self, ostring, exact=True):
|
||||
"""
|
||||
Searches for a particular player by name or
|
||||
database id.
|
||||
|
||||
ostring = a string or database id.
|
||||
ostring - a string or database id.
|
||||
exact - allow for a partial match
|
||||
"""
|
||||
dbref = self.dbref(ostring)
|
||||
if dbref or dbref == 0:
|
||||
# bref search is always exact
|
||||
matches = self.filter(id=dbref)
|
||||
if matches:
|
||||
return matches
|
||||
return self.filter(username__iexact=ostring)
|
||||
if exact:
|
||||
return self.filter(username__iexact=ostring)
|
||||
else:
|
||||
return self.filter(username__icontains=ostring)
|
||||
|
||||
def swap_character(self, player, new_character, delete_old_character=False):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue