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 7 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
b312786
just add some pass stuff
SharpBit Mar 23, 2018
31fe5d8
Merge pull request #1 from discord-python/master
SharpBit Mar 23, 2018
f92cf5e
some startup stuff
SharpBit Mar 23, 2018
d04759c
Merge branch 'master' of https://github.com/SharpBit/code-jam-1
SharpBit Mar 23, 2018
91cfb2d
fix bs4 req
SharpBit Mar 23, 2018
6dd7aef
remove that
SharpBit Mar 23, 2018
c865044
right thing to run
SharpBit Mar 23, 2018
e830c95
create the soup from the info source
SharpBit Mar 23, 2018
80273f6
rough estimate of what it should look like
SharpBit Mar 24, 2018
36ace30
@pikuhana can u do something
SharpBit Mar 24, 2018
9816692
Merge pull request #2 from discord-python/master
SharpBit Mar 24, 2018
2d743c8
Use image from OGP tag, remove unused methods.
jchristgit Mar 24, 2018
b77b7fe
test
SharpBit Mar 24, 2018
49f5251
Merge branch 'master' of https://github.com/SharpBit/code-jam-1
SharpBit Mar 24, 2018
f915d90
image (most work) and description
SharpBit Mar 24, 2018
a552543
Attach URL and location map.
jchristgit Mar 24, 2018
3234d57
did you know command
SharpBit Mar 25, 2018
3f56b6c
remove map image for now
SharpBit Mar 25, 2018
dfd3175
if python: send language
SharpBit Mar 25, 2018
0ff0f42
Fix location map image URL.
jchristgit Mar 25, 2018
ddc6e4e
Still more bugs...
SharpBit Mar 25, 2018
9edf8c9
Added a TicTacToe game stub.
jchristgit Mar 25, 2018
97e0e9d
fix some requests and travis stuff
SharpBit Mar 25, 2018
adafa48
redo the bot.get python
SharpBit Mar 25, 2018
7033463
Revert "Added a TicTacToe game stub."
jchristgit Mar 25, 2018
cca57c4
completely remove
SharpBit Mar 25, 2018
3f91775
fix flake8 linting import order
SharpBit Mar 25, 2018
b712a24
map region works all the time!
SharpBit Mar 25, 2018
5850ddb
success rate of images has gone up!
SharpBit Mar 25, 2018
256d4e1
fix flake8
SharpBit Mar 25, 2018
0854cb1
fix requested changes
SharpBit 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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# config
config.json

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
7 changes: 7 additions & 0 deletions bot/cogs/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ def __init__(self, bot: AutoShardedBot):
self.bot = bot

async def on_ready(self):
log.info('Signed in as:')
log.info('--------------')
log.info(f'Username: {self.bot.user.name}')
log.info(f'User ID: {self.bot.user.id}')
log.info('--------------')
log.info('Serving Team 17 in Code Jam 1!')
log.info('--------------')
log.info("Bot connected!")


Expand Down
5 changes: 4 additions & 1 deletion bot/cogs/snakes.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# coding=utf-8
import logging
from typing import Any, Dict

from bs4 import BeautifulSoup
from discord.ext.commands import AutoShardedBot, Context, command

log = logging.getLogger(__name__)
Expand All @@ -14,6 +14,7 @@ class Snakes:

def __init__(self, bot: AutoShardedBot):
self.bot = bot
self.base_url = 'http://www.softschools.com/facts/animals/'

async def get_snek(self, name: str = None) -> Dict[str, Any]:
"""
Expand All @@ -28,6 +29,7 @@ async def get_snek(self, name: str = None) -> Dict[str, Any]:
: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
Copy Markdown
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.


@command()
async def get(self, ctx: Context, name: str = None):
Expand All @@ -40,6 +42,7 @@ async def get(self, ctx: Context, name: str = None):
: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
Copy Markdown
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.


# Any additional commands can be placed here. Be creative, but keep it to a reasonable amount!

Expand Down
10 changes: 9 additions & 1 deletion run.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# coding=utf-8
import os
import json

from aiohttp import AsyncResolver, ClientSession, TCPConnector

Expand Down Expand Up @@ -35,6 +36,13 @@
# Commands, etc
bot.load_extension("bot.cogs.snakes")

bot.run(os.environ.get("BOT_TOKEN"))
try:
with open('config.json') as f:
config = json.load(f)
token = config.get('bot_token')
except FileNotFoundError:
print('No token found.')
else:
bot.run(token)
Copy link
Copy Markdown
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.


bot.http_session.close() # Close the aiohttp session when the bot finishes running