mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 21:06:30 +01:00
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
|
||||
|
||||
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:
|
||||
**kwargs (dict): Arbitrary, optional arguments for users
|
||||
overriding the call (unused by default).
|
||||
text (str, optional): The message received.
|
||||
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
|
||||
|
||||
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:
|
||||
**kwargs (dict): Arbitrary, optional arguments for users
|
||||
overriding the call (unused by default).
|
||||
text (str, optional): Text to send.
|
||||
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
|
||||
|
|
|
|||
|
|
@ -1374,7 +1374,7 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
|
|||
"""
|
||||
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
|
||||
object using the `msg` method.
|
||||
|
|
@ -1389,6 +1389,7 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
|
|||
|
||||
Args:
|
||||
text (str, optional): The message received.
|
||||
from_obj (any, optional): The object sending the message.
|
||||
|
||||
Kwargs:
|
||||
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)`.
|
||||
|
||||
Args:
|
||||
text (str): Text to send.
|
||||
to_obj (Object): The object to send to.
|
||||
text (str, optional): Text to send.
|
||||
to_obj (any, optional): The object to send to.
|
||||
|
||||
Kwargs:
|
||||
Keywords passed from msg()
|
||||
|
||||
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
|
||||
get called.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue