diff --git a/plugins/Google/test.py b/plugins/Google/test.py index 260b06bf2..9d9495984 100644 --- a/plugins/Google/test.py +++ b/plugins/Google/test.py @@ -54,6 +54,12 @@ class GoogleTestCase(ChannelPluginTestCase): # Unicode check self.assertNotError('google ae') + def testSearchFormat(self): + self.assertRegexp('google foo', '') + self.assertNotError('config reply.format.url %s') + self.assertRegexp('google foo', 'http://.*') + self.assertNotRegexp('google foo', '') + def testSearchOneToOne(self): self.assertRegexp('google dupa', ';') self.assertNotError('config plugins.Google.oneToOne True') diff --git a/src/conf.py b/src/conf.py index 9a9a3ecee..208864adc 100644 --- a/src/conf.py +++ b/src/conf.py @@ -314,6 +314,8 @@ for (name, s) in registry._cache.iteritems(): registerGroup(supybot, 'reply') registerGroup(supybot.reply, 'format') +registerChannelValue(supybot.reply.format, 'url', + registry.String('<%s>', _("""Determines how urls should be formatted."""))) registerChannelValue(supybot.reply.format, 'time', registry.String('%I:%M %p, %B %d, %Y', _("""Determines how timestamps printed for human reading should be formatted. Refer to the Python diff --git a/src/utils/str.py b/src/utils/str.py index c5ce82a3e..79ecb3851 100644 --- a/src/utils/str.py +++ b/src/utils/str.py @@ -471,7 +471,8 @@ def format(s, *args, **kwargs): elif char == 't': return timestamp(args.pop()) elif char == 'u': - return '<%s>' % args.pop() + import supybot.conf as conf + return conf.supybot.reply.format.url() % args.pop() elif char == 'v': args.pop() return ''