TextAdventures: try/except message handling

This commit is contained in:
oddluck 2020-03-01 22:24:37 +00:00
parent 665ba1497f
commit e2c8e89440

View File

@ -86,7 +86,7 @@ class TextAdventures(callbacks.Plugin):
response = [] response = []
prompts = ["\n> >", "\n>", "\n\)", pexpect.TIMEOUT] prompts = ["\n> >", "\n>", "\n\)", pexpect.TIMEOUT]
output.expect(prompts, timeout=1) output.expect(prompts, timeout=1)
response = output.before response = output.before
response = response.decode().splitlines() response = response.decode().splitlines()
return response return response
@ -99,12 +99,17 @@ class TextAdventures(callbacks.Plugin):
if not self.registryValue('requireCommand') or not irc.isChannel(msg.args[0]): if not self.registryValue('requireCommand') or not irc.isChannel(msg.args[0]):
self.game.setdefault(channel, None) self.game.setdefault(channel, None)
if self.game[channel]: if self.game[channel]:
command = msg.args[1] try:
self.game[channel].sendline(r'{}'.format(command)) command = msg.args[1]
response = self.output(self.game[channel]) self.game[channel].sendline(r'{}'.format(command))
for line in response[1:]: response = self.output(self.game[channel])
if line.strip() and line.strip() != ".": for line in response[1:]:
irc.reply(line, prefixNick=False) if line.strip() and line.strip() != ".":
irc.reply(line, prefixNick=False)
except:
return
else:
return
else: else:
return return