Skip to content

Commit

Permalink
Merge pull request #28 from Franco1010/see_contest
Browse files Browse the repository at this point in the history
Command: see
  • Loading branch information
Franco1010 authored Mar 24, 2023
2 parents 6a051f3 + 23200b4 commit 8b5eb6d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
5 changes: 1 addition & 4 deletions listenerServers/discordListener.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import discord
import aiohttp
import urllib.parse
import os
from dotenv import load_dotenv
import json

load_dotenv()

Expand Down Expand Up @@ -33,9 +31,8 @@ async def send_message(message):
async with aiohttp.ClientSession() as session:
async with session.post(url, json=payload) as response:
response_json = await response.json()
channel = message.channel
print(response_json)
await channel.send(response_json["response"])
await message.reply(response_json["response"])


@client.event
Expand Down
9 changes: 5 additions & 4 deletions polybotCommand/clickMenu/polygon/contest.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ async def help(ctx):
async def contest_list(ctx):
result = contestsDB.query_contests(ctx.obj["groupId"])
if len(result):
data = []
for i in result:
if i["source"] == "polygon":
data.append([i["name"], i["id"]])
data = [[r["name"], r["id"]] for r in result if r["source"] == "polygon"]
table = (
"```\n"
+ tabulate(data, headers=["Name", "Id"], tablefmt="pretty")
Expand Down Expand Up @@ -88,6 +85,7 @@ async def add(ctx, contestid, done):

@contest.command()
@click.argument("contestid")
@click.pass_context
async def see(ctx, contestid):
mine = is_mine(ctx.obj["groupId"], contestid)
if mine != 2:
Expand All @@ -97,6 +95,9 @@ async def see(ctx, contestid):
if contest == None:
click.echo("Contest is missing write access.")
return
data = [[c.letter, c.name] for c in contest]
table = "```\n" + tabulate(data, headers=["#", "Name"], tablefmt="pretty") + "\n```"
click.echo(table)


@contest.command()
Expand Down
3 changes: 2 additions & 1 deletion src_layer/polygon/polygonApi.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ async def contest(contestId):
if resp is None:
return None
problems = []
for _, problem in resp.items():
for letter, problem in resp.items():
problem["letter"] = letter
problems.append(make_from_dict(utils.Problem, problem))
return problems
1 change: 1 addition & 0 deletions src_layer/polygon/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"revision",
"latestPackage",
"modified",
"letter",
],
)

Expand Down

0 comments on commit 8b5eb6d

Please sign in to comment.