diff --git a/discordc.py b/discordc.py index f5b2dca..5de3b5c 100644 --- a/discordc.py +++ b/discordc.py @@ -4,6 +4,7 @@ from asyncio import coroutines import concurrent.futures from asyncio import futures +from text_util import toMathSans logging.basicConfig(level=logging.INFO) @@ -81,7 +82,10 @@ async def on_message(message): if len(message.attachments) > 0: content += ' ' + message.attachments[0].url - irc.send_my_message("%s: %s" % (message.author.name, content)) + # Note(jpc) for nick escaping + authorName = toMathSans(message.author.name) + irc.send_my_message("%s: %s" % (authorName, content)) + @client.event async def on_ready(): diff --git a/text_util.py b/text_util.py new file mode 100644 index 0000000..87900ea --- /dev/null +++ b/text_util.py @@ -0,0 +1,12 @@ +def toMathSans(text): + # convert alphabetic characters to Math Sans, for nick escaping + result = '' + for c in text: + o = ord(c) + if o >= 0x0061 and o <= 0x007a: + result += chr(o - 0x0061 + 0x1d5ba) + elif o >= 0x0041 and o <= 0x005a: + result += chr(o - 0x0041 + 0x1d5a0) + else: + result += c + return result