From b045b535196ed3fe438b70466f39e37d5b219fa8 Mon Sep 17 00:00:00 2001 From: Masahiko AMANO Date: Wed, 25 Jun 2025 02:00:19 +0300 Subject: [PATCH] feat(bot): use message timestamp instead of current time when adding quote --- bot/src/db.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bot/src/db.py b/bot/src/db.py index 54b3284..1ba5096 100644 --- a/bot/src/db.py +++ b/bot/src/db.py @@ -53,8 +53,9 @@ class Database: quote = msg.text.strip().split("\n\n") text = quote[0].strip() author = "" if len(quote) == 1 else quote[1].strip() + timestamp = msg.forward_origin.date if msg.forward_origin else msg.date with self.conn.cursor() as cursor: - cursor.execute("INSERT INTO quotes(text, author, creator_id) VALUES(%s, NULLIF(%s, ''), (SELECT id FROM users WHERE telegram_id=%s)) RETURNING id", (quote[0].strip(), author, msg.from_user.id)) + cursor.execute("INSERT INTO quotes(text, author, creator_id, datetime) VALUES(%s, NULLIF(%s, ''), (SELECT id FROM users WHERE telegram_id=%s), to_timestamp(%s)::timestamptz) RETURNING id", (quote[0].strip(), author, msg.from_user.id, timestamp)) return cursor.fetchone()[0] def quotes_count(self):