Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions advgoogle/advgoogle.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,7 @@ async def images(self, ctx, images: bool = False):
unicoded = test.decode("unicode_escape")
query_find = self.regex[0].findall(unicoded)
try:
if images:
url = choice(query_find)
elif not images:
url = query_find[0]
url = choice(query_find) if images else query_find[0]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function AdvancedGoogle.images refactored with the following changes:

error = False
except IndexError:
error = True
Expand Down
66 changes: 27 additions & 39 deletions emote/emote.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async def set(self, ctx):
else:
self.servers[server.id]["status"] = not self.servers[server.id]["status"]
if "emotes" not in self.servers[server.id]:
self.servers[server.id]["emotes"] = dict()
self.servers[server.id]["emotes"] = {}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Emote.set refactored with the following changes:

dataIO.save_json(self.data_path, self.servers)
# for a toggle, settings should save here in case bot fails to send message
if self.servers[server.id]["status"]:
Expand All @@ -69,7 +69,7 @@ async def add(self, ctx, name, url):
# default off
self.servers[server.id] = dict({"status": False})
if "emotes" not in self.servers[server.id]:
self.servers[server.id]["emotes"] = dict()
self.servers[server.id]["emotes"] = {}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Emote.add refactored with the following changes:

dataIO.save_json(self.data_path, self.servers)
if not url.endswith((".gif", ".gifv", ".png")):
await self.bot.say("Links ending in .gif, .png, and .gifv are the only ones accepted."
Expand Down Expand Up @@ -108,7 +108,7 @@ async def remove(self, ctx, name):
# default off
self.servers[server.id] = dict({"status": False})
if "emotes" not in self.servers[server.id]:
self.servers[server.id]["emotes"] = dict()
self.servers[server.id]["emotes"] = {}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Emote.remove refactored with the following changes:

dataIO.save_json(self.data_path, self.servers)
if name in self.servers[server.id]["emotes"]:
os.remove(self.emote+self.servers[server.id]["emotes"][name])
Expand Down Expand Up @@ -136,7 +136,7 @@ async def edit(self, ctx, name, newname):
# default off
self.servers[server.id] = dict({"status": False})
if "emotes" not in self.servers[server.id]:
self.servers[server.id]["emotes"] = dict()
self.servers[server.id]["emotes"] = {}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Emote.edit refactored with the following changes:

dataIO.save_json(self.data_path, self.servers)
if newname in self.servers[server.id]["emotes"]:
await self.bot.say("This keyword already exists, please use another keyword.")
Expand Down Expand Up @@ -172,7 +172,7 @@ async def list(self, ctx, style):
# default off
self.servers[server.id] = dict({"status": False})
if "emotes" not in self.servers[server.id]:
self.servers[server.id]["emotes"] = dict()
self.servers[server.id]["emotes"] = {}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Emote.list refactored with the following changes:

dataIO.save_json(self.data_path, self.servers)
istyles = sorted(self.servers[server.id]["emotes"])
if not istyles:
Expand All @@ -189,7 +189,7 @@ async def list(self, ctx, style):
istyle = []
for i in range(len(istyles)):
ist = re.findall("\\b"+style+"\\w+", istyles[i])
istyle = istyle + ist
istyle += ist
style = 10
else:
await self.bot.say("Your list style is not correct, please use one"
Expand All @@ -202,16 +202,13 @@ async def list(self, ctx, style):
if style <= count:
y = s.join(istyle[:style])
await self.bot.say("List of available emotes:\n{}".format(y))
if style > len(istyle):
return
style += count
elif style > count:
else:
style2 = style - count
y = s.join(istyle[style2:style])
await self.bot.say("Continuation:\n{}".format(y))
if style > len(istyle):
return
style += count
if style > len(istyle):
return
style += count
await self.bot.say("Do you want to continue seeing the list? Yes/No")
answer = await self.bot.wait_for_message(timeout=15,
author=ctx.message.author)
Expand Down Expand Up @@ -242,20 +239,18 @@ async def compare(self, ctx, style, alls: str=None):
# default off
self.servers[server.id] = dict({"status": False})
if "emotes" not in self.servers[server.id]:
self.servers[server.id]["emotes"] = dict()
self.servers[server.id]["emotes"] = {}
dataIO.save_json(self.data_path, self.servers)
if style not in styleset:
return
msg = "Keywords deleted due to missing files in the emotes list:\n"
c = list()
for entry in os.scandir(self.emote):
c.append(entry.name)
c = [entry.name for entry in os.scandir(self.emote)]
if style == styleset[0]:
msg = "Keywords deleted due to missing files in the emotes list:\n"
if alls == "all":
servers = sorted(self.servers)
servers.remove("emote")
for servs in servers:
missing = list()
missing = []
Comment on lines -245 to +253
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Emote.compare refactored with the following changes:

istyles = sorted(self.servers[servs]["emotes"])
for n in istyles:
cat = "|".join(c)
Expand All @@ -282,16 +277,13 @@ async def compare(self, ctx, style, alls: str=None):
if style <= 10:
y = s.join(missing[:style])
await self.bot.say(msg + y)
if style >= len(missing):
break
style += 10
elif style > 10:
else:
style2 = style - 10
y = s.join(missing[style2:style])
await self.bot.say("Continuation:\n{}".format(y))
if style >= len(missing):
break
style += 10
if style >= len(missing):
break
style += 10
await self.bot.say("Do you want to continue seeing the list? Yes/No")
answer = await self.bot.wait_for_message(timeout=15,
author=ctx.message.author)
Expand Down Expand Up @@ -325,16 +317,13 @@ async def compare(self, ctx, style, alls: str=None):
if style <= 10:
y = s.join(missing[:style])
await self.bot.say(msg + y)
if style >= len(missing):
return
style += 10
elif style > 10:
else:
style2 = style - 10
y = s.join(missing[style2:style])
await self.bot.say("Continuation:\n{}".format(y))
if style >= len(missing):
return
style += 10
if style >= len(missing):
return
style += 10
await self.bot.say("Do you want to continue seeing the list? Yes/No")
answer = await self.bot.wait_for_message(timeout=15,
author=ctx.message.author)
Expand Down Expand Up @@ -416,13 +405,13 @@ async def check_emotes(self, message):
# default off
self.servers[server.id] = dict({"status": False})
if "emotes" not in self.servers[server.id]:
self.servers[server.id]["emotes"] = dict()
self.servers[server.id]["emotes"] = {}
dataIO.save_json(self.data_path, self.servers)
# emotes is off, so ignore
if "status" not in self.servers[server.id]:
self.servers[server.id] = dict({"status": False})
if "emotes" not in self.servers[server.id]:
self.servers[server.id]["emotes"] = dict()
self.servers[server.id]["emotes"] = {}
Comment on lines -419 to +414
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Emote.check_emotes refactored with the following changes:

dataIO.save_json(self.data_path, self.servers)
if not self.servers[server.id]["status"]:
return
Expand Down Expand Up @@ -478,12 +467,11 @@ def check_folders():


def check_files():
# create server.json if not there
# put in default values
default = {}
default['emote'] = 'data/emote/images/'
if not os.path.isfile('data/emote/servers.json'):
print('Creating default emote servers.json...')
# create server.json if not there
# put in default values
default = {'emote': 'data/emote/images/'}
Comment on lines -481 to +474
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function check_files refactored with the following changes:

dataIO.save_json('data/emote/servers.json', default)


Expand Down
4 changes: 2 additions & 2 deletions geico/geico.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ async def _bash(self, ctx, num: int=1):
if num > 5:
num = 5
await self.bot.reply("Heck naw brah. 5 is max. Any more and you get killed.")
for i in range(num):
for _ in range(num):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Geico._bash refactored with the following changes:

async with aiohttp.request("GET", 'http://bash.org/?random') as resp:
test = str(await resp.text())
subs = re.findall(regex[0], test)
Expand Down Expand Up @@ -49,7 +49,7 @@ async def _quotes(self, ctx, *, author: str):
async with aiohttp.request("GET", url) as resp:
test = str(await resp.text())
quote_find = list(set(re.findall(regex, test)))
for i in range(number):
for _ in range(number):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Geico._quotes refactored with the following changes:

random_quote = choice(quote_find)
quote_find.remove(random_quote)
while random_quote == title:
Expand Down
8 changes: 4 additions & 4 deletions horoscope/horoscope.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,14 @@ def getchinese_signs(self, year):
@commands.cooldown(10, 60, commands.BucketType.user)
async def _cookie(self):
"""Retrieves a random fortune cookie fortune."""
regex = ["class=\"cookie-link\">([^`]*?)<\/a>", "<p>([^`]*?)<\/p>",
"(?:\\\\['])", "<strong>([^`]*?)<\/strong>",
"<\/strong><\/a>([^`]*?)<br>",
"3\)<\/strong><\/a>([^`]*?)<\/div>"]
url = "http://www.fortunecookiemessage.com"
await self.file_check()
async with self.session.get(url, headers={"encoding": "utf-8"}) as resp:
test = str(await resp.text())
regex = ["class=\"cookie-link\">([^`]*?)<\/a>", "<p>([^`]*?)<\/p>",
"(?:\\\\['])", "<strong>([^`]*?)<\/strong>",
"<\/strong><\/a>([^`]*?)<br>",
"3\)<\/strong><\/a>([^`]*?)<\/div>"]
Comment on lines -141 to +148
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Horoscope._cookie refactored with the following changes:

fortune = re.findall(regex[0], test)
fortest = re.match("<p>", fortune[0])
if fortest is not None:
Expand Down
2 changes: 1 addition & 1 deletion longcat/longcat.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ async def cat(self, ctx):
the_cat = [Image.open(self.path + "butt.png")]
trunk = Image.open(self.path + "trunk.png")
head = Image.open(self.path + "head.png")
for i in range(len_cat-1):
for _ in range(len_cat-1):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Longcat.cat refactored with the following changes:

the_cat.append(trunk)
the_cat.append(head)
widths, heights = zip(*(i.size for i in the_cat))
Expand Down
8 changes: 4 additions & 4 deletions loot/loot.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ async def remove(self, ctx, name: str, char: str=None):
elif char in self.db[server.id][name]:
del self.db[server.id][name][char]
dataIO.save_json("data/loot/servers.json", self.db)
await self.bot.say("{} has been removed".format(char if char else name))
await self.bot.say("{} has been removed".format(char or name))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Loot.remove refactored with the following changes:



def check_folders():
Expand All @@ -107,11 +107,11 @@ def check_folders():


def check_files():
# create servers.json if not there
# put in default values
default = {}
if not os.path.isfile('data/loot/servers.json'):
print('Creating default loot servers.json...')
# create servers.json if not there
# put in default values
default = {}
Comment on lines -110 to +114
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function check_files refactored with the following changes:

dataIO.save_json('data/loot/servers.json', default)


Expand Down
19 changes: 8 additions & 11 deletions lootbox/lootbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,12 @@ async def add(self, ctx, name: str, content: str, multi: int=None):
content = content.split(", ")
elif "," in content:
content = content.split(",")
if multi < 0:
neg = True
multi = abs(multi)
if multi and type(content) is not list:
if multi < 0:
neg = True
multi = abs(multi)
content = [content.lower()] * multi
else:
if multi < 0:
neg = True
multi = abs(multi)
Comment on lines +43 to -51
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Lootbox.add refactored with the following changes:

content = content * multi
print(content)
for x in content:
Expand Down Expand Up @@ -140,7 +137,7 @@ async def append(self, ctx, name: str, items: str):
Names are fixed when they are added."""
server = ctx.message.server
items = items.split(", ")
itemis = dict()
itemis = {}
Comment on lines -143 to +140
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Lootbox.append refactored with the following changes:

for item in items:
item, value = item.split(" ")
item = item.replace("_", " ").lower()
Expand Down Expand Up @@ -171,7 +168,7 @@ async def remove(self, ctx, name: str, items: str):
Names are fixed when they are added."""
server = ctx.message.server
items = items.split(", ")
itemis = dict()
itemis = {}
Comment on lines -174 to +171
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Lootbox.remove refactored with the following changes:

for item in items:
item, value = item.split(" ")
item = item.replace("_", " ").lower()
Expand Down Expand Up @@ -293,11 +290,11 @@ def check_folders():


def check_files():
# create servers.json if not there
# put in default values
default = {}
if not os.path.isfile('data/lootbox/servers.json'):
print('Creating default lootbox servers.json...')
# create servers.json if not there
# put in default values
default = {}
Comment on lines -296 to +297
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function check_files refactored with the following changes:

dataIO.save_json('data/lootbox/servers.json', default)


Expand Down
Loading