Skip to content

Commit

Permalink
Merge pull request #4546 from RasaHQ/no-kwargs
Browse files Browse the repository at this point in the history
remove kwargs from default channel implementation send methods
  • Loading branch information
erohmensing committed Oct 2, 2019
2 parents 13de474 + cc439a1 commit 135226b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Fixed
-----
- Fixed error ``Object of type 'MaxHistoryTrackerFeaturizer' is not JSON serializable``
when running ``rasa train core``
- Default channel ``send_`` methods no longer support kwargs as they caused issues in incompatible channelss

[1.3.7] - 2019-09-27
^^^^^^^^^^^^^^^^^^^^
Expand Down
19 changes: 7 additions & 12 deletions rasa/core/channels/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,16 +197,14 @@ async def send_image_url(
) -> None:
"""Sends an image. Default will just post the url as a string."""

await self.send_text_message(recipient_id, "Image: {}".format(image), **kwargs)
await self.send_text_message(recipient_id, "Image: {}".format(image))

async def send_attachment(
self, recipient_id: Text, attachment: Text, **kwargs: Any
) -> None:
"""Sends an attachment. Default will just post as a string."""

await self.send_text_message(
recipient_id, "Attachment: {}".format(attachment), **kwargs
)
await self.send_text_message(recipient_id, "Attachment: {}".format(attachment))

async def send_text_with_buttons(
self,
Expand All @@ -219,10 +217,10 @@ async def send_text_with_buttons(
Default implementation will just post the buttons as a string."""

await self.send_text_message(recipient_id, text, **kwargs)
await self.send_text_message(recipient_id, text)
for idx, button in enumerate(buttons):
button_msg = cli_utils.button_to_string(button, idx)
await self.send_text_message(recipient_id, button_msg, **kwargs)
await self.send_text_message(recipient_id, button_msg)

async def send_quick_replies(
self,
Expand All @@ -235,7 +233,7 @@ async def send_quick_replies(
Default implementation will just send as buttons."""

await self.send_text_with_buttons(recipient_id, text, quick_replies, **kwargs)
await self.send_text_with_buttons(recipient_id, text, quick_replies)

async def send_elements(
self, recipient_id: Text, elements: Iterable[Dict[Text, Any]], **kwargs: Any
Expand All @@ -244,15 +242,12 @@ async def send_elements(
Default implementation will just post the elements as a string."""

# we can't pass the empty "buttons" key of the message through to send_text_with_buttons()
kwargs.pop("buttons", None)

for element in elements:
element_msg = "{title} : {subtitle}".format(
title=element.get("title", ""), subtitle=element.get("subtitle", "")
)
await self.send_text_with_buttons(
recipient_id, element_msg, element.get("buttons", []), **kwargs
recipient_id, element_msg, element.get("buttons", [])
)

async def send_custom_json(
Expand All @@ -262,7 +257,7 @@ async def send_custom_json(
Default implementation will just post the json contents as a string."""

await self.send_text_message(recipient_id, json.dumps(json_message), **kwargs)
await self.send_text_message(recipient_id, json.dumps(json_message))


class CollectingOutputChannel(OutputChannel):
Expand Down

0 comments on commit 135226b

Please sign in to comment.