Merge pull request #1228 from GLolol/ircutils-1

ircutils: add $network to standard substitutions
This commit is contained in:
Valentin Lorentz 2016-03-15 17:14:08 +01:00
commit e91b3e70f8
3 changed files with 7 additions and 0 deletions

View File

@ -824,6 +824,7 @@ def standardSubstitute(irc, msg, text, env=None):
if irc: if irc:
vars.update({ vars.update({
'botnick': irc.nick, 'botnick': irc.nick,
'network': irc.network,
}) })
if msg: if msg:

View File

@ -219,6 +219,8 @@ class FunctionsTestCase(SupyTestCase):
msg = ircmsgs.IrcMsg(':%s PRIVMSG #channel :stuff' % self.hostmask) msg = ircmsgs.IrcMsg(':%s PRIVMSG #channel :stuff' % self.hostmask)
class Irc(object): class Irc(object):
nick = 'bob' nick = 'bob'
network = 'testnet'
irc = Irc() irc = Irc()
f = ircutils.standardSubstitute f = ircutils.standardSubstitute

View File

@ -41,6 +41,7 @@ class FunctionsTestCase(SupyTestCase):
class state: class state:
channels = {'#foo': holder()} channels = {'#foo': holder()}
nick = 'foobar' nick = 'foobar'
network = 'testnet'
@retry() @retry()
def testStandardSubstitute(self): def testStandardSubstitute(self):
@ -82,6 +83,9 @@ class FunctionsTestCase(SupyTestCase):
c = f(self.irc, msg, '$channel') c = f(self.irc, msg, '$channel')
self.assertEqual(c, msg.args[0]) self.assertEqual(c, msg.args[0])
net = f(self.irc, msg, '$network')
self.assertEqual(net, self.irc.network)