mirror of
https://github.com/myned/modufur.git
synced 2024-12-24 22:27:28 +00:00
2 > 4 space
This commit is contained in:
parent
8a0ba12f20
commit
51a002bb3f
2 changed files with 39 additions and 39 deletions
|
@ -14,48 +14,48 @@ owner_id = u.config['owner_id']
|
||||||
|
|
||||||
|
|
||||||
def is_owner():
|
def is_owner():
|
||||||
async def predicate(ctx):
|
async def predicate(ctx):
|
||||||
return ctx.message.author.id == owner_id
|
return ctx.message.author.id == owner_id
|
||||||
return commands.check(predicate)
|
return commands.check(predicate)
|
||||||
|
|
||||||
|
|
||||||
def is_admin():
|
def is_admin():
|
||||||
def predicate(ctx):
|
def predicate(ctx):
|
||||||
return ctx.message.author.guild_permissions.administrator
|
return ctx.message.author.guild_permissions.administrator
|
||||||
return commands.check(predicate)
|
return commands.check(predicate)
|
||||||
|
|
||||||
|
|
||||||
def is_mod():
|
def is_mod():
|
||||||
def predicate(ctx):
|
def predicate(ctx):
|
||||||
return ctx.message.author.guild_permissions.ban_members
|
return ctx.message.author.guild_permissions.ban_members
|
||||||
return commands.check(predicate)
|
return commands.check(predicate)
|
||||||
|
|
||||||
|
|
||||||
def owner(ctx):
|
def owner(ctx):
|
||||||
return ctx.message.author.id == owner_id
|
return ctx.message.author.id == owner_id
|
||||||
|
|
||||||
|
|
||||||
def admin(ctx):
|
def admin(ctx):
|
||||||
return ctx.message.author.guild_permissions.administrator
|
return ctx.message.author.guild_permissions.administrator
|
||||||
|
|
||||||
|
|
||||||
def mod(ctx):
|
def mod(ctx):
|
||||||
return ctx.message.author.guild_permissions.ban_members
|
return ctx.message.author.guild_permissions.ban_members
|
||||||
|
|
||||||
|
|
||||||
def is_nsfw():
|
def is_nsfw():
|
||||||
def predicate(ctx):
|
def predicate(ctx):
|
||||||
if isinstance(ctx.message.channel, d.TextChannel):
|
if isinstance(ctx.message.channel, d.TextChannel):
|
||||||
return ctx.message.channel.is_nsfw()
|
return ctx.message.channel.is_nsfw()
|
||||||
return True
|
return True
|
||||||
return commands.check(predicate)
|
return commands.check(predicate)
|
||||||
|
|
||||||
|
|
||||||
def del_ctx():
|
def del_ctx():
|
||||||
async def predicate(ctx):
|
async def predicate(ctx):
|
||||||
with suppress(AttributeError):
|
with suppress(AttributeError):
|
||||||
if ctx.guild.id in u.settings['del_ctx'] and ctx.me.permissions_in(ctx.channel).manage_messages and isinstance(ctx.message.channel, d.TextChannel):
|
if ctx.guild.id in u.settings['del_ctx'] and ctx.me.permissions_in(ctx.channel).manage_messages and isinstance(ctx.message.channel, d.TextChannel):
|
||||||
with suppress(err.NotFound):
|
with suppress(err.NotFound):
|
||||||
await ctx.message.delete()
|
await ctx.message.delete()
|
||||||
return True
|
return True
|
||||||
return commands.check(predicate)
|
return commands.check(predicate)
|
||||||
|
|
|
@ -8,26 +8,26 @@ from utils import utils as u
|
||||||
|
|
||||||
|
|
||||||
async def get_post(url):
|
async def get_post(url):
|
||||||
content = await u.fetch('http://iqdb.harry.lu', params={'url': url})
|
content = await u.fetch('http://iqdb.harry.lu', params={'url': url})
|
||||||
|
|
||||||
try:
|
|
||||||
value = BeautifulSoup(content, 'html.parser').find_all('a')[1].get('href')
|
|
||||||
if value != '#':
|
|
||||||
return value
|
|
||||||
else:
|
|
||||||
raise IndexError
|
|
||||||
except IndexError:
|
|
||||||
try:
|
try:
|
||||||
raise exc.MatchError(re.search('\/([^\/]+)$', url).group(1))
|
value = BeautifulSoup(content, 'html.parser').find_all('a')[1].get('href')
|
||||||
|
if value != '#':
|
||||||
|
return value
|
||||||
|
else:
|
||||||
|
raise IndexError
|
||||||
|
except IndexError:
|
||||||
|
try:
|
||||||
|
raise exc.MatchError(re.search('\/([^\/]+)$', url).group(1))
|
||||||
|
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
raise exc.MissingArgument
|
raise exc.MissingArgument
|
||||||
|
|
||||||
|
|
||||||
async def get_image(url):
|
async def get_image(url):
|
||||||
content = await u.fetch(url)
|
content = await u.fetch(url)
|
||||||
|
|
||||||
value = html.fromstring(content).xpath(
|
value = html.fromstring(content).xpath(
|
||||||
'string(/html/body/div[@id="content"]/div[@id="post-view"]/div[@class="content"]/div[2]/img/@src)')
|
'string(/html/body/div[@id="content"]/div[@id="post-view"]/div[@class="content"]/div[2]/img/@src)')
|
||||||
|
|
||||||
return value
|
return value
|
||||||
|
|
Loading…
Reference in a new issue