From 3ef196a6ee5b4347d8df779738baee97ea7e593f Mon Sep 17 00:00:00 2001 From: bakatrouble Date: Sun, 23 Jul 2023 03:05:49 +0300 Subject: [PATCH] send duplicate original --- bots/modules/channel_helper.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/bots/modules/channel_helper.py b/bots/modules/channel_helper.py index f0d873a..472d1a0 100644 --- a/bots/modules/channel_helper.py +++ b/bots/modules/channel_helper.py @@ -2,6 +2,7 @@ import base64 import json import os import tempfile +import traceback from io import BytesIO from uuid import uuid4 @@ -99,8 +100,13 @@ class ChannelHelperBotModuleConfig(TelegramBotModuleConfig): bot.get_file(p[-1]).download(out=io) im = Image.open(io) i.image_hash = imagehash.phash(im) - if self.queued_items.filter(image_hash=i.image_hash, type='photo').count() > 0: - update.message.reply_text('Duplicate', quote=True) + duplicate = self.queued_items.filter(image_hash=i.image_hash, type='photo').first() + if duplicate: + try: + update.message.reply_photo(json.loads(duplicate.args)[0], 'Duplicate', quote=True) + except: + traceback.print_exc() + update.message.reply_text('Could not send duplicate original', quote=True) return elif hasattr(m, 'sticker') and m.sticker: s = m.sticker