From 1b0c2ab95a153c307c9f25eb053d4e4faaf96c9d Mon Sep 17 00:00:00 2001 From: James Lu Date: Mon, 14 Mar 2016 19:33:47 -0700 Subject: [PATCH 1/2] ircutils: add $network to standard substitutions --- src/ircutils.py | 1 + test/test_ircutils.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/ircutils.py b/src/ircutils.py index 264adc09c..969120126 100644 --- a/src/ircutils.py +++ b/src/ircutils.py @@ -824,6 +824,7 @@ def standardSubstitute(irc, msg, text, env=None): if irc: vars.update({ 'botnick': irc.nick, + 'network': irc.network, }) if msg: diff --git a/test/test_ircutils.py b/test/test_ircutils.py index 908fca7b2..d08515d6e 100644 --- a/test/test_ircutils.py +++ b/test/test_ircutils.py @@ -219,6 +219,8 @@ class FunctionsTestCase(SupyTestCase): msg = ircmsgs.IrcMsg(':%s PRIVMSG #channel :stuff' % self.hostmask) class Irc(object): nick = 'bob' + network = 'testnet' + irc = Irc() f = ircutils.standardSubstitute From 22408ce4132a73ee033dea87563df5b8258ddbd6 Mon Sep 17 00:00:00 2001 From: James Lu Date: Tue, 15 Mar 2016 08:35:46 -0700 Subject: [PATCH 2/2] Fix tests from last commit --- test/test_standardSubstitute.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/test_standardSubstitute.py b/test/test_standardSubstitute.py index 901f6cb4e..d108d7b53 100644 --- a/test/test_standardSubstitute.py +++ b/test/test_standardSubstitute.py @@ -41,6 +41,7 @@ class FunctionsTestCase(SupyTestCase): class state: channels = {'#foo': holder()} nick = 'foobar' + network = 'testnet' @retry() def testStandardSubstitute(self): @@ -82,6 +83,9 @@ class FunctionsTestCase(SupyTestCase): c = f(self.irc, msg, '$channel') self.assertEqual(c, msg.args[0]) + net = f(self.irc, msg, '$network') + self.assertEqual(net, self.irc.network) +