Fix access bug using page/last.
This commit is contained in:
parent
443aae7f20
commit
00757677b7
2 changed files with 31 additions and 30 deletions
|
|
@ -8,15 +8,15 @@ Communication commands:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from evennia.comms.models import Msg
|
|
||||||
from evennia.accounts.models import AccountDB
|
|
||||||
from evennia.accounts import bots
|
from evennia.accounts import bots
|
||||||
from evennia.locks.lockhandler import LockException
|
from evennia.accounts.models import AccountDB
|
||||||
from evennia.comms.comms import DefaultChannel
|
from evennia.comms.comms import DefaultChannel
|
||||||
|
from evennia.comms.models import Msg
|
||||||
|
from evennia.locks.lockhandler import LockException
|
||||||
from evennia.utils import create, logger, utils
|
from evennia.utils import create, logger, utils
|
||||||
|
from evennia.utils.evmenu import ask_yes_no
|
||||||
from evennia.utils.logger import tail_log_file
|
from evennia.utils.logger import tail_log_file
|
||||||
from evennia.utils.utils import class_from_module, strip_unsafe_input
|
from evennia.utils.utils import class_from_module, strip_unsafe_input
|
||||||
from evennia.utils.evmenu import ask_yes_no
|
|
||||||
|
|
||||||
COMMAND_DEFAULT_CLASS = class_from_module(settings.COMMAND_DEFAULT_CLASS)
|
COMMAND_DEFAULT_CLASS = class_from_module(settings.COMMAND_DEFAULT_CLASS)
|
||||||
CHANNEL_DEFAULT_TYPECLASS = class_from_module(
|
CHANNEL_DEFAULT_TYPECLASS = class_from_module(
|
||||||
|
|
@ -285,8 +285,8 @@ class CmdChannel(COMMAND_DEFAULT_CLASS):
|
||||||
return None
|
return None
|
||||||
elif len(channels) > 1:
|
elif len(channels) > 1:
|
||||||
self.msg(
|
self.msg(
|
||||||
"Multiple possible channel matches/alias for "
|
f"Multiple possible channel matches/alias for '{channelname}':\n"
|
||||||
f"'{channelname}':\n" + ", ".join(chan.key for chan in channels)
|
+ ", ".join(chan.key for chan in channels)
|
||||||
)
|
)
|
||||||
return None
|
return None
|
||||||
return channels[0]
|
return channels[0]
|
||||||
|
|
@ -869,9 +869,7 @@ class CmdChannel(COMMAND_DEFAULT_CLASS):
|
||||||
subscribed, _ = self.list_channels()
|
subscribed, _ = self.list_channels()
|
||||||
table = self.display_subbed_channels(subscribed)
|
table = self.display_subbed_channels(subscribed)
|
||||||
|
|
||||||
self.msg(
|
self.msg(f"\n|wChannel subscriptions|n (use |w/all|n to see all available):\n{table}")
|
||||||
"\n|wChannel subscriptions|n " f"(use |w/all|n to see all available):\n{table}"
|
|
||||||
)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
if not self.switches and not self.args:
|
if not self.switches and not self.args:
|
||||||
|
|
@ -937,8 +935,8 @@ class CmdChannel(COMMAND_DEFAULT_CLASS):
|
||||||
)
|
)
|
||||||
elif len(found_channels) > 1:
|
elif len(found_channels) > 1:
|
||||||
errors.append(
|
errors.append(
|
||||||
"Multiple possible channel matches/alias for "
|
"Multiple possible channel matches/alias for '{channel_name}':\n"
|
||||||
"'{channel_name}':\n" + ", ".join(chan.key for chan in found_channels)
|
+ ", ".join(chan.key for chan in found_channels)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
channels.append(found_channels[0])
|
channels.append(found_channels[0])
|
||||||
|
|
@ -965,7 +963,7 @@ class CmdChannel(COMMAND_DEFAULT_CLASS):
|
||||||
header = f"Channel |w{channel.key}|n"
|
header = f"Channel |w{channel.key}|n"
|
||||||
self.msg(
|
self.msg(
|
||||||
f"{header}\n(use |w{channel.key} <msg>|n (or a channel-alias) "
|
f"{header}\n(use |w{channel.key} <msg>|n (or a channel-alias) "
|
||||||
f"to chat and the 'channel' command "
|
"to chat and the 'channel' command "
|
||||||
f"to customize)\n{table}"
|
f"to customize)\n{table}"
|
||||||
)
|
)
|
||||||
elif channel in available:
|
elif channel in available:
|
||||||
|
|
@ -1015,9 +1013,7 @@ class CmdChannel(COMMAND_DEFAULT_CLASS):
|
||||||
# un-subscribe from a channel
|
# un-subscribe from a channel
|
||||||
success, err = self.unsub_from_channel(channel)
|
success, err = self.unsub_from_channel(channel)
|
||||||
if success:
|
if success:
|
||||||
self.msg(
|
self.msg(f"You un-subscribed from channel {channel.key}. All aliases were cleared.")
|
||||||
f"You un-subscribed from channel {channel.key}. " "All aliases were cleared."
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
self.msg(err)
|
self.msg(err)
|
||||||
return
|
return
|
||||||
|
|
@ -1069,9 +1065,11 @@ class CmdChannel(COMMAND_DEFAULT_CLASS):
|
||||||
|
|
||||||
ask_yes_no(
|
ask_yes_no(
|
||||||
caller,
|
caller,
|
||||||
prompt=f"Are you sure you want to delete channel '{channel.key}' "
|
prompt=(
|
||||||
|
f"Are you sure you want to delete channel '{channel.key}' "
|
||||||
"(make sure name is correct!)?\nThis will disconnect and "
|
"(make sure name is correct!)?\nThis will disconnect and "
|
||||||
"remove all users' aliases. {options}?",
|
"remove all users' aliases. {options}?"
|
||||||
|
),
|
||||||
yes_action=_perform_delete,
|
yes_action=_perform_delete,
|
||||||
no_action="Aborted.",
|
no_action="Aborted.",
|
||||||
default="N",
|
default="N",
|
||||||
|
|
@ -1185,9 +1183,11 @@ class CmdChannel(COMMAND_DEFAULT_CLASS):
|
||||||
)
|
)
|
||||||
ask_yes_no(
|
ask_yes_no(
|
||||||
caller,
|
caller,
|
||||||
prompt=f"Are you sure you want to boot user {target.key} from "
|
prompt=(
|
||||||
|
f"Are you sure you want to boot user {target.key} from "
|
||||||
f"channel(s) {channames} (make sure name/channels are correct{reasonwarn}). "
|
f"channel(s) {channames} (make sure name/channels are correct{reasonwarn}). "
|
||||||
"{options}?",
|
"{options}?"
|
||||||
|
),
|
||||||
yes_action=_boot_user,
|
yes_action=_boot_user,
|
||||||
no_action="Aborted.",
|
no_action="Aborted.",
|
||||||
default="Y",
|
default="Y",
|
||||||
|
|
@ -1337,15 +1337,15 @@ class CmdPage(COMMAND_DEFAULT_CLASS):
|
||||||
caller = self.caller
|
caller = self.caller
|
||||||
|
|
||||||
# get the messages we've sent (not to channels)
|
# get the messages we've sent (not to channels)
|
||||||
pages_we_sent = Msg.objects.get_messages_by_sender(caller)
|
pages_we_sent = Msg.objects.get_messages_by_sender(caller).order_by("-db_date_created")
|
||||||
# get last messages we've got
|
# get last messages we've got
|
||||||
pages_we_got = Msg.objects.get_messages_by_receiver(caller)
|
pages_we_got = Msg.objects.get_messages_by_receiver(caller).order_by("-db_date_created")
|
||||||
targets, message, number = [], None, None
|
targets, message, number = [], None, None
|
||||||
|
|
||||||
if "last" in self.switches:
|
if "last" in self.switches:
|
||||||
if pages_we_sent:
|
if pages_we_sent:
|
||||||
recv = ",".join(obj.key for obj in pages_we_sent[-1].receivers)
|
recv = ",".join(obj.key for obj in pages_we_sent[0].receivers)
|
||||||
self.msg("You last paged |c%s|n:%s" % (recv, pages_we_sent[-1].message))
|
self.msg(f"You last paged |c{recv}|n:{pages_we_sent[0].message}")
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
self.msg("You haven't paged anyone yet.")
|
self.msg("You haven't paged anyone yet.")
|
||||||
|
|
|
||||||
|
|
@ -1584,9 +1584,8 @@ class TestBuilding(BaseEvenniaCommandTest):
|
||||||
self.call(
|
self.call(
|
||||||
building.CmdTeleport(),
|
building.CmdTeleport(),
|
||||||
"Obj = Room2",
|
"Obj = Room2",
|
||||||
"Obj(#{}) is leaving Room(#{}), heading for Room2(#{}).|Teleported Obj -> Room2.".format(
|
"Obj(#{}) is leaving Room(#{}), heading for Room2(#{}).|Teleported Obj -> Room2."
|
||||||
oid, rid, rid2
|
.format(oid, rid, rid2),
|
||||||
),
|
|
||||||
)
|
)
|
||||||
self.call(building.CmdTeleport(), "NotFound = Room", "Could not find 'NotFound'.")
|
self.call(building.CmdTeleport(), "NotFound = Room", "Could not find 'NotFound'.")
|
||||||
self.call(
|
self.call(
|
||||||
|
|
@ -1702,7 +1701,8 @@ class TestBuilding(BaseEvenniaCommandTest):
|
||||||
self.call(
|
self.call(
|
||||||
building.CmdSpawn(),
|
building.CmdSpawn(),
|
||||||
"{'prototype_key':'GOBLIN', 'typeclass':'evennia.objects.objects.DefaultCharacter', "
|
"{'prototype_key':'GOBLIN', 'typeclass':'evennia.objects.objects.DefaultCharacter', "
|
||||||
"'key':'goblin', 'location':'%s'}" % spawnLoc.dbref,
|
"'key':'goblin', 'location':'%s'}"
|
||||||
|
% spawnLoc.dbref,
|
||||||
"Spawned goblin",
|
"Spawned goblin",
|
||||||
)
|
)
|
||||||
goblin = get_object(self, "goblin")
|
goblin = get_object(self, "goblin")
|
||||||
|
|
@ -1750,7 +1750,8 @@ class TestBuilding(BaseEvenniaCommandTest):
|
||||||
self.call(
|
self.call(
|
||||||
building.CmdSpawn(),
|
building.CmdSpawn(),
|
||||||
"/noloc {'prototype_parent':'TESTBALL', 'key': 'Ball', 'prototype_key': 'foo',"
|
"/noloc {'prototype_parent':'TESTBALL', 'key': 'Ball', 'prototype_key': 'foo',"
|
||||||
" 'location':'%s'}" % spawnLoc.dbref,
|
" 'location':'%s'}"
|
||||||
|
% spawnLoc.dbref,
|
||||||
"Spawned Ball",
|
"Spawned Ball",
|
||||||
)
|
)
|
||||||
ball = get_object(self, "Ball")
|
ball = get_object(self, "Ball")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue