async evaluation
This commit is contained in:
parent
84e537847d
commit
538bfbcda4
4 changed files with 13 additions and 2 deletions
Binary file not shown.
Binary file not shown.
|
@ -34,9 +34,20 @@ async def joins(self, chan, source, msg):
|
||||||
for i in self.joins:
|
for i in self.joins:
|
||||||
await self.join(i)
|
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):
|
async def ev(self, chan, source, msg):
|
||||||
msg = msg.split(' ')
|
msg = msg.split(' ')
|
||||||
exec(' '.join(msg))
|
await aexec(self, ' '.join(msg))
|
||||||
await self.message(chan, 'ok')
|
await self.message(chan, 'ok')
|
||||||
|
|
||||||
async def send(self, c, n, m):
|
async def send(self, c, n, m):
|
||||||
|
|
|
@ -55,7 +55,7 @@ async def genOut(self, noun):
|
||||||
async def filter(self, c, n, m):
|
async def filter(self, c, n, m):
|
||||||
if c in self.qtime and self.qtime[c] > time.time():
|
if c in self.qtime and self.qtime[c] > time.time():
|
||||||
return
|
return
|
||||||
if m[:5] == 'kim: ':
|
if m[:len(self.prefix)] == self.prefix:
|
||||||
m = m[5:]
|
m = m[5:]
|
||||||
await go(self, c, n, m)
|
await go(self, c, n, m)
|
||||||
elif m[:4] == 'kim ':
|
elif m[:4] == 'kim ':
|
||||||
|
|
Loading…
Reference in a new issue