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:
parent
042dc1cf98
commit
da1e7abd09
3 changed files with 12 additions and 2 deletions
4
bot.py
4
bot.py
|
@ -16,13 +16,13 @@
|
||||||
# along with Emote Manager. If not, see <https://www.gnu.org/licenses/>.
|
# along with Emote Manager. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
import hashlib
|
|
||||||
import logging
|
import logging
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
from bot_bin.bot import Bot
|
from bot_bin.bot import Bot
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
from utils.compat import md5
|
||||||
|
|
||||||
logging.basicConfig(level=logging.WARNING)
|
logging.basicConfig(level=logging.WARNING)
|
||||||
logging.getLogger('discord').setLevel(logging.INFO)
|
logging.getLogger('discord').setLevel(logging.INFO)
|
||||||
|
@ -61,7 +61,7 @@ class Bot(Bot):
|
||||||
# Metrics
|
# Metrics
|
||||||
|
|
||||||
async def on_command(self, ctx):
|
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(
|
await self.pool.execute(
|
||||||
'INSERT INTO invokes (guild_id, user_id_md5, command) VALUES ($1, $2, $3)',
|
'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,
|
getattr(ctx.guild, 'id', None), user_id_md5, ctx.command.qualified_name,
|
||||||
|
|
|
@ -5,5 +5,6 @@ from . import archive
|
||||||
from . import emote
|
from . import emote
|
||||||
from . import errors
|
from . import errors
|
||||||
from . import paginator
|
from . import paginator
|
||||||
|
from . import compat
|
||||||
# note: do not import .image in case the user doesn't want it
|
# note: do not import .image in case the user doesn't want it
|
||||||
# since importing image can take a long time.
|
# since importing image can take a long time.
|
||||||
|
|
9
utils/compat.py
Normal file
9
utils/compat.py
Normal 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)
|
Loading…
Reference in a new issue