diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d6ca4e3d4..f4e82cb047 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ without arguments starts a full interactive Python console. of texts (such as tables). New `justify` bool. Old `justify_kwargs` remains but is now only used to pass extra kwargs into the justify function. - Improve performance of `find` and `objects` commands on large data sets (strikaco) +- New `CHANNEL_HANDLER_CLASS` setting allows for replacing the ChannelHandler entirely. ## Evennia 0.9 (2018-2019) diff --git a/evennia/comms/channelhandler.py b/evennia/comms/channelhandler.py index e33a95ed5a..feea9f6e33 100644 --- a/evennia/comms/channelhandler.py +++ b/evennia/comms/channelhandler.py @@ -29,6 +29,10 @@ from evennia.utils.logger import tail_log_file from evennia.utils.utils import class_from_module from django.utils.translation import ugettext as _ +# we must late-import these since any overloads are likely to +# themselves be using these classes leading to a circular import. + +_CHANNEL_HANDLER_CLASS = None _CHANNEL_COMMAND_CLASS = None _CHANNELDB = None @@ -314,5 +318,6 @@ class ChannelHandler(object): return chan_cmdset -CHANNEL_HANDLER = ChannelHandler() +# set up the singleton +CHANNEL_HANDLER = class_from_module(settings.CHANNEL_HANDLER_CLASS)() CHANNELHANDLER = CHANNEL_HANDLER # legacy diff --git a/evennia/settings_default.py b/evennia/settings_default.py index 8216c13395..674aeee4be 100644 --- a/evennia/settings_default.py +++ b/evennia/settings_default.py @@ -446,10 +446,17 @@ COMMAND_DEFAULT_MSG_ALL_SESSIONS = False COMMAND_DEFAULT_HELP_CATEGORY = "general" # The default lockstring of a command. COMMAND_DEFAULT_LOCKS = "" -# 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. +# The Channel Handler is responsible for managing all available channels. By +# default it builds the current channels into a channel-cmdset that it feeds +# to the cmdhandler. Overloading this can completely change how Channels +# are identified and called. +CHANNEL_HANDLER_CLASS = "evennia.comms.channelhandler.ChannelHandler" +# The (default) 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. +# If you implement CHANNEL_HANDLER_CLASS, you can change this directly and will +# likely not need this setting. CHANNEL_COMMAND_CLASS = "evennia.comms.channelhandler.ChannelCommand" ######################################################################