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