Adding @stats. We're just going to assume the equivalent of /all on MUX since it's a lot more informative.
This commit is contained in:
parent
bb0ff9f6ff
commit
bfafdbf9c9
3 changed files with 53 additions and 25 deletions
|
|
@ -64,6 +64,7 @@ ctable = {
|
||||||
"@reload": (commands_privileged.cmd_reload, ("genperms.process_control")),
|
"@reload": (commands_privileged.cmd_reload, ("genperms.process_control")),
|
||||||
"@set": (commands_privileged.cmd_set, None),
|
"@set": (commands_privileged.cmd_set, None),
|
||||||
"@shutdown": (commands_privileged.cmd_shutdown, ("genperms.process_control")),
|
"@shutdown": (commands_privileged.cmd_shutdown, ("genperms.process_control")),
|
||||||
|
"@stats": (commands_privileged.cmd_stats, None),
|
||||||
"@teleport": (commands_privileged.cmd_teleport, ("genperms.builder")),
|
"@teleport": (commands_privileged.cmd_teleport, ("genperms.builder")),
|
||||||
"@unlink": (commands_privileged.cmd_unlink, ("genperms.builder")),
|
"@unlink": (commands_privileged.cmd_unlink, ("genperms.builder")),
|
||||||
"@wall": (commands_privileged.cmd_wall, ("genperms.announce")),
|
"@wall": (commands_privileged.cmd_wall, ("genperms.announce")),
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,20 @@ This file contains commands that require special permissions to use. These
|
||||||
are generally @-prefixed commands, but there are exceptions.
|
are generally @-prefixed commands, but there are exceptions.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def cmd_stats(cdat):
|
||||||
|
"""
|
||||||
|
Shows stats about the database.
|
||||||
|
4012 objects = 144 rooms, 212 exits, 613 things, 1878 players. (1165 garbage)
|
||||||
|
"""
|
||||||
|
session = cdat['session']
|
||||||
|
stats_dict = functions_db.object_totals()
|
||||||
|
session.msg("%d objects = %d rooms, %d exits, %d things, %d players. (%d garbage)" % (stats_dict["objects"],
|
||||||
|
stats_dict["rooms"],
|
||||||
|
stats_dict["exits"],
|
||||||
|
stats_dict["things"],
|
||||||
|
stats_dict["players"],
|
||||||
|
stats_dict["garbage"]))
|
||||||
|
|
||||||
def cmd_reload(cdat):
|
def cmd_reload(cdat):
|
||||||
"""
|
"""
|
||||||
Reloads all modules.
|
Reloads all modules.
|
||||||
|
|
@ -351,11 +365,11 @@ def cmd_open(cdat):
|
||||||
new_object = functions_db.create_object(odat)
|
new_object = functions_db.create_object(odat)
|
||||||
|
|
||||||
session.msg("You open an unlinked exit - %s" % (new_object,))
|
session.msg("You open an unlinked exit - %s" % (new_object,))
|
||||||
|
|
||||||
def cmd_link(cdat):
|
def cmd_link(cdat):
|
||||||
"""
|
"""
|
||||||
Sets an object's home or an exit's destination.
|
Sets an object's home or an exit's destination.
|
||||||
|
|
||||||
Forms:
|
Forms:
|
||||||
@link <Object>=<Target>
|
@link <Object>=<Target>
|
||||||
"""
|
"""
|
||||||
|
|
@ -363,19 +377,19 @@ def cmd_link(cdat):
|
||||||
pobject = session.get_pobject()
|
pobject = session.get_pobject()
|
||||||
server = cdat['server']
|
server = cdat['server']
|
||||||
args = cdat['uinput']['splitted'][1:]
|
args = cdat['uinput']['splitted'][1:]
|
||||||
|
|
||||||
if len(args) == 0:
|
if len(args) == 0:
|
||||||
session.msg("Link what?")
|
session.msg("Link what?")
|
||||||
return
|
return
|
||||||
|
|
||||||
eq_args = args[0].split('=')
|
eq_args = args[0].split('=')
|
||||||
target_name = eq_args[0]
|
target_name = eq_args[0]
|
||||||
dest_name = '='.join(eq_args[1:])
|
dest_name = '='.join(eq_args[1:])
|
||||||
|
|
||||||
if len(target_name) == 0:
|
if len(target_name) == 0:
|
||||||
session.msg("What do you want to link?")
|
session.msg("What do you want to link?")
|
||||||
return
|
return
|
||||||
|
|
||||||
if len(eq_args) > 1:
|
if len(eq_args) > 1:
|
||||||
target_obj = functions_db.standard_plr_objsearch(session, target_name)
|
target_obj = functions_db.standard_plr_objsearch(session, target_name)
|
||||||
# Use standard_plr_objsearch to handle duplicate/nonexistant results.
|
# Use standard_plr_objsearch to handle duplicate/nonexistant results.
|
||||||
|
|
@ -385,7 +399,7 @@ def cmd_link(cdat):
|
||||||
if not pobject.controls_other(target_obj):
|
if not pobject.controls_other(target_obj):
|
||||||
session.msg(defines_global.NOCONTROL_MSG)
|
session.msg(defines_global.NOCONTROL_MSG)
|
||||||
return
|
return
|
||||||
|
|
||||||
# If we do something like "@link blah=", we unlink the object.
|
# If we do something like "@link blah=", we unlink the object.
|
||||||
if len(dest_name) == 0:
|
if len(dest_name) == 0:
|
||||||
target_obj.set_home(None)
|
target_obj.set_home(None)
|
||||||
|
|
@ -396,15 +410,15 @@ def cmd_link(cdat):
|
||||||
# Use standard_plr_objsearch to handle duplicate/nonexistant results.
|
# Use standard_plr_objsearch to handle duplicate/nonexistant results.
|
||||||
if not destination:
|
if not destination:
|
||||||
return
|
return
|
||||||
|
|
||||||
target_obj.set_home(destination)
|
target_obj.set_home(destination)
|
||||||
session.msg("You link %s to %s." % (target_obj,destination))
|
session.msg("You link %s to %s." % (target_obj,destination))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# We haven't provided a target.
|
# We haven't provided a target.
|
||||||
session.msg("You must provide a destination to link to.")
|
session.msg("You must provide a destination to link to.")
|
||||||
return
|
return
|
||||||
|
|
||||||
def cmd_unlink(cdat):
|
def cmd_unlink(cdat):
|
||||||
"""
|
"""
|
||||||
Unlinks an object.
|
Unlinks an object.
|
||||||
|
|
@ -437,14 +451,14 @@ def cmd_teleport(cdat):
|
||||||
pobject = session.get_pobject()
|
pobject = session.get_pobject()
|
||||||
server = cdat['server']
|
server = cdat['server']
|
||||||
args = cdat['uinput']['splitted'][1:]
|
args = cdat['uinput']['splitted'][1:]
|
||||||
|
|
||||||
if len(args) == 0:
|
if len(args) == 0:
|
||||||
session.msg("Teleport where/what?")
|
session.msg("Teleport where/what?")
|
||||||
return
|
return
|
||||||
|
|
||||||
eq_args = args[0].split('=')
|
eq_args = args[0].split('=')
|
||||||
search_str = ''.join(args)
|
search_str = ''.join(args)
|
||||||
|
|
||||||
# If we have more than one entry in our '=' delimited argument list,
|
# If we have more than one entry in our '=' delimited argument list,
|
||||||
# then we're doing a @tel <victim>=<location>. If not, we're doing
|
# then we're doing a @tel <victim>=<location>. If not, we're doing
|
||||||
# a direct teleport, @tel <destination>.
|
# a direct teleport, @tel <destination>.
|
||||||
|
|
@ -454,7 +468,7 @@ def cmd_teleport(cdat):
|
||||||
# Use standard_plr_objsearch to handle duplicate/nonexistant results.
|
# Use standard_plr_objsearch to handle duplicate/nonexistant results.
|
||||||
if not victim:
|
if not victim:
|
||||||
return
|
return
|
||||||
|
|
||||||
destination = functions_db.standard_plr_objsearch(session, eq_args[1])
|
destination = functions_db.standard_plr_objsearch(session, eq_args[1])
|
||||||
# Use standard_plr_objsearch to handle duplicate/nonexistant results.
|
# Use standard_plr_objsearch to handle duplicate/nonexistant results.
|
||||||
if not destination:
|
if not destination:
|
||||||
|
|
@ -476,7 +490,7 @@ def cmd_teleport(cdat):
|
||||||
# Kinda yucky I guess.
|
# Kinda yucky I guess.
|
||||||
cdat2 = {"server": server, "uinput": 'look', "session": victim_session}
|
cdat2 = {"server": server, "uinput": 'look', "session": victim_session}
|
||||||
cmdhandler.handle(cdat2)
|
cmdhandler.handle(cdat2)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# Direct teleport (no equal sign)
|
# Direct teleport (no equal sign)
|
||||||
target_obj = functions_db.standard_plr_objsearch(session, search_str)
|
target_obj = functions_db.standard_plr_objsearch(session, search_str)
|
||||||
|
|
@ -500,7 +514,7 @@ def cmd_wipe(cdat):
|
||||||
pobject = session.get_pobject()
|
pobject = session.get_pobject()
|
||||||
args = cdat['uinput']['splitted'][1:]
|
args = cdat['uinput']['splitted'][1:]
|
||||||
attr_search = False
|
attr_search = False
|
||||||
|
|
||||||
if len(args) == 0:
|
if len(args) == 0:
|
||||||
session.msg("Wipe what?")
|
session.msg("Wipe what?")
|
||||||
return
|
return
|
||||||
|
|
@ -524,7 +538,7 @@ def cmd_wipe(cdat):
|
||||||
# Use standard_plr_objsearch to handle duplicate/nonexistant results.
|
# Use standard_plr_objsearch to handle duplicate/nonexistant results.
|
||||||
if not target_obj:
|
if not target_obj:
|
||||||
return
|
return
|
||||||
|
|
||||||
if attr_search:
|
if attr_search:
|
||||||
# User has passed an attribute wild-card string. Search for name matches
|
# User has passed an attribute wild-card string. Search for name matches
|
||||||
# and wipe.
|
# and wipe.
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ from django.db import connection
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from apps.objects.models import Object, Attribute
|
from apps.objects.models import Object, Attribute
|
||||||
from apps.config.models import ConfigValue
|
from apps.config.models import ConfigValue
|
||||||
import defines_global as global_defines
|
import defines_global as defines_global
|
||||||
import gameconf
|
import gameconf
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
@ -19,13 +19,13 @@ def is_unsavable_flag(flagname):
|
||||||
"""
|
"""
|
||||||
Returns TRUE if the flag is an unsavable flag.
|
Returns TRUE if the flag is an unsavable flag.
|
||||||
"""
|
"""
|
||||||
return flagname.upper() in global_defines.NOSAVE_FLAGS
|
return flagname.upper() in defines_global.NOSAVE_FLAGS
|
||||||
|
|
||||||
def is_modifiable_flag(flagname):
|
def is_modifiable_flag(flagname):
|
||||||
"""
|
"""
|
||||||
Check to see if a particular flag is modifiable.
|
Check to see if a particular flag is modifiable.
|
||||||
"""
|
"""
|
||||||
if flagname.upper() not in global_defines.NOSET_FLAGS:
|
if flagname.upper() not in defines_global.NOSET_FLAGS:
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
@ -36,7 +36,7 @@ def is_modifiable_attrib(attribname):
|
||||||
|
|
||||||
attribname: (string) An attribute name to check.
|
attribname: (string) An attribute name to check.
|
||||||
"""
|
"""
|
||||||
if attribname.upper() not in global_defines.NOSET_ATTRIBS:
|
if attribname.upper() not in defines_global.NOSET_ATTRIBS:
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
@ -50,7 +50,7 @@ def get_nextfree_dbnum():
|
||||||
"""
|
"""
|
||||||
# First we'll see if there's an object of type 6 (GARBAGE) that we
|
# First we'll see if there's an object of type 6 (GARBAGE) that we
|
||||||
# can recycle.
|
# can recycle.
|
||||||
nextfree = Object.objects.filter(type__exact=global_defines.OTYPE_GARBAGE)
|
nextfree = Object.objects.filter(type__exact=defines_global.OTYPE_GARBAGE)
|
||||||
if nextfree:
|
if nextfree:
|
||||||
# We've got at least one garbage object to recycle.
|
# We've got at least one garbage object to recycle.
|
||||||
return nextfree[0]
|
return nextfree[0]
|
||||||
|
|
@ -64,9 +64,9 @@ def global_object_name_search(ostring, exact_match=False):
|
||||||
Searches through all objects for a name match.
|
Searches through all objects for a name match.
|
||||||
"""
|
"""
|
||||||
if exact_match:
|
if exact_match:
|
||||||
return Object.objects.filter(name__iexact=ostring).exclude(type=global_defines.OTYPE_GARBAGE)
|
return Object.objects.filter(name__iexact=ostring).exclude(type=defines_global.OTYPE_GARBAGE)
|
||||||
else:
|
else:
|
||||||
return Object.objects.filter(name__icontains=ostring).exclude(type=global_defines.OTYPE_GARBAGE)
|
return Object.objects.filter(name__icontains=ostring).exclude(type=defines_global.OTYPE_GARBAGE)
|
||||||
|
|
||||||
def list_search_object_namestr(searchlist, ostring, dbref_only=False, limit_types=False, match_type="fuzzy"):
|
def list_search_object_namestr(searchlist, ostring, dbref_only=False, limit_types=False, match_type="fuzzy"):
|
||||||
"""
|
"""
|
||||||
|
|
@ -98,7 +98,7 @@ def player_search(searcher, ostring):
|
||||||
if len(alias_results) > 0:
|
if len(alias_results) > 0:
|
||||||
return alias_results
|
return alias_results
|
||||||
else:
|
else:
|
||||||
return local_and_global_search(searcher, ostring, limit_types=[global_defines.OTYPE_PLAYER])
|
return local_and_global_search(searcher, ostring, limit_types=[defines_global.OTYPE_PLAYER])
|
||||||
|
|
||||||
def standard_plr_objsearch(session, ostring, search_contents=True, search_location=True, dbref_only=False, limit_types=False):
|
def standard_plr_objsearch(session, ostring, search_contents=True, search_location=True, dbref_only=False, limit_types=False):
|
||||||
"""
|
"""
|
||||||
|
|
@ -122,6 +122,19 @@ def standard_plr_objsearch(session, ostring, search_contents=True, search_locati
|
||||||
else:
|
else:
|
||||||
return results[0]
|
return results[0]
|
||||||
|
|
||||||
|
def object_totals():
|
||||||
|
"""
|
||||||
|
Returns a dictionary with database object totals.
|
||||||
|
"""
|
||||||
|
dbtotals = {}
|
||||||
|
dbtotals["objects"] = Object.objects.count()
|
||||||
|
dbtotals["things"] = Object.objects.filter(type=defines_global.OTYPE_THING).count()
|
||||||
|
dbtotals["exits"] = Object.objects.filter(type=defines_global.OTYPE_EXIT).count()
|
||||||
|
dbtotals["rooms"] = Object.objects.filter(type=defines_global.OTYPE_ROOM).count()
|
||||||
|
dbtotals["garbage"] = Object.objects.filter(type=defines_global.OTYPE_GARBAGE).count()
|
||||||
|
dbtotals["players"] = Object.objects.filter(type=defines_global.OTYPE_PLAYER).count()
|
||||||
|
return dbtotals
|
||||||
|
|
||||||
def alias_search(searcher, ostring):
|
def alias_search(searcher, ostring):
|
||||||
"""
|
"""
|
||||||
Search players by alias. Returns a list of objects whose "ALIAS" attribute
|
Search players by alias. Returns a list of objects whose "ALIAS" attribute
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue