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

Command: see #28

Merged
merged 1 commit into from
Mar 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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