Skip to content

Commit

Permalink
add create_acl_with_sender syntax sugar
Browse files Browse the repository at this point in the history
this function can be passed as a dict to the send_message, sparing a second receiver_addr argument
  • Loading branch information
maurerle committed Oct 28, 2024
1 parent 39abc5a commit f3e9af0
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions mango/messages/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,3 +289,35 @@ def create_acl(
for key, value in acl_metadata.items():
setattr(message, key, value)
return message

def create_acl_with_sender(
content,
receiver_addr: AgentAddress,
sender_addr: AgentAddress,
acl_metadata: None | dict[str, Any] = None,
is_anonymous_acl=False,
):
"""
create_acl function, which does not require to pass the receiver_addr twice
self.context.send_message(
**create_acl_with_sender(
"message content",
receiver_addr,
self.context.addr,
acl_metadata={
"in_reply_to": "reply_to",
},
)
)
"""
return {
"content": create_acl(
content,
receiver_addr,
sender_addr,
acl_metadata,
is_anonymous_acl,
),
"receiver_addr": receiver_addr,
}

0 comments on commit f3e9af0

Please sign in to comment.