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