From edf168704edbff10cccfbb6b206bb6b33f54a5b8 Mon Sep 17 00:00:00 2001 From: Alexandr Date: Wed, 12 Apr 2017 19:11:31 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=BE=D0=B1=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=BA=D1=83=20=D0=B4?= =?UTF-8?q?=D0=BB=D1=8F=20=D1=84=D0=B0=D0=B9=D0=BB=D0=BE=D0=B2=20=D0=B8=20?= =?UTF-8?q?=D0=BF=D0=B5=D1=80=D1=81=D0=BB.=20=D1=81=D0=BE=D0=BE=D0=B1?= =?UTF-8?q?=D1=89=D0=B5=D0=BD=D0=B8=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Показывает сообщение для пересылаемых сообщений и прикрепленных файлов --- vk_cli/messages.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/vk_cli/messages.py b/vk_cli/messages.py index 304a2de..e642d4b 100644 --- a/vk_cli/messages.py +++ b/vk_cli/messages.py @@ -21,17 +21,26 @@ def get_data(self, chat_id=0, user_id=0, page=0): def render(self, messages): last_msg_author = None msg_readed = list() - column_width = get_terminal_size().columns + column_width = get_terminal_size().columns - 10 + out = self.common.console.write for msg in messages[::-1]: # печаем имя пользователя, если мы в беседе и это входящее сообщение # дважды подряд имя пользователя не печатаем if not msg.out and 'chat_id' in msg and last_msg_author != msg.from_id: last_msg_author = msg.from_id - self.common.console.write(self.common.users[msg.from_id].header()) + out(self.common.users[msg.from_id].header()) align = '>' if msg.out else '<' for line in msg.body.split('\n'): - self.common.console.write(" "*5, "{0:{1}{2}}".format(line, align, column_width - 10)) + out(" "*5, "{0:{1}{2}}".format(line, align, column_width)) + + # если есть прикрепленные файлы + if msg.get('attachments'): + out(" "*5, "{0:{1}{2}}\n".format('', align, column_width)) + + # или пересылаемые сообщения + if msg.get('fwd_messages'): + out(" "*5, "{0:{1}{2}}\n".format('', align, column_width)) # запоминаем ID's сообщ. которые входящие и не прочитаные if not msg.out and not msg.read_state: