send duplicate original

This commit is contained in:
bakatrouble 2023-07-23 03:05:49 +03:00
parent 20b88b400c
commit 3ef196a6ee

View File

@ -2,6 +2,7 @@ import base64
import json import json
import os import os
import tempfile import tempfile
import traceback
from io import BytesIO from io import BytesIO
from uuid import uuid4 from uuid import uuid4
@ -99,8 +100,13 @@ class ChannelHelperBotModuleConfig(TelegramBotModuleConfig):
bot.get_file(p[-1]).download(out=io) bot.get_file(p[-1]).download(out=io)
im = Image.open(io) im = Image.open(io)
i.image_hash = imagehash.phash(im) i.image_hash = imagehash.phash(im)
if self.queued_items.filter(image_hash=i.image_hash, type='photo').count() > 0: duplicate = self.queued_items.filter(image_hash=i.image_hash, type='photo').first()
update.message.reply_text('Duplicate', quote=True) 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 return
elif hasattr(m, 'sticker') and m.sticker: elif hasattr(m, 'sticker') and m.sticker:
s = m.sticker s = m.sticker