buffer: Enable support for media messages.

This commit is contained in:
Damir Jelić 2018-08-08 15:04:19 +02:00
parent f1e87fe9b0
commit 458f6580fb

View file

@ -33,6 +33,7 @@ from .utils import (
from .plugin_options import RedactType from .plugin_options import RedactType
from nio import ( from nio import (
Api,
RoomMessageText, RoomMessageText,
RoomMemberEvent, RoomMemberEvent,
PowerLevelsEvent, PowerLevelsEvent,
@ -42,6 +43,7 @@ from nio import (
RoomTopicEvent, RoomTopicEvent,
RoomMessageEmote, RoomMessageEmote,
RoomNameEvent, RoomNameEvent,
RoomMessageMedia,
RoomMessageUnknown, RoomMessageUnknown,
RedactionEvent RedactionEvent
) )
@ -925,22 +927,22 @@ class RoomBuffer(object):
# self.get_event_tags(event) # self.get_event_tags(event)
# ) # )
# elif isinstance(event, RoomMessageMedia): elif isinstance(event, RoomMessageMedia):
# nick = self.find_nick(event.sender) nick = self.find_nick(event.sender)
# date = server_ts_to_weechat(event.server_timestamp) date = server_ts_to_weechat(event.server_timestamp)
# http_url = mxc_to_http(event.url) http_url = Api.mxc_to_http(event.url)
# url = http_url if http_url else event.url url = http_url if http_url else event.url
# description = ("/{}".format(event.description) description = ("/{}".format(event.body)
# if event.description else "") if event.body else "")
# data = "{url}{desc}".format(url=url, desc=description) data = "{url}{desc}".format(url=url, desc=description)
# self.weechat_buffer.message( self.weechat_buffer.message(
# nick, nick,
# data, data,
# date, date,
# self.get_event_tags(event) self.get_event_tags(event)
# ) )
elif isinstance(event, RoomMessageUnknown): elif isinstance(event, RoomMessageUnknown):
nick = self.find_nick(event.sender) nick = self.find_nick(event.sender)