Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snake cog #78

Merged
merged 32 commits into from
May 19, 2018
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
2360f21
Added the random_snake_name feature, created by Iceman
Apr 27, 2018
c8c5cca
Added Antidote to the snake_cog.
Apr 28, 2018
a9293e9
Add the snake quiz from Team 7 - Mushy and Cardium - to the snakes co…
Wim-De-Clercq May 10, 2018
514a17f
Cleaned up the snake quiz
May 10, 2018
2375290
Cleaning up snake_quiz further and integrating it towards the new API…
May 10, 2018
55eec4e
Bugfixes for Antidote and Quiz
May 10, 2018
01e04af
Implemented the zzzen of pythhhon, by prithaj and andrew.
May 12, 2018
36f2de7
Added the snake facts feature by Andrew and Prithaj. Also cleaned up …
May 12, 2018
5bcb305
Implemented the snake_videos feature. Also made a fix for a bug with …
May 12, 2018
c6acf33
Merge branch 'master' into snake_cog
lemonsaurus May 13, 2018
c5cf21e
Implemented Momo and kel's snake perlin noise gen draw feature
May 13, 2018
5b3535f
Implemented the hatch feature from Momo and Kels PR
May 13, 2018
9c14d52
Implemented the snakemefeature from the momo and kel PR, with big mod…
May 14, 2018
4f4f45f
Started on Snakes and Ladders, but want to refactor it to use reactio…
May 14, 2018
bdda2a8
Movie command, initial version
gdude2002 May 14, 2018
1a6c194
Snakes and Ladders implemented and rewritten to use reactions for con…
May 14, 2018
0244dbd
Merge branch 'snake_cog' of github.com:discord-python/bot into snake_cog
May 14, 2018
9a7a2aa
made the snek draw feature even more fabulous.
May 14, 2018
701547d
SAL, get_snek, perlin
May 14, 2018
1aba2d9
Fixing some minor problems with startup log spam. The bot will now on…
May 15, 2018
68e8a69
Merging master for some bugfixes
May 15, 2018
1b81818
Pointed all relevant functions at their respective snake API endpoint…
May 15, 2018
d8572e8
Added the guessing game by Ava and eivl
May 15, 2018
1a179ec
Trailing comma, baby
May 15, 2018
b261043
Added snake cards.
May 15, 2018
2e9c3e9
Added the snakes.about command, and cleaned up the cog. Still got a c…
May 16, 2018
cba9e30
Merge branch 'master' into snake_cog
lemonsaurus May 16, 2018
d784ca0
Some fixes for the snake cards. Cards now use the converter on the sn…
May 18, 2018
1f19b28
Some fixes to address Volcyy's review.
May 18, 2018
cb3d110
Merge branch 'snake_cog' of github.com:discord-python/bot into snake_cog
May 18, 2018
18663a7
Addressing comments by gdude on the site PR
May 18, 2018
9f5f0ce
Changes requested by Joseph
May 19, 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
2 changes: 2 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ logmatic-python = "*"
aiohttp = "<2.3.0,>=2.0.0"
websockets = ">=4.0,<5.0"
yarl = "==1.1.1"
fuzzywuzzy = "*"
python-levenshtein = "*"

[dev-packages]
"flake8" = "*"
Expand Down
23 changes: 19 additions & 4 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ def parse_python(buffer_pos):

# Args handling
new_args = []

if args:
# Force args into container
if not isinstance(args, tuple):
Expand Down Expand Up @@ -227,6 +228,7 @@ def parse_python(buffer_pos):

# Iterate through the buffer and determine
pos = 0
current = None
while not self.eof:
try:
current = self.buffer[self.index + pos]
Expand All @@ -241,7 +243,7 @@ def parse_python(buffer_pos):
self.index += pos

# If the command looks like a python syntax command, try to parse it.
if current == "(" or current == "[":
if current and current == "(" or current == "[":
Copy link
Member

Choose a reason for hiding this comment

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

Is this needed? if current is a string, bool(current) = len(current) > 0. If current is None, as above, then current != "(" and current != "[", or am I missing something?

Copy link
Member Author

Choose a reason for hiding this comment

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

yep, you're right.

try:
result = parse_python(pos)

Expand Down
1 change: 1 addition & 0 deletions bot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
bot.load_extension("bot.cogs.eval")
bot.load_extension("bot.cogs.fun")
bot.load_extension("bot.cogs.hiphopify")
bot.load_extension("bot.cogs.snakes")
bot.load_extension("bot.cogs.tags")
bot.load_extension("bot.cogs.verification")

Expand Down
16 changes: 9 additions & 7 deletions bot/cogs/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ async def send_updated_users(self, *users, replace_all=False):
try:
if replace_all:
response = await self.bot.http_session.post(
url=SITE_API_USER_URL,
url=f"{SITE_API_URL}/user",
json=list(users),
headers={"X-API-Key": SITE_API_KEY}
)
else:
response = await self.bot.http_session.put(
url=SITE_API_USER_URL,
url=f"{SITE_API_URL}/user",
json=list(users),
headers={"X-API-Key": SITE_API_KEY}
)
Expand All @@ -43,7 +43,8 @@ async def send_updated_users(self, *users, replace_all=False):
async def send_delete_users(self, *users):
try:
response = await self.bot.http_session.delete(
url=SITE_API_USER_URL,
url=f"{SITE_API_URL}/user",

json=list(users),
headers={"X-API-Key": SITE_API_KEY}
)
Expand Down Expand Up @@ -88,7 +89,7 @@ async def on_command_error(self, ctx: Context, e: CommandError):
f"Sorry, an unexpected error occurred. Please let us know!\n\n```{e}```"
)
raise e.original
log.error(f"COMMAND ERROR: '{e}'")
raise e

async def on_ready(self):
users = []
Expand Down Expand Up @@ -124,9 +125,10 @@ async def on_ready(self):
name=key, value=str(value)
)

await self.bot.get_channel(DEVLOG_CHANNEL).send(
embed=embed
)
if not DEBUG_MODE:
await self.bot.get_channel(DEVLOG_CHANNEL).send(
embed=embed
)

async def on_member_update(self, before: Member, after: Member):
if before.roles == after.roles and before.name == after.name and before.discriminator == after.discriminator:
Expand Down
9 changes: 5 additions & 4 deletions bot/cogs/hiphopify.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from bot.constants import (
ADMIN_ROLE, MODERATOR_ROLE, MOD_LOG_CHANNEL,
NEGATIVE_REPLIES, OWNER_ROLE, POSITIVE_REPLIES,
SITE_API_HIPHOPIFY_URL, SITE_API_KEY
SITE_API_KEY, SITE_API_URL
)
from bot.decorators import with_role

Expand All @@ -23,6 +23,7 @@ class Hiphopify:
def __init__(self, bot: AutoShardedBot):
self.bot = bot
self.headers = {"X-API-KEY": SITE_API_KEY}
self.url = f"{SITE_API_URL}/hiphopify"

async def on_member_update(self, before, after):
"""
Expand All @@ -42,7 +43,7 @@ async def on_member_update(self, before, after):
)

response = await self.bot.http_session.get(
SITE_API_HIPHOPIFY_URL,
self.url,
headers=self.headers,
params={"user_id": str(before.id)}
)
Expand Down Expand Up @@ -104,7 +105,7 @@ async def hiphopify(self, ctx: Context, member: Member, duration: str, forced_ni
params["forced_nick"] = forced_nick

response = await self.bot.http_session.post(
SITE_API_HIPHOPIFY_URL,
self.url,
headers=self.headers,
json=params
)
Expand Down Expand Up @@ -167,7 +168,7 @@ async def unhiphopify(self, ctx: Context, member: Member):
embed.colour = Colour.blurple()

response = await self.bot.http_session.delete(
SITE_API_HIPHOPIFY_URL,
self.url,
headers=self.headers,
json={"user_id": str(member.id)}
)
Expand Down
5 changes: 3 additions & 2 deletions bot/cogs/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from discord import Embed
from discord.ext.commands import AutoShardedBot

from bot.constants import DEVLOG_CHANNEL
from bot.constants import DEBUG_MODE, DEVLOG_CHANNEL

log = logging.getLogger(__name__)

Expand All @@ -26,7 +26,8 @@ async def on_ready(self):
icon_url="https://raw.githubusercontent.com/discord-python/branding/master/logos/logo_circle.png"
)

await self.bot.get_channel(DEVLOG_CHANNEL).send(embed=embed)
if not DEBUG_MODE:
await self.bot.get_channel(DEVLOG_CHANNEL).send(embed=embed)


def setup(bot):
Expand Down
Loading