From 684ae521b7e0102e1ae34a2ec0ce2ef3117539ad Mon Sep 17 00:00:00 2001 From: Michael King Date: Tue, 7 Aug 2007 19:19:31 +0000 Subject: [PATCH] Added @boot. Currently, @boot will boot the first username match it comes across, if connected. It will not boot non-player objects, and it will not allow staff to boot other staff. --- apps/objects/models.py | 2 +- cmdtable.py | 1 + commands/objmanip.py | 65 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 1 deletion(-) diff --git a/apps/objects/models.py b/apps/objects/models.py index b0166481c1..191bb685c8 100755 --- a/apps/objects/models.py +++ b/apps/objects/models.py @@ -452,7 +452,7 @@ class Object(models.Model): functions_general.log_errmsg("Missing default home, %s '%s(#%d)' now has a null location." % (text, obj.name, obj.id)) if obj.is_player(): - if obj.is_connected(): + if obj.is_connected_plr(): if home: obj.emit_to("Your current location has ceased to exist, moving you to your home %s(#%d)." % (home.name, home.id)) else: diff --git a/cmdtable.py b/cmdtable.py index cdad3606ac..a38bb13494 100644 --- a/cmdtable.py +++ b/cmdtable.py @@ -48,6 +48,7 @@ ctable = { "version": (commands.general.cmd_version, None), "who": (commands.general.cmd_who, None), "@alias": (commands.objmanip.cmd_alias, None), + "@boot": (commands.objmanip.cmd_boot, ("genperms.manage_players")), "@ccreate": (commands.comsys.cmd_ccreate, ("objects.add_commchannel")), "@cdestroy": (commands.comsys.cmd_cdestroy, ("objects.delete_commchannel")), "@cemit": (commands.comsys.cmd_cemit, None), diff --git a/commands/objmanip.py b/commands/objmanip.py index 5042ebddc3..66460f2409 100644 --- a/commands/objmanip.py +++ b/commands/objmanip.py @@ -545,3 +545,68 @@ def cmd_destroy(cdat): session.msg("You destroy %s." % (target_obj.get_name(),)) target_obj.destroy() + +def cmd_boot(cdat): + """ + Boot a player object from the server. + """ + session = cdat['session'] + pobject = session.get_pobject() + args = cdat['uinput']['splitted'][1:] + eq_args = ' '.join(args).split('=') + searchstring = ''.join(eq_args[0]) + switches = cdat['uinput']['root_chunk'][1:] + switch_quiet = False + switch_port = False + + if not pobject.is_staff(): + session.msg("You do not have permission to do that.") + return + + if "quiet" in switches: + switch_quiet = True + + if "port" in switches: + switch_port = True + + if len(args) == 0: + session.msg("Who would you like to boot?") + return + else: + boot_list = [] + if switch_port: + sessions = session_mgr.get_session_list(True) + for sess in sessions: + if sess.getClientAddress()[1] == int(searchstring): + boot_list.append(sess) + # We're done here + break + else: + # Grab the objects that match + objs = functions_db.global_object_name_search(searchstring) + + if len(objs) < 1: + session.msg("Who would you like to boot?") + return + + if not objs[0].is_player(): + session.msg("You can only boot players.") + return + + if not pobject.controls_other(objs[0]): + if objs[0].is_superuser(): + session.msg("You cannot boot a Wizard.") + return + else: + session.msg("You do not have permission to boot that player.") + return + + if objs[0].is_connected_plr(): + boot_list.append(session_mgr.session_from_object(objs[0])) + + for boot in boot_list: + if not switch_quiet: + boot.msg("You have been disconnected by %s." % (pobject.name)) + boot.disconnectClient() + session_mgr.remove_session(boot) + return