Add method to subscription handler to check online members, and put check in Channel typeclass for using this based on settings option.

This commit is contained in:
Tehom 2017-05-20 23:18:26 -04:00
parent 112e457cc3
commit f9c369f869
3 changed files with 27 additions and 2 deletions

View file

@ -2,6 +2,7 @@
Base typeclass for in-game Channels.
"""
from django.conf import settings
from evennia.typeclasses.models import TypeclassBase
from evennia.comms.models import TempMsg, ChannelDB
@ -246,7 +247,11 @@ class DefaultChannel(with_metaclass(TypeclassBase, ChannelDB)):
"""
# get all players or objects connected to this channel and send to them
for entity in self.subscriptions.all():
if online:
subs = self.subscriptions.online()
else:
subs = self.subscriptions.all()
for entity in subs:
# if the entity is muted, we don't send them a message
if entity in self.mutelist:
continue
@ -262,7 +267,7 @@ class DefaultChannel(with_metaclass(TypeclassBase, ChannelDB)):
logger.log_file(msgobj.message, self.attributes.get("log_file") or "channel_%s.log" % self.key)
def msg(self, msgobj, header=None, senders=None, sender_strings=None,
keep_log=None, online=False, emit=False, external=False):
keep_log=None, online=settings.CHANNELS_MSG_OFFLINE, emit=False, external=False):
"""
Send the given message to all players connected to channel. Note that
no permission-checking is done here; it is assumed to have been