From 2c30c58d4869522072467c73ba45802c4f6a284a Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Thu, 28 Feb 2019 20:51:34 +0100 Subject: [PATCH] Use forward author if /diario is in response to a forwarded message --- telegrambot.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/telegrambot.py b/telegrambot.py index 90fe016e..6e7669a3 100644 --- a/telegrambot.py +++ b/telegrambot.py @@ -247,9 +247,14 @@ def cmd_diario(bot: telegram.Bot, update: telegram.Update, session: db.Session): reply(bot, update, strings.DIARIO.ERRORS.INVALID_SYNTAX) return text = update.message.reply_to_message.text - author = session.query(db.Telegram)\ - .filter_by(telegram_id=update.message.reply_to_message.from_user.id)\ - .one_or_none() + if update.message.forward_from: + author = session.query(db.Telegram) \ + .filter_by(telegram_id=update.message.forward_from.id) \ + .one_or_none() + else: + author = session.query(db.Telegram)\ + .filter_by(telegram_id=update.message.reply_to_message.from_user.id)\ + .one_or_none() saver = session.query(db.Telegram).filter_by(telegram_id=update.message.from_user.id).one_or_none() if text is None: reply(bot, update, strings.DIARIO.ERRORS.NO_TEXT)