Fixed morse code

This commit is contained in:
Jeremy Fincher 2003-03-15 12:49:54 +00:00
parent 52b1270211
commit b8189d55ce

View File

@ -92,7 +92,6 @@ class Moobot(callbacks.Privmsg):
"7" : "--... ", "7" : "--... ",
"8" : "---.. ", "8" : "---.. ",
"9" : "----. ", "9" : "----. ",
" " : " "
} }
_revcode = dict([(y.strip(), x) for (x, y) in _code.items()]) _revcode = dict([(y.strip(), x) for (x, y) in _code.items()])
@ -104,11 +103,14 @@ class Moobot(callbacks.Privmsg):
""" """
text = privmsgs.getArgs(args) text = privmsgs.getArgs(args)
L = [] L = []
for code in text.split(): for (first, second, third) in window(text.split(' ')+[''], 3):
try: if first == '' and second == '' and third == '':
L.append(self._revcode[code]) L.append(' ')
except KeyError: else:
L.append(code) try:
L.append(self._revcode[first])
except KeyError:
L.append(first)
irc.reply(msg, ''.join(L)) irc.reply(msg, ''.join(L))
def morse(self, irc, msg, args): def morse(self, irc, msg, args):