From e2c8e89440cc574c413458dbd98e0aa9f2498b06 Mon Sep 17 00:00:00 2001 From: oddluck <39967334+oddluck@users.noreply.github.com> Date: Sun, 1 Mar 2020 22:24:37 +0000 Subject: [PATCH] TextAdventures: try/except message handling --- TextAdventures/plugin.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/TextAdventures/plugin.py b/TextAdventures/plugin.py index 035a775..6bffa08 100644 --- a/TextAdventures/plugin.py +++ b/TextAdventures/plugin.py @@ -86,7 +86,7 @@ class TextAdventures(callbacks.Plugin): response = [] prompts = ["\n> >", "\n>", "\n\)", pexpect.TIMEOUT] output.expect(prompts, timeout=1) - response = output.before + response = output.before response = response.decode().splitlines() return response @@ -99,12 +99,17 @@ class TextAdventures(callbacks.Plugin): if not self.registryValue('requireCommand') or not irc.isChannel(msg.args[0]): self.game.setdefault(channel, None) if self.game[channel]: - command = msg.args[1] - self.game[channel].sendline(r'{}'.format(command)) - response = self.output(self.game[channel]) - for line in response[1:]: - if line.strip() and line.strip() != ".": - irc.reply(line, prefixNick=False) + try: + command = msg.args[1] + self.game[channel].sendline(r'{}'.format(command)) + response = self.output(self.game[channel]) + for line in response[1:]: + if line.strip() and line.strip() != ".": + irc.reply(line, prefixNick=False) + except: + return + else: + return else: return