diff --git a/src/ircmsgs.py b/src/ircmsgs.py index edf7a52d5..e01ce70ea 100644 --- a/src/ircmsgs.py +++ b/src/ircmsgs.py @@ -41,6 +41,7 @@ __revision__ = "$Id$" import fix import re +import time import string import conf @@ -225,6 +226,27 @@ def unAction(msg): assert isAction(msg) return _unactionre.match(msg.args[1]).group(1) +def _escape(s): + s = s.replace('&', '&') + s = s.replace('"', '"') + s = s.replace('<', '<') + s = s.replace('>', '>') + return s + +def toXml(msg, pretty=True, includeTime=True): + assert msg.command == _escape(msg.command) + L = [] + L.append('') + for arg in msg.args: + if pretty: + L.append('\n ') + L.append('%s' % _escape(arg)) + L.append('') + return ''.join(L) + def prettyPrint(msg, addRecipients=False): """Provides a client-friendly string form for messages.