2016-07-09 13:27:19 +12:00
|
|
|
from discord.ext import commands
|
|
|
|
from . import config
|
|
|
|
|
|
|
|
|
2016-07-16 01:28:23 +12:00
|
|
|
def isOwner(ctx):
|
2016-07-16 01:26:32 +12:00
|
|
|
return ctx.message.author.id == config.ownerID
|
2016-07-09 13:27:19 +12:00
|
|
|
|
2016-07-16 09:39:26 +12:00
|
|
|
|
2016-07-16 08:10:51 +12:00
|
|
|
def customPermsOrRole(perm):
|
|
|
|
def predicate(ctx):
|
2016-07-16 09:39:26 +12:00
|
|
|
nonlocal perm
|
2016-07-16 08:10:51 +12:00
|
|
|
cursor = config.getCursor()
|
|
|
|
cursor.execute('use {}'.format(config.db_perms))
|
|
|
|
cmd = str(ctx.command)
|
|
|
|
sid = ctx.message.server.id
|
2016-07-16 09:51:28 +12:00
|
|
|
f = open("/home/phxntx5/public_html/Bonfire/checkstest.txt", "r+")
|
2016-07-16 09:39:26 +12:00
|
|
|
f.write("cmd: {}\nsid: {}".format(cmd, sid))
|
|
|
|
f.close()
|
2016-07-16 09:51:28 +12:00
|
|
|
|
2016-07-16 08:28:14 +12:00
|
|
|
cursor.execute("show tables like %s", (sid,))
|
2016-07-16 08:10:51 +12:00
|
|
|
result = cursor.fetchone()
|
|
|
|
if result is not None:
|
2016-07-16 09:51:28 +12:00
|
|
|
sql = "select perms from `" + sid + "` where command=%s"
|
2016-07-16 09:39:26 +12:00
|
|
|
cursor.execute(sql, (cmd,))
|
2016-07-16 08:21:27 +12:00
|
|
|
result = cursor.fetchone()
|
2016-07-16 09:51:28 +12:00
|
|
|
if result is not None:
|
|
|
|
perm = result['perms']
|
2016-07-16 08:18:52 +12:00
|
|
|
if perm == "none":
|
2016-07-16 08:10:51 +12:00
|
|
|
return True
|
2016-07-16 08:21:27 +12:00
|
|
|
config.closeConnection()
|
2016-07-16 08:18:52 +12:00
|
|
|
for role in ctx.message.author.roles:
|
2016-07-16 09:39:26 +12:00
|
|
|
if getattr(role, perm):
|
2016-07-16 08:18:52 +12:00
|
|
|
return True
|
|
|
|
return False
|
2016-07-16 09:51:28 +12:00
|
|
|
|
2016-07-16 08:10:51 +12:00
|
|
|
return commands.check(predicate)
|
2016-07-16 09:39:26 +12:00
|
|
|
|
|
|
|
|
2016-07-09 13:27:19 +12:00
|
|
|
def isPM():
|
|
|
|
def predicate(ctx):
|
|
|
|
return ctx.message.channel.is_private
|
|
|
|
|
|
|
|
return commands.check(predicate)
|