Added the possibility to overload the dynamically created ChannelCommand. Implements #887.
This commit is contained in:
parent
984c6f9758
commit
2f655abf1a
2 changed files with 15 additions and 2 deletions
|
|
@ -25,12 +25,15 @@ does this for you.
|
||||||
"""
|
"""
|
||||||
from builtins import object
|
from builtins import object
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
from evennia.comms.models import ChannelDB
|
from evennia.comms.models import ChannelDB
|
||||||
from evennia.commands import cmdset, command
|
from evennia.commands import cmdset, command
|
||||||
from evennia.utils.logger import tail_log_file
|
from evennia.utils.logger import tail_log_file
|
||||||
|
from evennia.utils.utils import class_from_module
|
||||||
from django.utils.translation import ugettext as _
|
from django.utils.translation import ugettext as _
|
||||||
|
|
||||||
|
_CHANNEL_COMMAND_CLASS = None
|
||||||
|
|
||||||
class ChannelCommand(command.Command):
|
class ChannelCommand(command.Command):
|
||||||
"""
|
"""
|
||||||
{channelkey} channel
|
{channelkey} channel
|
||||||
|
|
@ -194,8 +197,13 @@ class ChannelHandler(object):
|
||||||
the Channel itself.
|
the Channel itself.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
global _CHANNEL_COMMAND_CLASS
|
||||||
|
if not _CHANNEL_COMMAND_CLASS:
|
||||||
|
_CHANNEL_COMMAND_CLASS = class_from_module(settings.CHANNEL_COMMAND_CLASS)
|
||||||
|
|
||||||
# map the channel to a searchable command
|
# map the channel to a searchable command
|
||||||
cmd = ChannelCommand(key=channel.key.strip().lower(),
|
cmd = _CHANNEL_COMMAND_CLASS(
|
||||||
|
key=channel.key.strip().lower(),
|
||||||
aliases=channel.aliases.all(),
|
aliases=channel.aliases.all(),
|
||||||
locks="cmd:all();%s" % channel.locks,
|
locks="cmd:all();%s" % channel.locks,
|
||||||
help_category="Channel names",
|
help_category="Channel names",
|
||||||
|
|
|
||||||
|
|
@ -324,6 +324,11 @@ CMDSET_PATHS = ["commands", "evennia", "contribs"]
|
||||||
# Parent class for all default commands. Changing this class will
|
# Parent class for all default commands. Changing this class will
|
||||||
# modify all default commands, so do so carefully.
|
# modify all default commands, so do so carefully.
|
||||||
COMMAND_DEFAULT_CLASS = "evennia.commands.default.muxcommand.MuxCommand"
|
COMMAND_DEFAULT_CLASS = "evennia.commands.default.muxcommand.MuxCommand"
|
||||||
|
# The Channel Handler will create a command to represent each channel,
|
||||||
|
# creating it with the key of the channel, its aliases, locks etc. The
|
||||||
|
# default class logs channel messages to a file and allows for /history.
|
||||||
|
# This setting allows to override the command class used with your own.
|
||||||
|
CHANNEL_COMMAND_CLASS = "evennia.comms.channelhandler.ChannelCommand"
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
# Typeclasses and other paths
|
# Typeclasses and other paths
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue