Add 'reply_env' attribute to IrcMsg.

This commit is contained in:
Valentin Lorentz 2014-04-18 06:53:52 +00:00
parent 8dbc4da0ac
commit 30cc4804eb
2 changed files with 6 additions and 2 deletions

View File

@ -81,8 +81,9 @@ class IrcMsg(object):
# data. Goodbye, __slots__. # data. Goodbye, __slots__.
# On second thought, let's use methods for tagging. # On second thought, let's use methods for tagging.
__slots__ = ('args', 'command', 'host', 'nick', 'prefix', 'user', __slots__ = ('args', 'command', 'host', 'nick', 'prefix', 'user',
'_hash', '_str', '_repr', '_len', 'tags') '_hash', '_str', '_repr', '_len', 'tags', 'reply_env')
def __init__(self, s='', command='', args=(), prefix='', msg=None): def __init__(self, s='', command='', args=(), prefix='', msg=None,
reply_env=None):
assert not (msg and s), 'IrcMsg.__init__ cannot accept both s and msg' assert not (msg and s), 'IrcMsg.__init__ cannot accept both s and msg'
if not s and not command and not msg: if not s and not command and not msg:
raise MalformedIrcMsg('IRC messages require a command.') raise MalformedIrcMsg('IRC messages require a command.')
@ -90,6 +91,7 @@ class IrcMsg(object):
self._repr = None self._repr = None
self._hash = None self._hash = None
self._len = None self._len = None
self.reply_env = reply_env
self.tags = {} self.tags = {}
if s: if s:
originalString = s originalString = s

View File

@ -713,6 +713,8 @@ def standardSubstitute(irc, msg, text, env=None):
's': localtime[5], 'sec': localtime[5], 'second': localtime[5], 's': localtime[5], 'sec': localtime[5], 'second': localtime[5],
'tz': time.strftime('%Z', localtime), 'tz': time.strftime('%Z', localtime),
}) })
if msg.reply_env:
vars.update(msg.reply_env)
if env is not None: if env is not None:
vars.update(env) vars.update(env)
t = string.Template(text) t = string.Template(text)