fix some issues with mecha karen packet handling
@@ -9,7 +9,6 @@ from util.setup import load_secrets, load_data, setup_karen_logging
from util.ipc import Server, Stream
from bot import run_shard
-
class MechaKaren:
class Share:
def __init__(self):
@@ -53,13 +52,13 @@ class MechaKaren:
await asyncio.gather(*[stream.write_packet(packet.packet) for stream in self.server.connections])
elif packet.type == "eval":
try:
- result = eval(packet.code)
+ result = eval(packet.code, self.eval_env)
success = True
except Exception as e:
- result = e
+ result = str(e)
success = False
- await stream.send_packet({"type": "eval-response", "id": packet.id, "result": result, "success": success})
+ await stream.write_packet({"type": "eval-response", "id": packet.id, "result": result, "success": success})
async def start(self, pp):
await self.server.start()
