mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-26 20:59:27 +01:00
Added an email converter.
This commit is contained in:
parent
307f50137b
commit
978cf65453
@ -475,6 +475,12 @@ def getUrl(irc, msg, args, state):
|
||||
else:
|
||||
irc.errorInvalid('url', args[0])
|
||||
|
||||
def getEmail(irc, msg, args, state):
|
||||
if utils.net.emailRe.match(args[0]):
|
||||
state.args.append(args.pop(0))
|
||||
else:
|
||||
irc.errorInvalid('email', args[0])
|
||||
|
||||
def getHttpUrl(irc, msg, args, state):
|
||||
if utils.web.httpUrlRe.match(args[0]):
|
||||
state.args.append(args.pop(0))
|
||||
@ -557,6 +563,7 @@ wrappers = ircutils.IrcDict({
|
||||
'color': getIrcColor,
|
||||
'now': getNow,
|
||||
'url': getUrl,
|
||||
'email': getEmail,
|
||||
'httpUrl': getHttpUrl,
|
||||
'long': getLong,
|
||||
'float': getFloat,
|
||||
|
@ -142,5 +142,12 @@ class ConverterTestCase(CommandsTestCase):
|
||||
self.assertState(['url'], [url], [url])
|
||||
self.assertState(['httpUrl'], [url], [url])
|
||||
|
||||
def testEmail(self):
|
||||
email = 'jemfinch@supybot.com'
|
||||
self.assertState(['email'], [email], [email])
|
||||
self.assertError(['email'], ['foo'])
|
||||
self.assertError(['email'], ['foo@'])
|
||||
self.assertError(['email'], ['@foo'])
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user