diff --git a/modules/__pycache__/admin.cpython-36.pyc b/modules/__pycache__/admin.cpython-36.pyc index f1739c6..50680f2 100644 Binary files a/modules/__pycache__/admin.cpython-36.pyc and b/modules/__pycache__/admin.cpython-36.pyc differ diff --git a/modules/__pycache__/nlp.cpython-36.pyc b/modules/__pycache__/nlp.cpython-36.pyc index 8ddac0c..e5e94d5 100644 Binary files a/modules/__pycache__/nlp.cpython-36.pyc and b/modules/__pycache__/nlp.cpython-36.pyc differ diff --git a/modules/admin.py b/modules/admin.py index 8369213..cc641d9 100644 --- a/modules/admin.py +++ b/modules/admin.py @@ -34,9 +34,20 @@ async def joins(self, chan, source, msg): for i in self.joins: await self.join(i) +async def aexec(self, code): + # Make an async function with the code and `exec` it + exec( + f'async def __ex(self): ' + + ''.join(f'\n {l}' for l in code.split('\n')) + ) + + # Get `__ex` from local variables, call it and return the result + return await locals()['__ex'](self) + + async def ev(self, chan, source, msg): msg = msg.split(' ') - exec(' '.join(msg)) + await aexec(self, ' '.join(msg)) await self.message(chan, 'ok') async def send(self, c, n, m): diff --git a/modules/nlp.py b/modules/nlp.py index 94a5c30..24e7eda 100644 --- a/modules/nlp.py +++ b/modules/nlp.py @@ -55,7 +55,7 @@ async def genOut(self, noun): async def filter(self, c, n, m): if c in self.qtime and self.qtime[c] > time.time(): return - if m[:5] == 'kim: ': + if m[:len(self.prefix)] == self.prefix: m = m[5:] await go(self, c, n, m) elif m[:4] == 'kim ':