From 73c6be1969ff684c648a75715dfb1ff1dfbac40f Mon Sep 17 00:00:00 2001 From: Kacper Ziubryniewicz Date: Wed, 17 Apr 2019 22:35:04 +0200 Subject: [PATCH] Add message parameter to sending location (#416) --- fbchat/_client.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/fbchat/_client.py b/fbchat/_client.py index fa08e3e..3c416ab 100644 --- a/fbchat/_client.py +++ b/fbchat/_client.py @@ -1472,23 +1472,29 @@ class Client(object): r = self._post(self.req_url.UNSEND, data) r.raise_for_status() - def _sendLocation(self, location, current=True, thread_id=None, thread_type=None): + def _sendLocation( + self, location, current=True, message=None, thread_id=None, thread_type=None + ): thread_id, thread_type = self._getThread(thread_id, thread_type) - data = self._getSendData(thread_id=thread_id, thread_type=thread_type) + data = self._getSendData( + message=message, thread_id=thread_id, thread_type=thread_type + ) data["action_type"] = "ma-type:user-generated-message" data["location_attachment[coordinates][latitude]"] = location.latitude data["location_attachment[coordinates][longitude]"] = location.longitude data["location_attachment[is_current_location]"] = current return self._doSendRequest(data) - def sendLocation(self, location, thread_id=None, thread_type=None): + def sendLocation(self, location, message=None, thread_id=None, thread_type=None): """ Sends a given location to a thread as the user's current location :param location: Location to send + :param message: Additional message :param thread_id: User/Group ID to send to. See :ref:`intro_threads` :param thread_type: See :ref:`intro_threads` :type location: models.LocationAttachment + :type message: models.Message :type thread_type: models.ThreadType :return: :ref:`Message ID ` of the sent message :raises: FBchatException if request failed @@ -1496,18 +1502,23 @@ class Client(object): self._sendLocation( location=location, current=True, + message=message, thread_id=thread_id, thread_type=thread_type, ) - def sendPinnedLocation(self, location, thread_id=None, thread_type=None): + def sendPinnedLocation( + self, location, message=None, thread_id=None, thread_type=None + ): """ Sends a given location to a thread as a pinned location :param location: Location to send + :param message: Additional message :param thread_id: User/Group ID to send to. See :ref:`intro_threads` :param thread_type: See :ref:`intro_threads` :type location: models.LocationAttachment + :type message: models.Message :type thread_type: models.ThreadType :return: :ref:`Message ID ` of the sent message :raises: FBchatException if request failed @@ -1515,6 +1526,7 @@ class Client(object): self._sendLocation( location=location, current=False, + message=message, thread_id=thread_id, thread_type=thread_type, )