markov!
This commit is contained in:
parent
4f303d29ea
commit
e28287e692
2 changed files with 36 additions and 0 deletions
BIN
modules/__pycache__/markov.cpython-36.pyc
Normal file
BIN
modules/__pycache__/markov.cpython-36.pyc
Normal file
Binary file not shown.
36
modules/markov.py
Normal file
36
modules/markov.py
Normal file
|
@ -0,0 +1,36 @@
|
|||
|
||||
import asyncio
|
||||
|
||||
async def run(cmd):
|
||||
proc = await asyncio.create_subprocess_shell(
|
||||
cmd,
|
||||
stdout=asyncio.subprocess.PIPE,
|
||||
stderr=asyncio.subprocess.PIPE)
|
||||
|
||||
stdout, stderr = await proc.communicate()
|
||||
|
||||
print(f'[{cmd!r} exited with {proc.returncode}]')
|
||||
if stdout:
|
||||
return stdout.decode()
|
||||
if stderr:
|
||||
#print(f'[markov stderr]\n{stderr.decode()}')
|
||||
return
|
||||
|
||||
|
||||
|
||||
async def markov(self, c, n, m):
|
||||
m = ''.join([i for i in m if i.isalnum()])
|
||||
if len(m) > 1:
|
||||
await self.message(c, (await run("markov '{}'".format(m)))[:-1])
|
||||
return
|
||||
await self.message(c, 'the oven went boop')
|
||||
|
||||
async def init(self):
|
||||
self.cmd['m'] = markov
|
||||
self.cmd['markov'] = markov
|
||||
self.help['markov'] = ["markov <seed> - generate markov chains", "https://en.wikipedia.org/wiki/Markov_chain"]
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in a new issue