Make the at_channel_create method automatically add a new channel to the channelhandler.

This commit is contained in:
Griatch 2017-02-04 16:42:08 +01:00
parent ff1ee76421
commit 628dd268f9
2 changed files with 21 additions and 3 deletions

View file

@ -9,6 +9,7 @@ from evennia.comms.managers import ChannelManager
from evennia.utils import logger
from evennia.utils.utils import make_iter
from future.utils import with_metaclass
_CHANNEL_HANDLER = None
class DefaultChannel(with_metaclass(TypeclassBase, ChannelDB)):
@ -51,7 +52,12 @@ class DefaultChannel(with_metaclass(TypeclassBase, ChannelDB)):
Called once, when the channel is first created.
"""
pass
# delayed import of the channelhandler
global _CHANNEL_HANDLER
if not _CHANNEL_HANDLER:
from comms.channelhandler import CHANNEL_HANDLER as _CHANNEL_HANDLER
# register ourselves with the channelhandler.
_CHANNEL_HANDLER.add(self)
# helper methods, for easy overloading