Merge branch 'channels_msg_offline' of https://github.com/TehomCD/evennia into TehomCD-channels_msg_offline
This commit is contained in:
commit
2f4cbf1d09
2 changed files with 23 additions and 3 deletions
|
|
@ -2,7 +2,6 @@
|
||||||
Base typeclass for in-game Channels.
|
Base typeclass for in-game Channels.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from evennia.typeclasses.models import TypeclassBase
|
from evennia.typeclasses.models import TypeclassBase
|
||||||
from evennia.comms.models import TempMsg, ChannelDB
|
from evennia.comms.models import TempMsg, ChannelDB
|
||||||
from evennia.comms.managers import ChannelManager
|
from evennia.comms.managers import ChannelManager
|
||||||
|
|
@ -239,14 +238,17 @@ class DefaultChannel(with_metaclass(TypeclassBase, ChannelDB)):
|
||||||
Args:
|
Args:
|
||||||
msgobj (Msg or TempMsg): Message to distribute.
|
msgobj (Msg or TempMsg): Message to distribute.
|
||||||
online (bool): Only send to receivers who are actually online
|
online (bool): Only send to receivers who are actually online
|
||||||
(not currently used):
|
|
||||||
|
|
||||||
Notes:
|
Notes:
|
||||||
This is also where logging happens, if enabled.
|
This is also where logging happens, if enabled.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
# get all players or objects connected to this channel and send to them
|
# 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 the entity is muted, we don't send them a message
|
||||||
if entity in self.mutelist:
|
if entity in self.mutelist:
|
||||||
continue
|
continue
|
||||||
|
|
|
||||||
|
|
@ -538,6 +538,24 @@ class SubscriptionHandler(object):
|
||||||
self._recache()
|
self._recache()
|
||||||
return self._cache
|
return self._cache
|
||||||
|
|
||||||
|
def online(self):
|
||||||
|
"""
|
||||||
|
Get all online players from our cache
|
||||||
|
Returns:
|
||||||
|
subscribers (list): Subscribers who are online or
|
||||||
|
are puppeted by an online player.
|
||||||
|
"""
|
||||||
|
subs = []
|
||||||
|
for obj in self.all():
|
||||||
|
if hasattr(obj, 'player'):
|
||||||
|
if not obj.player:
|
||||||
|
continue
|
||||||
|
obj = obj.player
|
||||||
|
if not obj.is_connected:
|
||||||
|
continue
|
||||||
|
subs.append(obj)
|
||||||
|
return subs
|
||||||
|
|
||||||
def clear(self):
|
def clear(self):
|
||||||
"""
|
"""
|
||||||
Remove all subscribers from channel.
|
Remove all subscribers from channel.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue