From 29cca2acd405d06694fc182c5daf963bf38557e6 Mon Sep 17 00:00:00 2001 From: Philip Douglass Date: Wed, 24 Aug 2016 16:59:51 -0400 Subject: [PATCH 1/4] Return result of /message endpoint call - message id is required for /reply --- hypchat/restobject.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hypchat/restobject.py b/hypchat/restobject.py index c94d21b..c61c8df 100644 --- a/hypchat/restobject.py +++ b/hypchat/restobject.py @@ -145,7 +145,8 @@ def message(self, message): Allows a user to send a message to a room. """ data = {'message': message} - self._requests.post(self.url + '/message', data=data) + resp = self._requests.post(self.url + '/message', data=data) + return Linker._obj_from_text(resp.text, self._requests) def notification(self, message, color=None, notify=False, format=None): """ From 784ded652a35b63d3c19308c68b9dfc6a5e5fb5a Mon Sep 17 00:00:00 2001 From: Philip Douglass Date: Wed, 24 Aug 2016 17:01:21 -0400 Subject: [PATCH 2/4] Enable sending Card notifications --- hypchat/restobject.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hypchat/restobject.py b/hypchat/restobject.py index c61c8df..d2dc6c3 100644 --- a/hypchat/restobject.py +++ b/hypchat/restobject.py @@ -148,7 +148,7 @@ def message(self, message): resp = self._requests.post(self.url + '/message', data=data) return Linker._obj_from_text(resp.text, self._requests) - def notification(self, message, color=None, notify=False, format=None): + def notification(self, message, card=None, color=None, notify=False, format=None): """ Send a message to a room. """ @@ -157,7 +157,7 @@ def notification(self, message, color=None, notify=False, format=None): format = 'text' else: format = 'html' - data = {'message': message, 'notify': notify, 'message_format': format} + data = {'message': message, 'card': card, 'notify': notify, 'message_format': format} if color: data['color'] = color self._requests.post(self.url + '/notification', data=data) From 7b9cc57766fb4331902cfaa3b7957dbe884b8274 Mon Sep 17 00:00:00 2001 From: Philip Douglass Date: Wed, 24 Aug 2016 17:39:20 -0400 Subject: [PATCH 3/4] Add support for attach_to notification property --- hypchat/restobject.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hypchat/restobject.py b/hypchat/restobject.py index d2dc6c3..f7689eb 100644 --- a/hypchat/restobject.py +++ b/hypchat/restobject.py @@ -148,7 +148,7 @@ def message(self, message): resp = self._requests.post(self.url + '/message', data=data) return Linker._obj_from_text(resp.text, self._requests) - def notification(self, message, card=None, color=None, notify=False, format=None): + def notification(self, message, card=None, color=None, notify=False, format=None, attach_to=None): """ Send a message to a room. """ @@ -157,7 +157,7 @@ def notification(self, message, card=None, color=None, notify=False, format=None format = 'text' else: format = 'html' - data = {'message': message, 'card': card, 'notify': notify, 'message_format': format} + data = {'message': message, 'card': card, 'notify': notify, 'message_format': format, 'attach_to': attach_to} if color: data['color'] = color self._requests.post(self.url + '/notification', data=data) From bac0939ee15443d6d42b6d8557a45451db9af073 Mon Sep 17 00:00:00 2001 From: Philip DOUGLASS Date: Tue, 5 Sep 2017 10:22:38 -0400 Subject: [PATCH 4/4] Only add card,attach_to values if they are set --- hypchat/restobject.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hypchat/restobject.py b/hypchat/restobject.py index f7689eb..73161ad 100644 --- a/hypchat/restobject.py +++ b/hypchat/restobject.py @@ -148,7 +148,7 @@ def message(self, message): resp = self._requests.post(self.url + '/message', data=data) return Linker._obj_from_text(resp.text, self._requests) - def notification(self, message, card=None, color=None, notify=False, format=None, attach_to=None): + def notification(self, message, color=None, notify=False, format=None, card=None, attach_to=None): """ Send a message to a room. """ @@ -157,9 +157,13 @@ def notification(self, message, card=None, color=None, notify=False, format=None format = 'text' else: format = 'html' - data = {'message': message, 'card': card, 'notify': notify, 'message_format': format, 'attach_to': attach_to} + data = {'message': message, 'notify': notify, 'message_format': format} if color: data['color'] = color + if card: + data['card'] = card + if attach_to: + data['attach_to'] = attach_to self._requests.post(self.url + '/notification', data=data) def topic(self, text):