Ben-Brady / PureImage

A discord bot for automatically detecting duplicate images using perceptual image hashing and similar techniques.
6 stars 6 forks source link

Fix null result error when checking videos #3

Closed thomotron closed 2 years ago

thomotron commented 2 years ago

When testing and a video is received, the below error pops up.

[2022-07-24 08:16:19,444] Resposts: Exception in CheckVideo(751321295647670344, "<class 'bytes'>"):
Traceback (most recent call last):
  File "/home/tom/PureImage/src/Modules/Reposts.py", line 31, in Wrapper
    ReturnValue = func(*args, **kwargs)
  File "/home/tom/PureImage/src/Modules/Reposts.py", line 117, in CheckVideo
    return True,Hashes[0]
TypeError: 'sqlite3.Cursor' object is not subscriptable
Ignoring exception in on_message
Traceback (most recent call last):
  File "/home/tom/PureImage/src/venv/lib/python3.10/site-packages/discord/client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "/home/tom/PureImage/src/Cogs/RepostCog.py", line 34, in on_message
    exists, OriginID = Reposts.CheckVideo(msg.guild.id, File)
TypeError: cannot unpack non-iterable NoneType object

It looks as though this was caused by a variable name typo. A follow-up error also occurs if there aren't any message IDs returned from the query, so Hash is null checked as well.