simplify prompt detection

This commit is contained in:
Gordon Shumway 2019-12-10 08:06:01 -05:00 committed by GitHub
parent a1523dd5a5
commit ed82d466cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 10 deletions

View File

@ -62,16 +62,9 @@ class TextAdventures(callbacks.Plugin):
def output(self, output):
response = []
prompts = ["> >$", ">$", "\*\*\*MORE\*\*\*", "\) \[Hit any key to continue.\]", "\[Press RETURN or ENTER to begin.\]", "\[Hit any key to continue.\]", pexpect.TIMEOUT]
output.expect(prompts, timeout=1)
response = output.before
try:
while not output.match.group().decode().endswith(">"):
output.sendline()
output.expect(prompts, timeout=2)
response += output.before
except:
pass
prompts = ["\n>", "\n> >", "\n)", pexpect.TIMEOUT]
output.expect_exact(prompts, timeout=1)
response = output.before
response = response.decode().splitlines()
return response