Browse Source

fix media filtering bug

master
Anonymous 4 weeks ago
parent
commit
950899ff75
1 changed files with 6 additions and 9 deletions
  1. 6
    9
      antipedo.py

+ 6
- 9
antipedo.py View File

@@ -135,10 +135,7 @@ def setReason(update,context):

for uid in uids:
blacklist[uid]=reason
# This may clog the log for batch adds
debug.info(
f"Blacklisted {uid} by {sender.username}({sender.id}) for {reason}"
)
debug.info(f"Blacklisted {uid} by {sender.username}({sender.id}) for {reason}")

dump_json(blacklist,"blacklist.json")

@@ -179,15 +176,15 @@ def updatePicBlacklist(update,context):
path = file.get_file().download(f"/tmp/{file.file_unique_id}")
phash = str(average_hash(Image.open(path)))
remove(path)
if phash not in filter_list:
if phash=="0000000000000000":
update.message.reply_text(f"Bad thumbnail media.")
elif not phash in filter_list:
filter_list.append(phash)
debug.info(
f"Media blacklisted {phash} by {sender.username}({sender.id})"
)
debug.info(f"Media blacklisted {phash} by {sender.username}({sender.id})")
dump_json(filter_list,"filter.json")
update.message.reply_text("Sucessfully added.")
else:
update.message.reply_text("This media is already filtered.")
update.message.reply_text("This media is already filtered. Hash: {phash}")

def batchBlacklist(update,context):
if not update.message.from_user.id in admins:

Loading…
Cancel
Save