yield from maybe_say(channel, text, 1.0)
@asyncio.coroutine
+def say_expect(message, stdout):
+ if stdout:
+ log.debug(stdout)
+ yield from client.send_message(message.channel, '{}```{}```'.format('{} '.format(message.author.mention) if not message.channel.is_private else '', stdout))
+ else:
+ yield from say(message.channel, 'Sorry!')
+
+@asyncio.coroutine
def not_admin(message):
log.warning('Not admin: {} id {}'.format(message.author, message.author.id))
yield from maybe_say(message.channel, 'hiss!')
yield from client.send_typing(message.channel)
p.sendline(raw)
wait_for_prompt(p)
- stdout = p.before
- if stdout:
- log.info(stdout)
- yield from client.send_message(message.channel, '{}```{}```'.format('{} '.format(message.author.mention) if not message.channel.is_private else '', stdout))
- else:
- yield from say(message.channel, 'Sorry!')
+ yield from say_expect(message, p.before)
+
+@asyncio.coroutine
+def do_fork(message, command, raw):
+ yield from client.send_typing(message.channel)
+ if re.search(r'[^A-Za-z0-9-_."\'"]', raw):
+ yield from say(message.channel, 'hiss')
+ return
+ p = pexpect.spawnu('./{}'.format(raw))
+ p.expect(pexpect.EOF)
+ yield from say_expect(message, p.before)
p = pexpect.spawnu('./edi.py')
wait_for_prompt(p)
'fn': do_edi,
'args': [p],
'commands': ['coords', 'close_to', 'distance', 'edts', 'fuel_usage', 'galmath', 'help', 'raikogram']
+ },
+ 'fork': {
+ 'fn': do_fork,
+ 'args': [],
+ 'commands': ['gravity', 'material', 'range']
}
}