★ wanayoo — archive 1999 https://github.com/python-discord/code-jam-1/pull/8Nouvelle recherche | Portail wanayoo
Skip to content
This repository has been archived by the owner. It is now read-only.

Team 17 #8

Open
wants to merge 31 commits into
base: master
from
Open

Team 17 #8

wants to merge 31 commits into from

Conversation

@SharpBit
Copy link

@SharpBit SharpBit commented Mar 23, 2018 •

Teammate: @Volcyy

SharpBit added 2 commits Mar 23, 2018
glhf
Fix Pipfile dependencies
@gdude2002 gdude2002 changed the title just add some pass stuff Team 17 Mar 23, 2018
SharpBit added 5 commits 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

This comment has been minimized.

@gdude2002

gdude2002 Mar 23, 2018
Contributor

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

This comment has been minimized.

@gdude2002

gdude2002 Mar 23, 2018
Contributor

pass is not required if there's a docstring.

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

This comment has been minimized.

@gdude2002

gdude2002 Mar 23, 2018
Contributor

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

@gdude2002 gdude2002 commented Mar 23, 2018

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 Mar 23, 2018
- 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

This comment has been minimized.

@gdude2002

gdude2002 Mar 25, 2018
Contributor

No, this should be a comment.

log.info("Bot connected!")

self.bot.session = ClientSession(loop=self.bot.loop)

This comment has been minimized.

@gdude2002

gdude2002 Mar 25, 2018
Contributor

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.')

This comment has been minimized.

@gdude2002

gdude2002 Mar 25, 2018
Contributor

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

This comment has been minimized.

@SharpBit

SharpBit Mar 25, 2018
Author

you can make two on_ready events in two different files?

This comment has been minimized.

@gdude2002

gdude2002 Mar 25, 2018
Contributor

You sure can!

This comment has been minimized.

@SharpBit

SharpBit Mar 25, 2018
Author

what order will the bot perform the actions in?

This comment has been minimized.

@gdude2002

gdude2002 Mar 25, 2018
Contributor

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:

This comment has been minimized.

@gdude2002

gdude2002 Mar 25, 2018
Contributor

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'))

This comment has been minimized.

@gdude2002

gdude2002 Mar 25, 2018
Contributor

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

This comment has been minimized.

@SharpBit

SharpBit Mar 25, 2018
Author

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"),

This comment has been minimized.

@gdude2002

gdude2002 Mar 25, 2018
Contributor

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

This comment has been minimized.

@SharpBit

SharpBit Mar 25, 2018
Author

still mentionable /shrug

jchristgit and others added 5 commits Mar 25, 2018
- 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 Mar 25, 2018
This reverts commit 9edf8c9.
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 = {

This comment has been minimized.

@jb3

jb3 Mar 25, 2018
Member

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.'''

This comment has been minimized.

@jb3

jb3 Mar 25, 2018
Member

""" are preferred in docstrings over '''

This comment has been minimized.

@jb3

jb3 Mar 25, 2018
Member

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):
'''

This comment has been minimized.

@jb3

jb3 Mar 25, 2018
Member

Again, """ are preferred over '''

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

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.