alias PEP8

This commit is contained in:
Will Tekulve 2016-04-12 00:18:42 -04:00
parent e356ced715
commit 8760fb92d5

View File

@ -1,4 +1,3 @@
import discord
from discord.ext import commands
from .utils.chat_formatting import *
from .utils.dataIO import fileIO
@ -6,6 +5,7 @@ from .utils import checks
from __main__ import send_cmd_help
import os
class Alias:
def __init__(self, bot):
self.bot = bot
@ -24,17 +24,17 @@ class Alias:
Example: !alias add test flip @Twentysix"""
server = ctx.message.server
if self.get_prefix(to_execute) == False:
if self.get_prefix(to_execute) is False:
to_execute = self.bot.command_prefix[0] + to_execute
if server.id not in self.aliases:
self.aliases[server.id] = {}
#curr_aliases = self.aliases[server.id]
if command not in self.bot.commands:
self.aliases[server.id][command] = to_execute
fileIO("data/alias/aliases.json", "save", self.aliases)
await self.bot.say("Alias '{}' added.".format(command))
else:
await self.bot.say("Cannot add '{}' because it's a real bot command.".format(command))
await self.bot.say("Cannot add '{}' because it's a real bot "
"command.".format(command))
@alias.command(name="help", pass_context=True)
async def _help_alias(self, ctx, command):
@ -74,7 +74,8 @@ class Alias:
await self.bot.say("Alias '{}' deleted.".format(command))
async def check_aliases(self, message):
if message.author.id == self.bot.user.id or len(message.content) < 2 or message.channel.is_private:
if message.author.id == self.bot.user.id or \
len(message.content) < 2 or message.channel.is_private:
return
msg = message.content
@ -100,11 +101,13 @@ class Alias:
return p
return False
def check_folder():
if not os.path.exists("data/alias"):
print("Creating data/alias folder...")
os.makedirs("data/alias")
def check_file():
aliases = {}
@ -113,6 +116,7 @@ def check_file():
print("Creating default alias's aliases.json...")
fileIO(f, "save", aliases)
def setup(bot):
check_folder()
check_file()