mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-24 19:52:54 +01:00
Filter: Rename _(un)code to _(morse|unMorse)code
Closes: Sf#3056753
Signed-off-by: James Vega <jamessan@users.sourceforge.net>
(cherry picked from commit 452c019b10
)
Signed-off-by: Daniel Folkinshteyn <nanotube@users.sourceforge.net>
This commit is contained in:
parent
d6423cad67
commit
ee42f42fb4
@ -278,7 +278,7 @@ class Filter(callbacks.Plugin):
|
|||||||
irc.reply(s)
|
irc.reply(s)
|
||||||
scramble = wrap(scramble, ['text'])
|
scramble = wrap(scramble, ['text'])
|
||||||
|
|
||||||
_code = {
|
_morseCode = {
|
||||||
"A" : ".-",
|
"A" : ".-",
|
||||||
"B" : "-...",
|
"B" : "-...",
|
||||||
"C" : "-.-.",
|
"C" : "-.-.",
|
||||||
@ -326,7 +326,7 @@ class Filter(callbacks.Plugin):
|
|||||||
"@" : ".--.-.",
|
"@" : ".--.-.",
|
||||||
"=" : "-...-"
|
"=" : "-...-"
|
||||||
}
|
}
|
||||||
_revcode = dict([(y, x) for (x, y) in _code.items()])
|
_revMorseCode = dict([(y, x) for (x, y) in _morseCode.items()])
|
||||||
_unmorsere = re.compile('([.-]+)')
|
_unmorsere = re.compile('([.-]+)')
|
||||||
def unmorse(self, irc, msg, args, text):
|
def unmorse(self, irc, msg, args, text):
|
||||||
"""<Morse code text>
|
"""<Morse code text>
|
||||||
@ -336,7 +336,7 @@ class Filter(callbacks.Plugin):
|
|||||||
text = text.replace('_', '-')
|
text = text.replace('_', '-')
|
||||||
def morseToLetter(m):
|
def morseToLetter(m):
|
||||||
s = m.group(1)
|
s = m.group(1)
|
||||||
return self._revcode.get(s, s)
|
return self._revMorseCode.get(s, s)
|
||||||
text = self._unmorsere.sub(morseToLetter, text)
|
text = self._unmorsere.sub(morseToLetter, text)
|
||||||
text = text.replace(' ', '\x00')
|
text = text.replace(' ', '\x00')
|
||||||
text = text.replace(' ', '')
|
text = text.replace(' ', '')
|
||||||
@ -351,10 +351,7 @@ class Filter(callbacks.Plugin):
|
|||||||
"""
|
"""
|
||||||
L = []
|
L = []
|
||||||
for c in text.upper():
|
for c in text.upper():
|
||||||
if c in self._code:
|
L.append(self._morseCode.get(c, c))
|
||||||
L.append(self._code[c])
|
|
||||||
else:
|
|
||||||
L.append(c)
|
|
||||||
irc.reply(' '.join(L))
|
irc.reply(' '.join(L))
|
||||||
morse = wrap(morse, ['text'])
|
morse = wrap(morse, ['text'])
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user