1
0
Fork 0
mirror of https://github.com/uhIgnacio/EmoteManager.git synced 2024-08-15 02:23:13 +00:00

fix 3.8 md5() compat

This commit is contained in:
io mintz 2021-04-06 04:31:47 +00:00
parent 042dc1cf98
commit da1e7abd09
3 changed files with 12 additions and 2 deletions

4
bot.py
View file

@ -16,13 +16,13 @@
# along with Emote Manager. If not, see <https://www.gnu.org/licenses/>.
import base64
import hashlib
import logging
import traceback
import discord
from bot_bin.bot import Bot
from discord.ext import commands
from utils.compat import md5
logging.basicConfig(level=logging.WARNING)
logging.getLogger('discord').setLevel(logging.INFO)
@ -61,7 +61,7 @@ class Bot(Bot):
# Metrics
async def on_command(self, ctx):
user_id_md5 = hashlib.md5(ctx.author.id.to_bytes(8, byteorder='big'), usedforsecurity=False).digest()
user_id_md5 = md5(ctx.author.id.to_bytes(8, byteorder='big')).digest()
await self.pool.execute(
'INSERT INTO invokes (guild_id, user_id_md5, command) VALUES ($1, $2, $3)',
getattr(ctx.guild, 'id', None), user_id_md5, ctx.command.qualified_name,

View file

@ -5,5 +5,6 @@ from . import archive
from . import emote
from . import errors
from . import paginator
from . import compat
# note: do not import .image in case the user doesn't want it
# since importing image can take a long time.

9
utils/compat.py Normal file
View file

@ -0,0 +1,9 @@
import hashlib
try:
hashlib.md5(usedforsecurity=False)
except TypeError:
md5 = hashlib.md5
else:
def md5(*args):
return hashlib.md5(*args, usedforsecurity=False)