diff options
| author | 2021-01-25 10:46:04 +0545 | |
|---|---|---|
| committer | 2021-01-25 10:46:04 +0545 | |
| commit | a123417cb9fe2d9be86bab41c6a166e29833f6a3 (patch) | |
| tree | fa83e9e330be541e5967dd972dfe2addeedaba42 | |
| parent | Fixed python_general const in server command (diff) | |
Removed self.interpreter from internal cog, and deleted the interpreter helper file
| -rw-r--r-- | bot/exts/utils/internal.py | 1 | ||||
| -rw-r--r-- | bot/interpreter.py | 51 |
2 files changed, 0 insertions, 52 deletions
diff --git a/bot/exts/utils/internal.py b/bot/exts/utils/internal.py index 3521c8fd4..cc0c8a574 100644 --- a/bot/exts/utils/internal.py +++ b/bot/exts/utils/internal.py @@ -30,7 +30,6 @@ class Internal(Cog): self.ln = 0 self.stdout = StringIO() - self.interpreter = Interpreter() self.socket_since = datetime.utcnow() self.socket_event_total = 0 diff --git a/bot/interpreter.py b/bot/interpreter.py deleted file mode 100644 index b58f7a6b0..000000000 --- a/bot/interpreter.py +++ /dev/null @@ -1,51 +0,0 @@ -from code import InteractiveInterpreter -from io import StringIO -from typing import Any - -from discord.ext.commands import Context - -import bot - -CODE_TEMPLATE = """ -async def _func(): -{0} -""" - - -class Interpreter(InteractiveInterpreter): - """ - Subclass InteractiveInterpreter to specify custom run functionality. - - Helper class for internal eval. - """ - - write_callable = None - - def __init__(self): - locals_ = {"bot": bot.instance} - super().__init__(locals_) - - async def run(self, code: str, ctx: Context, io: StringIO, *args, **kwargs) -> Any: - """Execute the provided source code as the bot & return the output.""" - self.locals["_rvalue"] = [] - self.locals["ctx"] = ctx - self.locals["print"] = lambda x: io.write(f"{x}\n") - - code_io = StringIO() - - for line in code.split("\n"): - code_io.write(f" {line}\n") - - code = CODE_TEMPLATE.format(code_io.getvalue()) - del code_io - - self.runsource(code, *args, **kwargs) - self.runsource("_rvalue = _func()", *args, **kwargs) - - rvalue = await self.locals["_rvalue"] - - del self.locals["_rvalue"] - del self.locals["ctx"] - del self.locals["print"] - - return rvalue |