User: Fix checking of GPG availabiliy and add @gpg list command.

This commit is contained in:
Valentin Lorentz 2014-03-25 14:29:32 +00:00
parent 121cc1772e
commit f3e4f097aa

View File

@ -399,18 +399,19 @@ class User(callbacks.Plugin):
remove = wrap(remove, ['private', first('otherUser', 'user'), remove = wrap(remove, ['private', first('otherUser', 'user'),
optional('something'), additional('something', '')]) optional('something'), additional('something', '')])
def callCommand(self, command, irc, msg, *args, **kwargs):
if command[0] != 'gpg' or \
(gpg.available and self.registryValue('gpg.enable')):
return super(User, self) \
.callCommand(command, irc, msg, *args, **kwargs)
else:
irc.error(_('GPG features are not enabled.'))
class gpg(callbacks.Commands): class gpg(callbacks.Commands):
def __init__(self, *args): def __init__(self, *args):
super(User.gpg, self).__init__(*args) super(User.gpg, self).__init__(*args)
self._tokens = {} self._tokens = {}
def callCommand(self, command, irc, msg, *args, **kwargs):
if gpg.available and self.registryValue('gpg.enable'):
return super(User.gpg, self) \
.callCommand(command, irc, msg, *args, **kwargs)
else:
irc.error(_('GPG features are not enabled.'))
def _expire_tokens(self): def _expire_tokens(self):
now = time.time() now = time.time()
self._tokens = dict(filter(lambda x_y: x_y[1][1]>now, self._tokens = dict(filter(lambda x_y: x_y[1][1]>now,
@ -460,6 +461,18 @@ class User(callbacks.Plugin):
irc.error(_('GPG key not associated with your account.')) irc.error(_('GPG key not associated with your account.'))
remove = wrap(remove, ['user', 'somethingWithoutSpaces']) remove = wrap(remove, ['user', 'somethingWithoutSpaces'])
@internationalizeDocstring
def list(self, irc, msg, args, user):
"""takes no arguments
List your GPG keys."""
keyids = user.gpgkeys
if len(keyids) == 0:
irc.reply(_('No key is associated with your account.'))
else:
irc.reply(format('%L', keyids))
list = wrap(list, ['user'])
@internationalizeDocstring @internationalizeDocstring
def gettoken(self, irc, msg, args): def gettoken(self, irc, msg, args):
"""takes no arguments """takes no arguments