Cleanup of at_msg_receive/send hooks
This commit is contained in:
parent
ccd48ebce3
commit
fb773a9e75
2 changed files with 41 additions and 12 deletions
|
|
@ -810,24 +810,52 @@ class DefaultAccount(with_metaclass(TypeclassBase, AccountDB)):
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def at_msg_receive(self, message, from_obj=None, **kwargs):
|
def at_msg_receive(self, text=None, from_obj=None, **kwargs):
|
||||||
"""
|
"""
|
||||||
This is currently unused.
|
This hook is called whenever someone sends a message to this
|
||||||
|
object using the `msg` method.
|
||||||
|
|
||||||
|
Note that from_obj may be None if the sender did not include
|
||||||
|
itself as an argument to the obj.msg() call - so you have to
|
||||||
|
check for this. .
|
||||||
|
|
||||||
|
Consider this a pre-processing method before msg is passed on
|
||||||
|
to the user session. If this method returns False, the msg
|
||||||
|
will not be passed on.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
**kwargs (dict): Arbitrary, optional arguments for users
|
text (str, optional): The message received.
|
||||||
overriding the call (unused by default).
|
from_obj (any, optional): The object sending the message.
|
||||||
|
|
||||||
|
Kwargs:
|
||||||
|
This includes any keywords sent to the `msg` method.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
receive (bool): If this message should be received.
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
If this method returns False, the `msg` operation
|
||||||
|
will abort without sending the message.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def at_msg_send(self, message, to_object, **kwargs):
|
def at_msg_send(self, text=None, to_obj=None, **kwargs):
|
||||||
"""
|
"""
|
||||||
This is currently unused.
|
This is a hook that is called when *this* object sends a
|
||||||
|
message to another object with `obj.msg(text, to_obj=obj)`.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
**kwargs (dict): Arbitrary, optional arguments for users
|
text (str, optional): Text to send.
|
||||||
overriding the call (unused by default).
|
to_obj (any, optional): The object to send to.
|
||||||
|
|
||||||
|
Kwargs:
|
||||||
|
Keywords passed from msg()
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
Since this method is executed by `from_obj`, if no `from_obj`
|
||||||
|
was passed to `DefaultCharacter.msg` this hook will never
|
||||||
|
get called.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
|
|
@ -1374,7 +1374,7 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def at_msg_receive(self, text=None, **kwargs):
|
def at_msg_receive(self, text=None, from_obj=None, **kwargs):
|
||||||
"""
|
"""
|
||||||
This hook is called whenever someone sends a message to this
|
This hook is called whenever someone sends a message to this
|
||||||
object using the `msg` method.
|
object using the `msg` method.
|
||||||
|
|
@ -1389,6 +1389,7 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
text (str, optional): The message received.
|
text (str, optional): The message received.
|
||||||
|
from_obj (any, optional): The object sending the message.
|
||||||
|
|
||||||
Kwargs:
|
Kwargs:
|
||||||
This includes any keywords sent to the `msg` method.
|
This includes any keywords sent to the `msg` method.
|
||||||
|
|
@ -1409,14 +1410,14 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
|
||||||
message to another object with `obj.msg(text, to_obj=obj)`.
|
message to another object with `obj.msg(text, to_obj=obj)`.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
text (str): Text to send.
|
text (str, optional): Text to send.
|
||||||
to_obj (Object): The object to send to.
|
to_obj (any, optional): The object to send to.
|
||||||
|
|
||||||
Kwargs:
|
Kwargs:
|
||||||
Keywords passed from msg()
|
Keywords passed from msg()
|
||||||
|
|
||||||
Notes:
|
Notes:
|
||||||
Since this method is executed `from_obj`, if no `from_obj`
|
Since this method is executed by `from_obj`, if no `from_obj`
|
||||||
was passed to `DefaultCharacter.msg` this hook will never
|
was passed to `DefaultCharacter.msg` this hook will never
|
||||||
get called.
|
get called.
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue