Fix forward/reply grammar

This commit is contained in:
Sijmen Schoon 2016-09-26 00:56:22 +02:00
parent a6007a8902
commit ff1c6bf883

View File

@ -247,10 +247,10 @@ async def aiotg_message(chat, match):
date = datetime.datetime.fromtimestamp(fw_from['date'])
quoted_msg = '\n'.join(['>{}'.format(x) for x in message.split('\n')])
quoted_msg = 'Forwarded from {}, said at {}:\n{}'.format(msg_from, date, quoted_msg)
quoted_msg = 'Forwarded from {}, who {} said:\n{}'.format(msg_from, date, quoted_msg)
quoted_html = '<blockquote>{}</blockquote>'.format(html.escape(message).replace('\n', '<br />'))
quoted_html = '<i>Forwarded from {}, said at {}:</i>\n{}'.format(html.escape(msg_from), html.escape(str(date)), quoted_html)
quoted_html = '<i>Forwarded from {}, who {} said:</i>\n{}'.format(html.escape(msg_from), html.escape(str(date)), quoted_html)
j = await send_matrix_message(room_id, user_id, txn_id, body=quoted_msg, formatted_body=quoted_html, format='org.matrix.custom.html', msgtype='m.text')
elif 'reply_to_message' in chat.message:
re_msg = chat.message['reply_to_message']
@ -258,13 +258,13 @@ async def aiotg_message(chat, match):
msg_from = '{} {} (Telegram)'.format(re_msg['from']['first_name'], re_msg['from']['last_name'])
else:
msg_from = '{} (Telegram)'.format(re_msg['from']['first_name'])
date = datetime.datetime.fromtimestamp(re_msg['date'])
date = datetime.datetime.fromtimestamp(re_msg['date']).strftime('on %Y-%m-%d at %H:%M:%S')
quoted_msg = '\n'.join(['>{}'.format(x) for x in re_msg['text'].split('\n')])
quoted_msg = 'Reply to {}, said at {}:\n{}\n\n{}'.format(msg_from, date, quoted_msg, message)
quoted_msg = 'Reply to {}, who {} said:\n{}\n\n{}'.format(msg_from, date, quoted_msg, message)
quoted_html = '<blockquote>{}</blockquote>'.format(html.escape(re_msg['text']).replace('\n', '<br />'))
quoted_html = '<i>Reply to {}, said at {}:</i><br />{}<p>{}</p>'.format(html.escape(msg_from), html.escape(str(date)), quoted_html, html.escape(message).replace('\n', '<br />'))
quoted_html = '<i>Reply to {}, who {} said:</i><br />{}<p>{}</p>'.format(html.escape(msg_from), html.escape(str(date)), quoted_html, html.escape(message).replace('\n', '<br />'))
j = await send_matrix_message(room_id, user_id, txn_id, body=quoted_msg, formatted_body=quoted_html, format='org.matrix.custom.html', msgtype='m.text')
else: