mirror of
https://github.com/evennia/evennia.git
synced 2026-03-26 17:56:32 +01:00
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.
|
||||
|
||||
"""
|
||||
|
||||
from evennia.typeclasses.models import TypeclassBase
|
||||
from evennia.comms.models import TempMsg, ChannelDB
|
||||
from evennia.comms.managers import ChannelManager
|
||||
|
|
@ -239,14 +238,17 @@ class DefaultChannel(with_metaclass(TypeclassBase, ChannelDB)):
|
|||
Args:
|
||||
msgobj (Msg or TempMsg): Message to distribute.
|
||||
online (bool): Only send to receivers who are actually online
|
||||
(not currently used):
|
||||
|
||||
Notes:
|
||||
This is also where logging happens, if enabled.
|
||||
|
||||
"""
|
||||
# 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
|
||||
|
|
|
|||
|
|
@ -538,6 +538,24 @@ class SubscriptionHandler(object):
|
|||
self._recache()
|
||||
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):
|
||||
"""
|
||||
Remove all subscribers from channel.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue