Commit 51fc2990 authored by Guillaume Binet's avatar Guillaume Binet

pep8

parent 14b08620
......@@ -15,8 +15,6 @@ from errbot.templating import tenv
from errbot.bundled.threadpool import ThreadPool, WorkRequest
class ACLViolation(Exception):
"""Exceptions raised when user is not allowed to execute given command due to ACLs"""
......@@ -1017,20 +1015,26 @@ class Backend(object):
if cmd not in self.bot_config.ACCESS_CONTROLS:
self.bot_config.ACCESS_CONTROLS[cmd] = self.bot_config.ACCESS_CONTROLS_DEFAULT
if 'allowusers' in self.bot_config.ACCESS_CONTROLS[cmd] and usr not in self.bot_config.ACCESS_CONTROLS[cmd]['allowusers']:
if ('allowusers' in self.bot_config.ACCESS_CONTROLS[cmd] and
usr not in self.bot_config.ACCESS_CONTROLS[cmd]['allowusers']):
raise ACLViolation("You're not allowed to access this command from this user")
if 'denyusers' in self.bot_config.ACCESS_CONTROLS[cmd] and usr in self.bot_config.ACCESS_CONTROLS[cmd]['denyusers']:
if ('denyusers' in self.bot_config.ACCESS_CONTROLS[cmd] and
usr in self.bot_config.ACCESS_CONTROLS[cmd]['denyusers']):
raise ACLViolation("You're not allowed to access this command from this user")
if typ == 'groupchat':
stripped = mess.frm.stripped
if 'allowmuc' in self.bot_config.ACCESS_CONTROLS[cmd] and self.bot_config.ACCESS_CONTROLS[cmd]['allowmuc'] is False:
if ('allowmuc' in self.bot_config.ACCESS_CONTROLS[cmd] and
self.bot_config.ACCESS_CONTROLS[cmd]['allowmuc'] is False):
raise ACLViolation("You're not allowed to access this command from a chatroom")
if 'allowrooms' in self.bot_config.ACCESS_CONTROLS[cmd] and stripped not in self.bot_config.ACCESS_CONTROLS[cmd]['allowrooms']:
if ('allowrooms' in self.bot_config.ACCESS_CONTROLS[cmd] and
stripped not in self.bot_config.ACCESS_CONTROLS[cmd]['allowrooms']):
raise ACLViolation("You're not allowed to access this command from this room")
if 'denyrooms' in self.bot_config.ACCESS_CONTROLS[cmd] and stripped in self.bot_config.ACCESS_CONTROLS[cmd]['denyrooms']:
if ('denyrooms' in self.bot_config.ACCESS_CONTROLS[cmd] and
stripped in self.bot_config.ACCESS_CONTROLS[cmd]['denyrooms']):
raise ACLViolation("You're not allowed to access this command from this room")
else:
if 'allowprivate' in self.bot_config.ACCESS_CONTROLS[cmd] and self.bot_config.ACCESS_CONTROLS[cmd]['allowprivate'] is False:
if ('allowprivate' in self.bot_config.ACCESS_CONTROLS[cmd] and
self.bot_config.ACCESS_CONTROLS[cmd]['allowprivate'] is False):
raise ACLViolation("You're not allowed to access this command via private message to me")
f = self.commands[cmd] if cmd in self.commands else self.re_commands[cmd]
......@@ -1055,7 +1059,8 @@ class Backend(object):
matches.extend(difflib.get_close_matches(full_cmd, ununderscore_keys))
matches = set(matches)
if matches:
return part1 + '\n\nDid you mean "' + self.bot_config.BOT_PREFIX + ('" or "' + self.bot_config.BOT_PREFIX).join(matches) + '" ?'
return (part1 + '\n\nDid you mean "' + self.bot_config.BOT_PREFIX +
('" or "' + self.bot_config.BOT_PREFIX).join(matches) + '" ?')
else:
return part1
......@@ -1125,7 +1130,7 @@ class Backend(object):
usage = '\n'.join(sorted([
self.bot_config.BOT_PREFIX + '%s: %s' % (name, (command.__doc__ or
'(undocumented)').strip().split('\n', 1)[0])
'(undocumented)').strip().split('\n', 1)[0])
for (name, command) in self.commands.items()
if name != 'help'
and not command._err_command_hidden
......
......@@ -159,7 +159,16 @@ class IRCMUCRoom(MUCRoom):
class IRCConnection(SingleServerIRCBot):
def __init__(self, callback, nickname, server, port=6667, ssl=False, password=None, username=None, private_rate = 1, channel_rate = 1):
def __init__(self,
callback,
nickname,
server,
port=6667,
ssl=False,
password=None,
username=None,
private_rate=1,
channel_rate=1):
self.use_ssl = ssl
self.callback = callback
# manually decorate functions
......
......@@ -33,7 +33,6 @@ except ImportError as _:
sys.exit(-1)
def verify_gtalk_cert(xmpp_client):
"""
Hack specific for google apps domains with SRV entries.
......@@ -356,7 +355,9 @@ XMPP_TO_ERR_STATUS = {'available': ONLINE,
'dnd': DND,
'unavailable': OFFLINE}
class XMPPBackend(ErrBot):
def __init__(self, config):
super(XMPPBackend, self).__init__(config)
identity = config.BOT_IDENTITY
......
......@@ -51,6 +51,7 @@ CONFIGS = b'configs' if PY2 else 'configs'
REPOS = b'repos' if PY2 else 'repos'
BL_PLUGINS = b'bl_plugins' if PY2 else 'bl_plugins'
def bot_config_defaults(config):
if not hasattr(config, 'ACCESS_CONTROLS_DEFAULT'):
config.ACCESS_CONTROLS_DEFAULT = {}
......@@ -73,6 +74,7 @@ def bot_config_defaults(config):
if not hasattr(config, 'MESSAGE_SIZE_LIMIT'):
config.MESSAGE_SIZE_LIMIT = 10000 # Corresponds with what HipChat accepts
class ErrBot(Backend, StoreMixin):
""" ErrBot is the layer of Err that takes care of the plugin management and dispatching
"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment