Added voice messages to the list of supported attached files in chats
This commit is contained in:
@@ -173,4 +173,12 @@ def render_video(video, session=None):
|
||||
Reference: https://vk.com/dev/video_object"""
|
||||
if video == False:
|
||||
return [_(u"Video not available"), "", ""]
|
||||
return [video["title"], video["description"], utils.seconds_to_string(video["duration"])]
|
||||
return [video["title"], video["description"], utils.seconds_to_string(video["duration"])]
|
||||
|
||||
def render_audio_message(audio_message, session=None):
|
||||
""" Render a voice message from VK
|
||||
Example result:
|
||||
["Voice message", "01:30:28"]"""
|
||||
if audio_message == False:
|
||||
return [_(u"Voice message not available"), "", ""]
|
||||
return [utils.seconds_to_string(audio_message["duration"])]
|
@@ -79,12 +79,12 @@ def add_attachment(attachment):
|
||||
msg = u"{0}".format(" ".join(renderers.render_audio(attachment["audio"])))
|
||||
tpe = _(u"Audio")
|
||||
elif attachment["type"] == "doc":
|
||||
if attachment["doc"].has_key("preview") and attachment["doc"]["preview"].has_key("audio_msg"):
|
||||
tpe = _(u"Voice message")
|
||||
msg = seconds_to_string(attachment["doc"]["preview"]["audio_msg"]["duration"])
|
||||
print attachment["doc"]["ext"]
|
||||
else:
|
||||
msg = u"{0}".format(attachment["doc"]["title"])
|
||||
tpe = _(u"{0} file").format(attachment["doc"]["ext"])
|
||||
msg = u"{0}".format(attachment["doc"]["title"])
|
||||
tpe = _(u"{0} file").format(attachment["doc"]["ext"])
|
||||
elif attachment["type"] == "audio_message":
|
||||
msg = u"{0}".format(" ".join(renderers.render_audio_message(attachment["audio_message"])))
|
||||
tpe = _(u"Voice message")
|
||||
else:
|
||||
print attachment
|
||||
return [tpe, msg]
|
||||
|
||||
|
Reference in New Issue
Block a user