From 26c6dd109a9ba9a5f0ec5ea977d772ce25ed2d1a Mon Sep 17 00:00:00 2001 From: Michael King Date: Sun, 29 Apr 2007 13:58:58 +0000 Subject: [PATCH] * Re-implemented page using @teleport's protocol. Still can't get spaces in names working out of the box, but I'm looking into squashing that. (tsal) --- commands_general.py | 46 ++++++++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/commands_general.py b/commands_general.py index bab2fb5f47..e797f7560d 100644 --- a/commands_general.py +++ b/commands_general.py @@ -241,21 +241,41 @@ def cmd_page(cdat): """ Send a message to target user (if online). """ - from apps.objects.models import Object - session = cdat['session'] - # discard command name - cdat['uinput']['splitted'].pop(0) - target_name = cdat['uinput']['splitted'].pop(0) - message = ' '.join(cdat['uinput']['splitted']) try: - target = Object.objects.get(name__iexact=target_name) - if target.is_connected_plr(): - target.emit_to("%s pages you with: %s" % (session.get_pobject().get_name(), message)) - session.msg("Page sent.") - else: - session.msg("User %s is not logged on." % (target_name.capitalize(),)) + session = cdat['session'] + pobject = session.get_pobject() + server = cdat['server'] + args = cdat['uinput']['splitted'][1:] + + if len(args) == 0: + session.msg("Page who/what?") + return + + eq_args = args[0].split('=') + if len(eq_args) > 1: + target = functions_db.local_and_global_search(pobject, eq_args[0]) + message = eq_args[1] + + if len(target) == 0: + session.msg("I can't find the user %s." % (eq_args[0].capitalize(),)) + return + elif len(message) == 0: + session.msg("I need a message to deliver.") + return + elif len(target) > 1: + session.msg("Try a more unique spelling of their name.") + return + else: + if target[0].is_connected_plr(): + target[0].emit_to("%s pages you with: %s" % + (pobject.get_name(), message)) + session.msg("Page sent.") + else: + session.msg("Player %s does not exist or is not online." % + (target[0].name.capitalize(),)) except: - session.msg("User %s not found." % (target_name,)) + from traceback import format_exc + session.msg("Untrapped error: %s" % (format_exc(),)) def cmd_quit(cdat): """