1
0
Fork 0
mirror of synced 2024-06-09 22:24:32 +12:00

Corrected error caused by the last merge; fixed pep8 issues

This commit is contained in:
phxntxm 2016-10-02 13:08:20 -05:00
parent e36223141a
commit 11e12a7f1b
5 changed files with 65 additions and 60 deletions

View file

@ -82,7 +82,7 @@ class Core:
hm_games = len(
[server_id for server_id, game in self.bot.get_cog('Hangman').games.items()])
ttt_games = len([server_id for server_id,
game in self.bot.get_cog('TicTacToe').boards.items()])
game in self.bot.get_cog('TicTacToe').boards.items()])
count_battles = 0
for battles in self.bot.get_cog('Interaction').battles.values():
count_battles += len(battles)
@ -135,7 +135,7 @@ class Core:
"""Use this to print a random doggo image.
Doggo is love, doggo is life."""
# Find a random image based on how many we currently have
f =random.SystemRandom().choice(glob.glob('images/doggo*'))
f = random.SystemRandom().choice(glob.glob('images/doggo*'))
with open(f, 'rb') as f:
await self.bot.upload(f)
@ -145,7 +145,7 @@ class Core:
"""Use this to print a random snek image.
Sneks are o3o"""
# Find a random image based on how many we currently have
f =random.SystemRandom().choice(glob.glob('images/snek*'))
f = random.SystemRandom().choice(glob.glob('images/snek*'))
with open(f, 'rb') as f:
await self.bot.upload(f)

View file

@ -5,43 +5,52 @@ from .utils import checks
import discord
import random
battle_outcomes = ["A meteor fell on {1}, {0} is left standing and has been declared the victor!",
"{0} has bucked {1} into a tree, even Big Mac would be impressed at that kick!",
"As they were battling, {1} was struck by lightning! {0} you lucked out this time!",
"{1} tried to dive at {0} while fighting, somehow they missed and landed in quicksand. Try paying more attention next time {1}",
"{1} got a little...heated during the battle and ended up getting set on fire. {0} wins by remaining cool",
"Princess Celestia came in and banished {1} to the moon. Good luck getting into any battles up there",
"{1} took an arrow to the knee, they are no longer an adventurer. Keep on adventuring {0}",
"Common sense should make it obvious not to get into battle with {0}. Apparently {1} didn't get the memo",
"{0} had a nice cup of tea with {1} over their conflict, and mutually agreed that {0} was Best Pony",
"{0} and {1} had an intense staring contest. Sadly, {1} forgot to breathe and lost much more than the staring contest",
"It appears {1} is actually a pacifist, they ran away screaming and crying. Maybe you should have thought of that before getting in a fight?",
"A bunch of parasprites came in and ate up the jetpack while {1} was flying with it. Those pesky critters...",
"{0} used their charm to seduce {1} to surrender.",
"{1} slipped on a banana peel and fell into a pit of spikes. That's actually impressive.",
"{0} realized it was high noon, {1} never even saw it coming.",
"{1} spontaneously combusted...lol rip"]
battle_outcomes = \
["A meteor fell on {1}, {0} is left standing and has been declared the victor!",
"{0} has bucked {1} into a tree, even Big Mac would be impressed at that kick!",
"As they were battling, {1} was struck by lightning! {0} you lucked out this time!",
"{1} tried to dive at {0} while fighting, somehow they missed and landed in quicksand."
"Try paying more attention next time {1}",
"{1} got a little...heated during the battle and ended up getting set on fire. {0} wins by remaining cool",
"Princess Celestia came in and banished {1} to the moon. Good luck getting into any battles up there",
"{1} took an arrow to the knee, they are no longer an adventurer. Keep on adventuring {0}",
"Common sense should make it obvious not to get into battle with {0}. Apparently {1} didn't get the memo",
"{0} had a nice cup of tea with {1} over their conflict, and mutually agreed that {0} was Best Pony",
"{0} and {1} had an intense staring contest. "
"Sadly, {1} forgot to breathe and lost much morethan the staring contest",
"It appears {1} is actually a pacifist, they ran away screaming and crying. "
"Maybe you should have thought of that before getting in a fight?",
"A bunch of parasprites came in and ate up the jetpack while {1} was flying with it. Those pesky critters...",
"{0} used their charm to seduce {1} to surrender.",
"{1} slipped on a banana peel and fell into a pit of spikes. That's actually impressive.",
"{0} realized it was high noon, {1} never even saw it coming.",
"{1} spontaneously combusted...lol rip"]
hugs = \
["*hugs {}.*",
"*tackles {} for a hug.*",
"*drags {} into her dungeon where hugs ensue*",
"*pulls {} to the side for a warm hug*",
"*goes out to buy a big enough blanket to embrace {}*",
"*hard codes an electric hug to {}*",
"*hires mercenaries to take {} out....to a nice dinner*",
"*pays $10 to not touch {}*",
"*clones herself to create a hug pile with {}*",
"*orders and airstrike of hugs {}*",
"*glomps {}*",
"*hears a knock at her door, opens it, finds {} and hugs them excitedly*",
"*goes in for a punch but misses and ends up hugging {}*",
"*hugs {} from behind*",
"*denies a hug from {}*",
"*does a hug to {}*",
"*lets {} cuddle nonchalantly*",
"*cuddles {}*",
"*burrows underground and pops up underneath {} she hugs their legs.*",
"*approaches {} after having gone to the gym for several months and almost crushes them.*"]
hugs = ["*hugs {}.*",
"*tackles {} for a hug.*",
"*drags {} into her dungeon where hugs ensue*",
"*pulls {} to the side for a warm hug*",
"*goes out to buy a big enough blanket to embrace {}*",
"*hard codes an electric hug to {}*",
"*hires mercenaries to take {} out....to a nice dinner*",
"*pays $10 to not touch {}*",
"*clones herself to create a hug pile with {}*",
"*orders and airstrike of hugs {}*",
"*glomps {}*",
"*hears a knock at her door, opens it, finds {} and hugs them excitedly*",
"*goes in for a punch but misses and ends up hugging {}*",
"*hugs {} from behind*",
"*denies a hug from {}*",
"*does a hug to {}*",
"*lets {} cuddle nonchalantly*",
"*cuddles {}*",
"*burrows underground and pops up underneath {} she hugs their legs.*",
"*approaches {} after having gone to the gym for several months and almost crushes them.*"]
class Interaction:
"""Commands that interact with another user"""
@ -77,7 +86,7 @@ class Interaction:
@commands.command(pass_context=True, no_pm=True)
@checks.custom_perms(send_messages=True)
async def hug (self, ctx, user: discord.Member=None):
async def hug(self, ctx, user: discord.Member = None):
if user is None:
user = ctx.message.author
@ -163,7 +172,7 @@ class Interaction:
@commands.command(pass_context=True, no_pm=True)
@commands.cooldown(1, 180, BucketType.user)
@checks.custom_perms(send_messages=True)
async def boop(self, ctx, boopee: discord.Member=None):
async def boop(self, ctx, boopee: discord.Member = None):
"""Boops the mentioned person"""
booper = ctx.message.author
if boopee is None:

View file

@ -27,9 +27,9 @@ class Links:
# All we need to do is search for the term provided, so the action, list, and format never need to change
base_url = "https://en.wikipedia.org/w/api.php"
params = {"action": "query",
"list": "search",
"format": "json",
"srsearch": query.replace(" ", "%20")}
"list": "search",
"format": "json",
"srsearch": query.replace(" ", "%20")}
async with self.session.get(base_url, params=params, headers=self.headers) as r:
data = await r.json()
@ -92,7 +92,6 @@ class Links:
else:
params['q'] += ", safe"
await self.bot.say("Looking up an image with those tags....")
# Get the response from derpibooru and parse the 'search' result from it
@ -139,7 +138,7 @@ class Links:
tags = tags.replace(' ', '_')
url = 'https://e621.net/post/index.json'
params = {'limit': 320,
'tags': tags}
'tags': tags}
# e621 provides a way to change how many images can be shown on one request
# This gives more of a chance of random results, however it causes the lookup to take longer than most
# Due to this, send a message saying we're looking up the information first
@ -147,30 +146,25 @@ class Links:
r_filter = {'channel_id': ctx.message.channel.id}
nsfw_channels = await config.get_content("nsfw_channels", r_filter)
# e621 by default does not filter explicit content, so tack on
# safe/explicit based on if this channel is nsfw or not
if nsfw_channels is not None:
params['tags'] += " rating:explicit"
else:
url += " rating:safe"
params['tags'] += " rating:explicit" if nsfw_channels else " rating:safe"
try:
async with self.session.get(url, headers=self.headers) as r:
async with self.session.get(url, params=params, headers=self.headers) as r:
data = await r.json()
except json.JSONDecodeError:
await self.bot.say("Sorry, I had trouble connecting at the moment; please try again later")
return
params['tags'] += " rating:safe"
async with self.session.get(url, params=params, headers=self.headers) as r:
data = await r.json()
# Try to find an image from the list. If there were no results, we're going to attempt to find
# A number between (0,-1) and receive an error.
# The response should be in a list format, so we'll end up getting a key error if the response was in json
# i.e. it responded with a 404/504/etc.
try:
rand_image = data[random.SystemRandom().randint(0, len(data) - 1)]['file_url']
await self.bot.say(rand_image)
rand_image = data[random.SystemRandom().randint(0, len(data) - 1)]['file_url']
await self.bot.say(rand_image)
except (ValueError, KeyError, TypeError):
await self.bot.say("No results with that tag {}".format(ctx.message.author.mention))
return

View file

@ -174,7 +174,8 @@ class Mod:
permissions = msg[len(msg) - 1]
except IndexError:
await self.bot.say("Please provide the permissions you want to setup, the format for this must be in:\n"
"`perms add <command> <permission>`")
"`perms add <command> <permission>`")
return
# If a user can run a command, they have to have send_messages permissions; so use this as the base
if permissions.lower() == "none":

View file

@ -253,7 +253,8 @@ class Music:
except asyncio.TimeoutError:
await self.bot.say(
"Sorry, I couldn't connect! This can sometimes be caused by the server region you are in. "
"You can either try again, or try to change the server's region and see if that fixes the issue")
"You can either try again, or try to change the server's"
" region and see if that fixes the issue")
return False
# Return true if nothing has failed, so that we can invoke this, and ensure we succeeded
return True
@ -324,7 +325,7 @@ class Music:
@commands.command(pass_context=True, no_pm=True)
@checks.custom_perms(kick_members=True)
async def volume(self, ctx, value: int=None):
async def volume(self, ctx, value: int = None):
"""Sets the volume of the currently playing song."""
state = self.get_voice_state(ctx.message.server)