Add configuration variable supybot.reply.format.url.

This commit is contained in:
Valentin Lorentz 2012-07-31 13:12:33 +00:00
parent 60cba105c8
commit ef78c86974
3 changed files with 10 additions and 1 deletions

View File

@ -54,6 +54,12 @@ class GoogleTestCase(ChannelPluginTestCase):
# Unicode check
self.assertNotError('google ae')
def testSearchFormat(self):
self.assertRegexp('google foo', '<http://.*>')
self.assertNotError('config reply.format.url %s')
self.assertRegexp('google foo', 'http://.*')
self.assertNotRegexp('google foo', '<http://.*>')
def testSearchOneToOne(self):
self.assertRegexp('google dupa', ';')
self.assertNotError('config plugins.Google.oneToOne True')

View File

@ -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

View File

@ -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 ''