From 3964ff50ef44f07f68208689398ad0e77f79de1d Mon Sep 17 00:00:00 2001 From: Gordon Shumway <39967334+oddluck@users.noreply.github.com> Date: Fri, 15 Mar 2019 20:15:58 -0400 Subject: [PATCH] line-by-line output --- Frotz/plugin.py | 41 ++++++++++++++--------------------------- 1 file changed, 14 insertions(+), 27 deletions(-) diff --git a/Frotz/plugin.py b/Frotz/plugin.py index 50b6d2c..f0b6c52 100644 --- a/Frotz/plugin.py +++ b/Frotz/plugin.py @@ -51,29 +51,18 @@ class Frotz(callbacks.Plugin): irc.reply("Starting {0} on {1}. Please wait...".format(game_name, channel)) game_file= "{0}{1}".format(self.game_path, game_name) self.game[channel] = pexpect.spawn("{0} -S 0 {1}".format(self.binary, game_file)) - score, response = self.output(self.game[channel]) - if score: - irc.reply(score, prefixNick=False) - irc.reply(response, prefixNick=False) + response = self.output(self.game[channel]) + for line in response: + if line.strip() and line.strip() != ".": + irc.reply(line, prefixNick=False) load = wrap(load, ['text']) def output(self, output): response = [] - prompts = ["\n>", "\n> >", "to begin]", "\n\*\*\*MORE\*\*\*", pexpect.TIMEOUT] + prompts = ["\n>", "\n> >", "to begin]", "\n\*\*\*MORE\*\*\*", "to continue.]", pexpect.TIMEOUT] output.expect(prompts, timeout=2) - response = re.sub('(?