Few fixes in quick replies
This commit is contained in:
@@ -1052,8 +1052,8 @@ class Client(object):
|
|||||||
q["content_type"] = quick_reply.type.value.lower()
|
q["content_type"] = quick_reply.type.value.lower()
|
||||||
q["payload"] = quick_reply.payload
|
q["payload"] = quick_reply.payload
|
||||||
q["data"] = quick_reply.data
|
q["data"] = quick_reply.data
|
||||||
if isinstance(quick_reply, QuickReplyText): q["title"] = quick_reply.title
|
if quick_reply.type == QuickReplyType.TEXT: q["title"] = quick_reply.title
|
||||||
if not isinstance(quick_reply, QuickReplyLocation): q["image_url"] = quick_reply.image_url
|
if quick_reply.type is not QuickReplyType.LOCATION: q["image_url"] = quick_reply.image_url
|
||||||
xmd["quick_replies"].append(q)
|
xmd["quick_replies"].append(q)
|
||||||
if len(message.quick_replies) == 1 and message.quick_replies[0].is_response:
|
if len(message.quick_replies) == 1 and message.quick_replies[0].is_response:
|
||||||
xmd["quick_replies"] = xmd["quick_replies"][0]
|
xmd["quick_replies"] = xmd["quick_replies"][0]
|
||||||
@@ -1141,6 +1141,7 @@ class Client(object):
|
|||||||
:raises: FBchatException if request failed
|
:raises: FBchatException if request failed
|
||||||
"""
|
"""
|
||||||
quick_reply.is_response = True
|
quick_reply.is_response = True
|
||||||
|
if quick_reply.type == QuickReplyType.TEXT:
|
||||||
return self.send(Message(text=quick_reply.title, quick_replies=[quick_reply]))
|
return self.send(Message(text=quick_reply.title, quick_replies=[quick_reply]))
|
||||||
|
|
||||||
def _upload(self, files):
|
def _upload(self, files):
|
||||||
|
@@ -195,13 +195,13 @@ def graphql_to_plan(a):
|
|||||||
|
|
||||||
def graphql_to_quick_reply(q, is_response=False):
|
def graphql_to_quick_reply(q, is_response=False):
|
||||||
data = dict()
|
data = dict()
|
||||||
if q.get('title') is not None: data["title"] = q["title"]
|
|
||||||
if q.get('image_url') is not None: data["image_url"] = q["image_url"]
|
|
||||||
if q.get('payload') is not None: data["payload"] = q["payload"]
|
|
||||||
if q.get('data') is not None: data["data"] = q["data"]
|
|
||||||
data["is_response"] = is_response
|
|
||||||
_type = QuickReplyType(q.get('content_type').upper())
|
_type = QuickReplyType(q.get('content_type').upper())
|
||||||
|
if q.get('payload'): data["payload"] = q["payload"]
|
||||||
|
if q.get('data'): data["data"] = q["data"]
|
||||||
|
if q.get('image_url') and _type is not QuickReplyType.LOCATION: data["image_url"] = q["image_url"]
|
||||||
|
data["is_response"] = is_response
|
||||||
if _type == QuickReplyType.TEXT:
|
if _type == QuickReplyType.TEXT:
|
||||||
|
if q.get('title') is not None: data["title"] = q["title"]
|
||||||
rtn = QuickReplyText(**data)
|
rtn = QuickReplyText(**data)
|
||||||
elif _type == QuickReplyType.LOCATION:
|
elif _type == QuickReplyType.LOCATION:
|
||||||
rtn = QuickReplyLocation(**data)
|
rtn = QuickReplyLocation(**data)
|
||||||
|
@@ -465,7 +465,7 @@ class QuickReply(object):
|
|||||||
return self.__unicode__()
|
return self.__unicode__()
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return '<QuickReply: type={!r} payload={!r}>'.format(self.type, self.payload)
|
return '<{}: payload={!r}>'.format(self.__class__.__name__, self.payload)
|
||||||
|
|
||||||
class QuickReplyText(QuickReply):
|
class QuickReplyText(QuickReply):
|
||||||
#: Title of the quick reply
|
#: Title of the quick reply
|
||||||
|
Reference in New Issue
Block a user