Skip to content

Commit

Permalink
Fixed PEP8 formating
Browse files Browse the repository at this point in the history
  • Loading branch information
EldonMcGuinness committed Dec 14, 2013
1 parent 650ce7d commit 913bec9
Showing 1 changed file with 52 additions and 30 deletions.
82 changes: 52 additions & 30 deletions adminchannel.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,18 @@
import re
from willie.module import commands, priority, OP

STRINGS = {'NOT_ENOUGH_ARGS' : 'Not enough arguments specified',
'TOO_MANY_ARGS' : 'Too many arguments specified',
'NO_PERMISSION' : 'You do not have permission to do this',
'NO_CHANNEL' : 'The channel provided is invalid or one was not specified',
'INVALID_MASK' : 'The mask provided is invalid',
'NO_TOPIC' : 'The topic privided is invalid or one was not specified',
'NO_DATABASE' : 'Could not connect to the Database',
'DEFAULT_KICK_REASON' : 'No reason specified',
'ERROR_PREFIX' : '[ERROR]',
'ERROR_MESSAGE_FORMAT' : '%s %s'}
STRINGS = {'NOT_ENOUGH_ARGS': 'Not enough arguments specified',
'TOO_MANY_ARGS': 'Too many arguments specified',
'NO_PERMISSION': 'You do not have permission to do this',
'NO_CHANNEL': 'The channel provided is invalid or one was not\
specified',
'INVALID_MASK': 'The mask provided is invalid',
'NO_TOPIC': 'The topic privided is invalid or one was not\
specified',
'NO_DATABASE': 'Could not connect to the Database',
'DEFAULT_KICK_REASON': 'No reason specified',
'ERROR_PREFIX': '[ERROR]',
'ERROR_MESSAGE_FORMAT': '%s %s'}


def setup(bot):
Expand Down Expand Up @@ -161,7 +163,8 @@ def kick(bot, trigger):
channel = trigger.sender
reasonidx = 2
else:
bot.reply(STRINGS.get('ERROR_MESSAGE_FORMAT') % (STRINGS.get('ERROR_PREFIX'), e.message))
bot.reply(STRINGS.get('ERROR_MESSAGE_FORMAT') %
(STRINGS.get('ERROR_PREFIX'), e.message))
return

if reasonidx > 1:
Expand All @@ -170,7 +173,8 @@ def kick(bot, trigger):
reason = DEFAULT_KICK_REASON

if not permissionsCheck(bot, channel, trigger.nick):
bot.reply(STRINGS.get('ERROR_MESSAGE_FORMAT') % (STRINGS.get('NO_PERMISSION'), e.message))
bot.reply(STRINGS.get('ERROR_MESSAGE_FORMAT') %
(STRINGS.get('ERROR_PREFIX'), e.message))
return

if nick != bot.config.nick:
Expand Down Expand Up @@ -270,7 +274,8 @@ def kickban(bot, trigger):
argc = len(args) - 1

if argc < 2:
bot.reply(STRINGS.get('ERROR_MESSAGE_FORMAT') % (STRINGS.get('NOT_ENOUGH_ARGS'), e.message))
bot.reply(STRINGS.get('ERROR_MESSAGE_FORMAT') %
(STRINGS.get('ERROR_PREFIX'), e.message))
return
elif argc == 2:
channel = trigger.sender
Expand All @@ -295,11 +300,13 @@ def kickban(bot, trigger):
banmask = configureHostMask(banmask)

if banmask == '':
bot.reply(STRINGS.get('ERROR_MESSAGE_FORMAT') % (STRINGS.get('INVALID_MASK'), e.message))
bot.reply(STRINGS.get('ERROR_MESSAGE_FORMAT') %
(STRINGS.get('ERROR_PREFIX'), e.message))
return

if not permissionsCheck(bot, channel, trigger.nick):
bot.reply(STRINGS.get('ERROR_MESSAGE_FORMAT') % (STRINGS.get('NO_PERMISSION'), e.message))
bot.reply(STRINGS.get('ERROR_MESSAGE_FORMAT') %
(STRINGS.get('ERROR_PREFIX'), e.message))
return

bot.write(['MODE', channel, '+b', banmask])
Expand Down Expand Up @@ -329,10 +336,12 @@ def topic(bot, trigger):
argc = len(args) - 1

if argc < 1:
bot.reply(STRINGS.get('ERROR_MESSAGE_FORMAT') % (STRINGS.get('NO_TOPIC'), e.message))
bot.reply(STRINGS.get('ERROR_MESSAGE_FORMAT') %
(STRINGS.get('ERROR_PREFIX'), e.message))
return
elif argc < 2 and args[1].startswith('#'):
bot.reply(STRINGS.get('ERROR_MESSAGE_FORMAT') % (STRINGS.get('NO_TOPIC'), e.message))
bot.reply(STRINGS.get('ERROR_MESSAGE_FORMAT') %
(STRINGS.get('ERROR_PREFIX'), e.message))
return
elif argc > 1:
if args[1].startswith('#'):
Expand Down Expand Up @@ -374,7 +383,8 @@ def topic(bot, trigger):
new_topic = mask % topic_args

if not permissionsCheck(bot, channel, trigger.nick):
bot.reply(STRINGS.get('ERROR_MESSAGE_FORMAT') % (STRINGS.get('NO_PERMISSION'), e.message))
bot.reply(STRINGS.get('ERROR_MESSAGE_FORMAT') %
(STRINGS.get('ERROR_PREFIX'), e.message))
return

bot.write(('TOPIC', channel), text=new_topic)
Expand All @@ -401,7 +411,8 @@ def set_mask(bot, trigger):
argc = len(args) - 1

if argc < 1:
bot.reply(STRINGS.get('ERROR_MESSAGE_FORMAT') % (STRINGS.get('NO_TOPIC'), e.message))
bot.reply(STRINGS.get('ERROR_MESSAGE_FORMAT') %
(STRINGS.get('ERROR_PREFIX'), e.message))
return
elif argc >= 1:
if args[1].startswith('#'):
Expand All @@ -414,11 +425,13 @@ def set_mask(bot, trigger):
topic_mask = ' '.join(args[maskidx:])

if not permissionsCheck(bot, channel, trigger.nick):
bot.reply(STRINGS.get('ERROR_MESSAGE_FORMAT') % (STRINGS.get('NO_PERMISSION'), e.message))
bot.reply(STRINGS.get('ERROR_MESSAGE_FORMAT') %
(STRINGS.get('ERROR_PREFIX'), e.message))
return

if not bot.db:
bot.reply(STRINGS.get('ERROR_MESSAGE_FORMAT') % (STRINGS.get('NO_DATABASE'), e.message))
bot.reply(STRINGS.get('ERROR_MESSAGE_FORMAT') %
(STRINGS.get('ERROR_PREFIX'), e.message))
return

bot.db.preferences.update(channel.lower(), {'topic_mask': topic_mask})
Expand Down Expand Up @@ -451,15 +464,18 @@ def show_mask(bot, trigger):
channel = trigger.sender.lower()

if not permissionsCheck(bot, channel, trigger.nick):
bot.reply(STRINGS.get('ERROR_MESSAGE_FORMAT') % (STRINGS.get('NO_PERMISSION'), e.message))
bot.reply(STRINGS.get('ERROR_MESSAGE_FORMAT') %
(STRINGS.get('ERROR_PREFIX'), e.message))
return

if not bot.db:
bot.reply(STRINGS.get('ERROR_MESSAGE_FORMAT') % (STRINGS.get('NO_DATABASE'), e.message))
bot.reply(STRINGS.get('ERROR_MESSAGE_FORMAT') %
(STRINGS.get('ERROR_PREFIX'), e.message))
return

if channel not in bot.db.preferences:
bot.reply(STRINGS.get('ERROR_MESSAGE_FORMAT') % (STRINGS.get('NO_CHANNEL'), e.message))
bot.reply(STRINGS.get('ERROR_MESSAGE_FORMAT') %
(STRINGS.get('ERROR_PREFIX'), e.message))
return

topic = bot.db.preferences.get(channel, 'topic_mask')
Expand Down Expand Up @@ -540,19 +556,23 @@ def setMaskMode(bot, trigger, mode):
elif args[1].startswith('#'):
banmask, channel = args[1:3]
else:
bot.reply(STRINGS.get('ERROR_MESSAGE_FORMAT') % (STRINGS.get('NO_CHANNEL'), e.message))
bot.reply(STRINGS.get('ERROR_MESSAGE_FORMAT') %
(STRINGS.get('ERROR_PREFIX'), e.message))
return
else:
bot.reply(STRINGS.get('ERROR_MESSAGE_FORMAT') % (STRINGS.get('TOO_MANY_ARGS'), e.message))
bot.reply(STRINGS.get('ERROR_MESSAGE_FORMAT') %
(STRINGS.get('ERROR_PREFIX'), e.message))
return

if not permissionsCheck(bot, channel, trigger.nick):
bot.reply(STRINGS.get('ERROR_MESSAGE_FORMAT') % (STRINGS.get('NO_PERMISSION'), e.message))
bot.reply(STRINGS.get('ERROR_MESSAGE_FORMAT') %
(STRINGS.get('ERROR_PREFIX'), e.message))
return

banmask = configureHostMask(banmask)
if banmask == '':
bot.reply(STRINGS.get('ERROR_MESSAGE_FORMAT') % (STRINGS.get('INVALID_MASK'), e.message))
bot.reply(STRINGS.get('ERROR_MESSAGE_FORMAT') %
(STRINGS.get('ERROR_PREFIX'), e.message))
return

bot.write(['MODE', channel, mode, banmask])
Expand Down Expand Up @@ -580,11 +600,13 @@ def setMode(bot, trigger, mode):
elif args[2].startswith('#'):
nick, channel = args[1:3]
else:
bot.reply(STRINGS.get('ERROR_MESSAGE_FORMAT') % (STRINGS.get('NO_CHANNEL'), e.message))
bot.reply(STRINGS.get('ERROR_MESSAGE_FORMAT') %
(STRINGS.get('ERROR_PREFIX'), e.message))
return

if not permissionsCheck(bot, channel, trigger.nick):
bot.reply(STRINGS.get('ERROR_MESSAGE_FORMAT') % (STRINGS.get('NO_PERMISSION'), e.message))
bot.reply(STRINGS.get('ERROR_MESSAGE_FORMAT') %
(STRINGS.get('ERROR_PREFIX'), e.message))
return

bot.write(['MODE', channel, mode, nick])
Expand Down

0 comments on commit 913bec9

Please sign in to comment.