This repository was archived by the owner on Mar 14, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 16
Team 23 #3
Open
aramperes
wants to merge
75
commits into
python-discord:master
Choose a base branch
from
aramperes:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Team 23 #3
Changes from 9 commits
Commits
Show all changes
75 commits
Select commit
Hold shift + click to select a range
7e308b9
Add team to readme
aramperes bd7dc5f
Merge pull request #1 from discord-python/master
Momothereal 5da9811
Add python snek and a bunch of todos
aramperes ce70e43
sad snek
aramperes 7ad4438
Remove unnecessary import
aramperes 40d4e0d
Move SnakeDef into a new file
aramperes 66bcd71
Newline at EOF
aramperes 4846889
snek it up
aramperes db3c1e2
scrape stuff from the internet
aramperes 9ee4dcc
Use image instead of thumbnail
aramperes 85a3658
Merge pull request #2 from momothereal/master
Momothereal 06ba0c6
underscores and pluses
aramperes c4e523b
barebones snake search
804f516
ITIS database scraping
aramperes d9ee4ab
Use JSON API when ITIS TSN is known
aramperes 005224c
working barebones search
eb22a95
Use aiohttp instead of wikipedia API
aramperes f650277
Remove wikipedia API
aramperes 988e181
Add doctext
aramperes 97c9549
Add todo for family
aramperes c6983df
Family & geography
aramperes 284593e
Add species suffix
aramperes bcaecbe
Merge pull request #3 from momothereal/momo-itis
Momothereal 5e34e15
snakeme template
acf9c97
Command snakes prefix
aramperes 3956d48
snakeme : retrieve messages from all channel
54f4d9f
Flake and query fixes
aramperes 80696c6
Ordering
aramperes 2c0347d
gets all messages in server, embed option
ad58f53
Snake rattles!
aramperes b1f78e2
Cleanup and comments
aramperes df73998
Simplify rattle file location
aramperes c011b73
CGI sneks using perlin noise
aramperes f77e0dc
before merge
c5ae223
merge for snakeme
81d9327
accidentally commited in progress command
c153fbd
Merge branch 'master' into rattle
Momothereal abd48a4
Sync piplock
aramperes d10c084
Merge pull request #4 from momothereal/rattle
Momothereal ae0b28a
Merge pull request #5 from discord-python/master
Momothereal 16c4a36
Snakes and Ladders - Initial work
aramperes 3adbc50
fixed snakeme, added hatching
d779f22
S&L rolling
aramperes ff0c19e
S&L with snakes and ladders
aramperes 80a8c0e
Fix prefixes
aramperes 8d6b0c9
Export board configuration to res, fixes.
aramperes 9b2112d
Merge pull request #8 from discord-python/master
Momothereal e944803
Merge branch 'master' into draw-sneks
Momothereal 24a6cf4
Merge pull request #6 from momothereal/draw-sneks
Momothereal 125b0ee
Sync piplock
aramperes efd8a40
Merge branch 'master' into ladders
Momothereal 0a7b7ad
Merge pull request #7 from momothereal/ladders
Momothereal f28ae2e
Merge branch 'master' into hatch
Momothereal 760a43e
Merge pull request #9 from momothereal/hatch
Momothereal e421513
Sync piplock
aramperes dd8e80d
Flake fixes
aramperes 73dbd63
Make S&L max players configurable
aramperes 6bebf63
Add libopus env variable
aramperes 16dd8c2
Make a fresh new readme file
aramperes 03aee14
Add note about libopus in readme
aramperes 2a30747
Simplify some for loops using iterators
aramperes 1f0e862
Fix hanging when player leaves
aramperes 181fc4b
Extract rattle config to res folder
aramperes 2355f5e
Readme: configuration for s&l and rattles
aramperes c3c9cd6
Store some common (yet scientifically incorrect) snek names in a file
aramperes e82a9d1
Random snakes!
aramperes db3d329
Another tox exception
aramperes f2b4c9a
Document random snakes/pickle-file in readme
aramperes 0a1367a
Fix wiki link (underscores)
aramperes 7b8d5a6
More adjustments and fixes to snek querying
aramperes 679abc1
Remove pass's, replace prints with logger, more documentation in snek…
aramperes 54e2dcb
Simplify snekfetcher instructions
aramperes e59546c
Change max sentences count to 2
aramperes 75bd290
Add docstring for draw command
aramperes 9af1e83
Capitalize instead of titling
aramperes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,29 @@ | ||
| # coding=utf-8 | ||
| import logging | ||
| from typing import Any, Dict | ||
|
|
||
| import discord | ||
| from discord.ext.commands import AutoShardedBot, Context, command | ||
|
|
||
| from bot.sneks.sneks import SnakeDef | ||
|
|
||
| log = logging.getLogger(__name__) | ||
|
|
||
| # the python snek | ||
| SNEK_PYTHON = SnakeDef( | ||
| common_name="Python", | ||
| species="Pseudo lingua", | ||
| image_url="https://momoperes.ca/files/pythonpls.png", | ||
| family="sneks-that-byte", | ||
| genus="\"Programming Language\"", | ||
| short_description="python is a language that you learn because tensorflow has an API for it", | ||
| wiki_link="https://en.wikipedia.org/wiki/Pseudocode" | ||
| ) | ||
|
|
||
| # consolation snek :( | ||
| SNEK_SAD = discord.Embed() | ||
| SNEK_SAD.title = "sad snek :(" | ||
| SNEK_SAD.set_image(url="https://momoperes.ca/files/sadsnek.jpeg") | ||
|
|
||
|
|
||
| class Snakes: | ||
| """ | ||
|
|
@@ -15,33 +33,24 @@ class Snakes: | |
| def __init__(self, bot: AutoShardedBot): | ||
| self.bot = bot | ||
|
|
||
| async def get_snek(self, name: str = None) -> Dict[str, Any]: | ||
| """ | ||
| Go online and fetch information about a snake | ||
|
|
||
| The information includes the name of the snake, a picture of the snake, and various other pieces of info. | ||
| What information you get for the snake is up to you. Be creative! | ||
| async def get_snek(self, name: str = None) -> SnakeDef: | ||
|
||
| if name is not None and name.lower() == "python": | ||
| # return info about language | ||
| return SNEK_PYTHON | ||
|
|
||
| If "python" is given as the snake name, you should return information about the programming language, but with | ||
| all the information you'd provide for a real snake. Try to have some fun with this! | ||
|
|
||
| :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 | ||
| """ | ||
| # todo: find a random snek online if there name is null | ||
| # todo: scrape the web to find the lost sneks | ||
|
|
||
| @command() | ||
| async def get(self, ctx: Context, name: str = None): | ||
| """ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also now missing a docstring. This one's important as it shows help text to the user. |
||
| Go online and fetch information about a snake | ||
|
|
||
| This should make use of your `get_snek` method, using it to get information about a snake. This information | ||
| should be sent back to Discord in an embed. | ||
|
|
||
| :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 | ||
| """ | ||
|
|
||
| # Any additional commands can be placed here. Be creative, but keep it to a reasonable amount! | ||
| # fetch data for a snek | ||
| await ctx.send("Fetching data for " + name + "..." if name is not None else "Finding a random snek!") | ||
| data = await self.get_snek(name) | ||
| if data is None: | ||
| await ctx.send("sssorry I can't find that snek :(", embed=SNEK_SAD) | ||
| return | ||
| channel: discord.TextChannel = ctx.channel | ||
| await channel.send(embed=data.as_embed()) | ||
|
|
||
|
|
||
| def setup(bot): | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| # coding=utf-8 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import discord | ||
|
|
||
|
|
||
| class SnakeDef: | ||
| """ | ||
| Represents a snek | ||
| """ | ||
|
|
||
| def __init__(self, common_name, species, image_url, family, genus, short_description, wiki_link): | ||
| self.common_name = common_name | ||
| self.species = species | ||
| self.image_url = image_url | ||
| self.family = family | ||
| self.genus = genus | ||
| self.short_description = short_description | ||
| self.wiki_link = wiki_link | ||
|
|
||
| def as_embed(self): | ||
| # returns a discord embed with the snek | ||
| embed = discord.Embed() | ||
| embed.title = self.species + " (" + self.common_name + ")" | ||
| embed.colour = discord.Colour.green() | ||
| embed.url = self.wiki_link | ||
| embed.add_field(name="Family", value=self.family) | ||
| embed.add_field(name="Genus", value=self.genus) | ||
| embed.add_field(name="Species", value=self.species) | ||
| embed.set_image(url=self.image_url) | ||
| embed.description = self.short_description | ||
| return embed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤣