Fixed morse code

This commit is contained in:
Jeremy Fincher 2003-03-15 12:49:54 +00:00
parent 52b1270211
commit b8189d55ce
1 changed files with 8 additions and 6 deletions

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):
if first == '' and second == '' and third == '':
L.append(' ')
else:
try: try:
L.append(self._revcode[code]) L.append(self._revcode[first])
except KeyError: except KeyError:
L.append(code) 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):