Skip to content
This repository was archived by the owner on Mar 14, 2021. It is now read-only.

Team 17 #8

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open

Team 17 #8

wants to merge 31 commits into from

Conversation

SharpBit
Copy link

@SharpBit SharpBit commented Mar 23, 2018

Teammate: @Volcyy

@gdude2002 gdude2002 changed the title just add some pass stuff Team 17 Mar 23, 2018
@@ -28,6 +29,7 @@ def __init__(self, bot: AutoShardedBot):
:param name: Optional, the name of the snake to get information for - omit for a random snake
:return: A dict containing information on a snake
"""
pass
Copy link
Contributor

Choose a reason for hiding this comment

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

pass is not required if there's a docstring.

@@ -40,6 +42,7 @@ def __init__(self, bot: AutoShardedBot):
:param ctx: Context object passed from discord.py
:param name: Optional, the name of the snake to get information for - omit for a random snake
"""
pass
Copy link
Contributor

Choose a reason for hiding this comment

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

pass is not required if there's a docstring.

run.py Outdated
except FileNotFoundError:
print('No token found.')
else:
bot.run(token)
Copy link
Contributor

Choose a reason for hiding this comment

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

No, this whole block is incorrect. Don't run the bot this way. Read over the doc/ folder in the repository again, it explains exactly how you should be doing this.

@gdude2002
Copy link
Contributor

Your build is currently failing.

./run.py:2:1: F401 'os' imported but unused
./run.py:3:1: I100 Import statements are in the wrong order. 'import json' should be before 'import os'
./bot/cogs/snakes.py:4:1: F401 'bs4.BeautifulSoup' imported but unused
./bot/cogs/snakes.py:4:1: I201 Missing newline between import groups. 'from bs4 import BeautifulSoup' is identified as Third Party and 'from typing import Any, Dict' is identified as Stdlib.
./bot/cogs/snakes.py:5:1: I201 Missing newline between import groups. 'from discord.ext.commands import AutoShardedBot, Context, command' is identified as Third Party and 'from bs4 import BeautifulSoup' is identified as Third Party.

SharpBit and others added 12 commits March 23, 2018 18:43
- Fix the way the bot is run to match with the docs (including removing `config.json` from the `.gitignore` file
- Create the bot's session and response from the info source
- update the info source and functions to easily get info
- add dependencies (bs4 and lxml)
- still have to remove html tags
- fix image url to actually work
- move image to the embed's image function
- region picture to thumbnail
- more info
[UPDATE] Ignored a silly rule from flake8.
So far these don't return an image:
- bullsnake
- ringneck snake
- puff adder
- still ussues with the snek map image url
- see the comments in L14-16 in bot/cogs/snakes.py
- add command aliases
- until we get a fix
- proper css selector
- correct link
- if apostrophe: remove it
# used in `children's python`
.gitignore Outdated
@@ -1,4 +1,4 @@
# Byte-compiled / optimized / DLL files
Byte-compiled / optimized / DLL files
Copy link
Contributor

Choose a reason for hiding this comment

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

No, this should be a comment.

log.info("Bot connected!")

self.bot.session = ClientSession(loop=self.bot.loop)
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't do that, this should be done in the cog itself and set on self.

for i, snek in enumerate(self.bot.sneks):
self.bot.sneks[i] = snek.replace('\u200b', '').replace('\ufeff', '')

log.info('Snakes loaded.')
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the logging cog. If you need to do stuff on_ready, do it in your cog.

Copy link
Author

Choose a reason for hiding this comment

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

you can make two on_ready events in two different files?

Copy link
Contributor

Choose a reason for hiding this comment

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

You sure can!

Copy link
Author

Choose a reason for hiding this comment

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

what order will the bot perform the actions in?

Copy link
Contributor

Choose a reason for hiding this comment

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

No idea. You shouldn't rely on that.

@@ -28,9 +83,56 @@ def __init__(self, bot: AutoShardedBot):
:param name: Optional, the name of the snake to get information for - omit for a random snake
:return: A dict containing information on a snake
"""
if name:
if name not in self.bot.sneks:
Copy link
Contributor

Choose a reason for hiding this comment

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

This, again, should be an attribute on your cog, not the bot.

run.py Outdated
@@ -35,6 +35,6 @@
# Commands, etc
bot.load_extension("bot.cogs.snakes")

bot.run(os.environ.get("BOT_TOKEN"))
bot.run(os.environ.get('BOT_TOKEN'))
Copy link
Contributor

Choose a reason for hiding this comment

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

Haha, come on, no need to change the quote marks.

Copy link
Author

Choose a reason for hiding this comment

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

i use single quotes, just that i accidentally did the config.json stuff before so when i changed it back i naturally used single quotes

@@ -16,7 +16,7 @@
">>> ", ">> ", "> ",
">>>", ">>", ">"
), # Order matters (and so do commas)
activity=Game(name="Help: bot.help()"),
activity=Game(name="with snekky sneks"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably a bit user-unfriendly, but it's fine in this case. :P

Copy link
Author

Choose a reason for hiding this comment

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

still mentionable /shrug

jchristgit and others added 5 commits March 25, 2018 13:20
- the stupid image that changes divs
- that causes some commands for snakes to be broken (IndexError)
- some snakes still don't show with an image (cut-off html?)
- remove unnecessary import
- added it to on_ready in seperate cog
- cog attribute, not bot attribute
- fix accidental `.gitignore` change
- tic tac toe uses python emoji
- update tic tac toe board
less clutter in the actual command
jchristgit and others added 6 commits March 25, 2018 18:35
loops through the possible divs
- this site's html is like anti-webscrape
- no one cares about the eastern brown snake
- i put `for x in range(1, 7)`, but for some reason it's not doing the 1?
- only 1 issue so far but as i already said, no one cares about the eastern brown snake so screw that
@@ -15,6 +30,62 @@ class Snakes:
def __init__(self, bot: AutoShardedBot):
self.bot = bot

PYTHON_INFO = {
Copy link
Member

Choose a reason for hiding this comment

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

This probably shouldn't be a class variable, but a module variable declared above class declaration.

return em

def format_info(self, data, color=discord.Color.green()):
'''Formats the info with the given data.'''
Copy link
Member

Choose a reason for hiding this comment

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

""" are preferred in docstrings over '''

Copy link
Member

Choose a reason for hiding this comment

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

Not required, but some documentation for the parameters would be nice, maybe some type annotations at the least to say what data should be.

# Any additional commands can be placed here. Be creative, but keep it to a reasonable amount!
@command(aliases=['getsnekfact', 'snekfact()', 'get_snek_fact()'])
async def snekfact(self, ctx: Context):
'''
Copy link
Member

Choose a reason for hiding this comment

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

Again, """ are preferred over '''

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants