More WIP decrypt
This commit is contained in:
parent
d9494364d8
commit
1594df5f85
@ -1,8 +1,11 @@
|
||||
import asyncio
|
||||
import logging
|
||||
import os
|
||||
from concurrent.futures.process import ProcessPoolExecutor
|
||||
from concurrent.futures.thread import ThreadPoolExecutor
|
||||
from typing import Optional
|
||||
|
||||
|
||||
import discord
|
||||
from ciphey import decrypt, iface
|
||||
from redbot.core import Config, commands
|
||||
@ -30,19 +33,24 @@ class Decrypt(commands.Cog):
|
||||
"""Nothing to delete"""
|
||||
return
|
||||
|
||||
@commands.command()
|
||||
async def decrypt(self, ctx: commands.Context, *, encrypted_string):
|
||||
@commands.command(name="decrypt")
|
||||
async def _decrypt(self, ctx: commands.Context, *, encrypted_string):
|
||||
"""Attempt to decrypt any encrypted text"""
|
||||
async with ctx.typing():
|
||||
iconfig = iface.Config().library_default()
|
||||
iconfig.timeout = 10
|
||||
iconfig.complete_config()
|
||||
|
||||
future = self.bot.loop.run_in_executor(
|
||||
None, decrypt, iface.Config().library_default().complete_config(), encrypted_string
|
||||
None,
|
||||
decrypt,
|
||||
iconfig,
|
||||
encrypted_string,
|
||||
)
|
||||
|
||||
|
||||
# TODO: This kills the bot somehow, waiting
|
||||
try:
|
||||
result = await asyncio.wait_for(future, timeout=60, loop=self.bot.loop)
|
||||
result = await asyncio.wait_for(future, timeout=15, loop=self.bot.loop)
|
||||
except asyncio.TimeoutError:
|
||||
result = None
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user