extlib/megahal.py: don't crash when the input string ends in '

This commit is contained in:
Brian S. Stephan 2010-12-23 10:01:11 -06:00
parent ae6eda2c6a
commit c513a0bebc
2 changed files with 4 additions and 3 deletions

View File

@ -167,6 +167,10 @@ class Brain(object):
boundary = False
elif position == len(string):
boundary = True
elif (string[position] == "'" and
string[position - 1].isalpha() and
position + 1 == len(string)):
boundary = True
elif (string[position] == "'" and
string[position - 1].isalpha() and
string[position + 1].isalpha()):

View File

@ -59,9 +59,6 @@ class MegaHAL(Module):
reply = ""
append_nick = False
if line[-1] == '\'':
line = line[:-1]
if re.search(connection.get_nickname(), line, re.IGNORECASE) is not None:
addressed_pattern = '^' + connection.get_nickname() + '[:,]\s+'
addressed_re = re.compile(addressed_pattern)