Changed the OOB message structure to include sending text data as well; still not working fully.
This commit is contained in:
parent
529f13c689
commit
4817ec90b3
8 changed files with 249 additions and 240 deletions
|
|
@ -461,25 +461,34 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
|
|||
return cmdhandler.cmdhandler(self, raw_string, callertype="object", session=session, **kwargs)
|
||||
|
||||
|
||||
def msg(self, text=None, from_obj=None, session=None, **kwargs):
|
||||
def msg(self, text=None, from_obj=None, session=None, options=None, **kwargs):
|
||||
"""
|
||||
Emits something to a session attached to the object.
|
||||
|
||||
Args:
|
||||
text (str, optional): The message to send
|
||||
text (str or tuple, optional): The message to send. This
|
||||
is treated internally like any send-command, so its
|
||||
value can be a tuple if sending multiple arguments to
|
||||
the `text` oob command.
|
||||
from_obj (obj, optional): object that is sending. If
|
||||
given, at_msg_send will be called
|
||||
given, at_msg_send will be called. This value will be
|
||||
passed on to the protocol.
|
||||
session (Session or list, optional): Session or list of
|
||||
Sessions to relay data to, if any. If set, will
|
||||
force send to these sessions. If unset, who receives the
|
||||
message depends on the MULTISESSION_MODE.
|
||||
Sessions to relay data to, if any. If set, will force send
|
||||
to these sessions. If unset, who receives the message
|
||||
depends on the MULTISESSION_MODE.
|
||||
options (dict, optional): Message-specific option-value
|
||||
pairs. These will be applied at the protocol level.
|
||||
Kwargs:
|
||||
any (string or tuples): All kwarg keys not listed above
|
||||
will be treated as send-command names and their arguments
|
||||
(which can be a string or a tuple).
|
||||
|
||||
Notes:
|
||||
`at_msg_receive` will be called on this Object.
|
||||
All extra kwargs will be passed on to the protocol.
|
||||
|
||||
"""
|
||||
text = to_str(text, force_string=True) if text != None else ""
|
||||
# try send hooks
|
||||
if from_obj:
|
||||
try:
|
||||
|
|
@ -493,10 +502,12 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
|
|||
except Exception:
|
||||
logger.log_trace()
|
||||
|
||||
kwargs["options"] = options
|
||||
|
||||
# relay to session(s)
|
||||
sessions = make_iter(session) if session else self.sessions.all()
|
||||
for session in sessions:
|
||||
session.msg(text=text, **kwargs)
|
||||
session.data_out(text=text, **kwargs)
|
||||
|
||||
def for_contents(self, func, exclude=None, **kwargs):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue