Skip to content
This repository was archived by the owner on Mar 14, 2021. It is now read-only.
Open
Show file tree
Hide file tree
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 Mar 23, 2018
bd7dc5f
Merge pull request #1 from discord-python/master
Momothereal Mar 23, 2018
5da9811
Add python snek and a bunch of todos
aramperes Mar 23, 2018
ce70e43
sad snek
aramperes Mar 23, 2018
7ad4438
Remove unnecessary import
aramperes Mar 23, 2018
40d4e0d
Move SnakeDef into a new file
aramperes Mar 23, 2018
66bcd71
Newline at EOF
aramperes Mar 23, 2018
4846889
snek it up
aramperes Mar 23, 2018
db3c1e2
scrape stuff from the internet
aramperes Mar 23, 2018
9ee4dcc
Use image instead of thumbnail
aramperes Mar 23, 2018
85a3658
Merge pull request #2 from momothereal/master
Momothereal Mar 23, 2018
06ba0c6
underscores and pluses
aramperes Mar 23, 2018
c4e523b
barebones snake search
Mar 23, 2018
804f516
ITIS database scraping
aramperes Mar 23, 2018
d9ee4ab
Use JSON API when ITIS TSN is known
aramperes Mar 23, 2018
005224c
working barebones search
Mar 23, 2018
eb22a95
Use aiohttp instead of wikipedia API
aramperes Mar 23, 2018
f650277
Remove wikipedia API
aramperes Mar 23, 2018
988e181
Add doctext
aramperes Mar 23, 2018
97c9549
Add todo for family
aramperes Mar 23, 2018
c6983df
Family & geography
aramperes Mar 23, 2018
284593e
Add species suffix
aramperes Mar 23, 2018
bcaecbe
Merge pull request #3 from momothereal/momo-itis
Momothereal Mar 23, 2018
5e34e15
snakeme template
Mar 23, 2018
acf9c97
Command snakes prefix
aramperes Mar 23, 2018
3956d48
snakeme : retrieve messages from all channel
Mar 23, 2018
54f4d9f
Flake and query fixes
aramperes Mar 23, 2018
80696c6
Ordering
aramperes Mar 23, 2018
2c0347d
gets all messages in server, embed option
Mar 23, 2018
ad58f53
Snake rattles!
aramperes Mar 24, 2018
b1f78e2
Cleanup and comments
aramperes Mar 24, 2018
df73998
Simplify rattle file location
aramperes Mar 24, 2018
c011b73
CGI sneks using perlin noise
aramperes Mar 24, 2018
f77e0dc
before merge
Mar 24, 2018
c5ae223
merge for snakeme
Mar 24, 2018
81d9327
accidentally commited in progress command
Mar 24, 2018
c153fbd
Merge branch 'master' into rattle
Momothereal Mar 24, 2018
abd48a4
Sync piplock
aramperes Mar 24, 2018
d10c084
Merge pull request #4 from momothereal/rattle
Momothereal Mar 24, 2018
ae0b28a
Merge pull request #5 from discord-python/master
Momothereal Mar 24, 2018
16c4a36
Snakes and Ladders - Initial work
aramperes Mar 24, 2018
3adbc50
fixed snakeme, added hatching
Mar 24, 2018
d779f22
S&L rolling
aramperes Mar 24, 2018
ff0c19e
S&L with snakes and ladders
aramperes Mar 24, 2018
80a8c0e
Fix prefixes
aramperes Mar 24, 2018
8d6b0c9
Export board configuration to res, fixes.
aramperes Mar 24, 2018
9b2112d
Merge pull request #8 from discord-python/master
Momothereal Mar 24, 2018
e944803
Merge branch 'master' into draw-sneks
Momothereal Mar 24, 2018
24a6cf4
Merge pull request #6 from momothereal/draw-sneks
Momothereal Mar 24, 2018
125b0ee
Sync piplock
aramperes Mar 24, 2018
efd8a40
Merge branch 'master' into ladders
Momothereal Mar 24, 2018
0a7b7ad
Merge pull request #7 from momothereal/ladders
Momothereal Mar 24, 2018
f28ae2e
Merge branch 'master' into hatch
Momothereal Mar 25, 2018
760a43e
Merge pull request #9 from momothereal/hatch
Momothereal Mar 25, 2018
e421513
Sync piplock
aramperes Mar 25, 2018
dd8e80d
Flake fixes
aramperes Mar 25, 2018
73dbd63
Make S&L max players configurable
aramperes Mar 25, 2018
6bebf63
Add libopus env variable
aramperes Mar 25, 2018
16dd8c2
Make a fresh new readme file
aramperes Mar 25, 2018
03aee14
Add note about libopus in readme
aramperes Mar 25, 2018
2a30747
Simplify some for loops using iterators
aramperes Mar 25, 2018
1f0e862
Fix hanging when player leaves
aramperes Mar 25, 2018
181fc4b
Extract rattle config to res folder
aramperes Mar 25, 2018
2355f5e
Readme: configuration for s&l and rattles
aramperes Mar 25, 2018
c3c9cd6
Store some common (yet scientifically incorrect) snek names in a file
aramperes Mar 25, 2018
e82a9d1
Random snakes!
aramperes Mar 25, 2018
db3d329
Another tox exception
aramperes Mar 25, 2018
f2b4c9a
Document random snakes/pickle-file in readme
aramperes Mar 25, 2018
0a1367a
Fix wiki link (underscores)
aramperes Mar 25, 2018
7b8d5a6
More adjustments and fixes to snek querying
aramperes Mar 25, 2018
679abc1
Remove pass's, replace prints with logger, more documentation in snek…
aramperes Mar 25, 2018
54e2dcb
Simplify snekfetcher instructions
aramperes Mar 25, 2018
e59546c
Change max sentences count to 2
aramperes Mar 25, 2018
75bd290
Add docstring for draw command
aramperes Mar 25, 2018
9af1e83
Capitalize instead of titling
aramperes Mar 25, 2018
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
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Code Jam 1
# Code Jam 1 - Team 23

**This is the code jam entry for Momo & kel**

This is the repository for all code relating to our first code jam, in March 2018. Participants should fork this repository, and submit their code in a pull request.

Expand Down
57 changes: 33 additions & 24 deletions bot/cogs/snakes.py
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"
Copy link
Member

Choose a reason for hiding this comment

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

🤣

)

# consolation snek :(
SNEK_SAD = discord.Embed()
SNEK_SAD.title = "sad snek :("
SNEK_SAD.set_image(url="https://momoperes.ca/files/sadsnek.jpeg")


class Snakes:
"""
Expand All @@ -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:
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you guys are missing a docstring :P

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):
"""
Copy link
Contributor

Choose a reason for hiding this comment

The 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):
Expand Down
1 change: 1 addition & 0 deletions bot/sneks/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# coding=utf-8
29 changes: 29 additions & 0 deletions bot/sneks/sneks.py
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
2 changes: 1 addition & 1 deletion run.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
">>> ", ">> ", "> ",
">>>", ">>", ">"
), # Order matters (and so do commas)
activity=Game(name="Help: bot.help()"),
activity=Game(name="snek it up"),
help_attrs={"aliases": ["help()"]},
formatter=Formatter()
)
Expand Down