Codechef atcoder support#470
Conversation
|
|
|
#94 for reference |
|
Which features were you talking in #468 then? |
|
@iampjeetsingh just ignore what cheran said. this requires detailed discussion. please provide your discord username so that we can invite you to the development server |
|
My discord username is thesupremeone#1162 |
| - **ALLOW_DUEL_SELF_REGISTER**: boolean value indicating if self registration for duels is enabled. | ||
| - **TLE_ADMIN**: the name of the role that can run admin commands of the bot. If this is not set, the role name will default to "Admin". | ||
| - **TLE_MODERATOR**: the name of the role that can run moderator commands of the bot. If this is not set, the role name will default to "Moderator". | ||
| - **CLIST_API_TOKEN**: Credential for accessing clist api, You can find your api key [here][https://clist.by/api/v2/doc/] after creating an account on clist.by. If this is not set, codechef/atcoder/google(kickstart) related commands won't work. |
There was a problem hiding this comment.
Markdown links are [label](url), with parentheses.
| """Shows ranklist for the contest with given contest id. If handles contains | ||
| '+server', all server members are included. No handles defaults to '+server'. | ||
|
|
||
| You can frame contest_id as follow |
There was a problem hiding this comment.
"You can specify contest_id as follows"?
| Use QR for Qualification Round and WF for World Finals. | ||
|
|
||
| # If nothing works | ||
| Use clist contest_id. You have to prefix - sign to clist contest-id otherwise it will be considered a codeforces contest id. |
There was a problem hiding this comment.
Could we consider doing this with a clist prefix rather than a minus sign? The minus way seems like a hack to me.
| async def _show_ranklist(self, channel, contest_id: int, handles: [str], ranklist, vc: bool = False, delete_after: float = None): | ||
| contest = cf_common.cache2.contest_cache.get_contest(contest_id) | ||
| async def _show_ranklist(self, channel, contest_id: int, handles, ranklist, vc: bool = False, delete_after: float = None, contest=None): | ||
| contest = contest or cf_common.cache2.contest_cache.get_contest(contest_id) |
There was a problem hiding this comment.
Not a big issue, but it would be neat if we could get away with only having 1 arg, rather than both contest and contest_id. Though I'm not sure what a clean option would be here.
|
|
||
| import discord | ||
| import random | ||
| import random, string |
There was a problem hiding this comment.
Small nit on style, prefer doing one import per line and keep imports sorted. I think the codebase is a bit inconsistent on that atm, but it's good to try to fix such issues as we go/don't make it messier.
| if is_int(contest_id): | ||
| contest_id = int(contest_id) | ||
| if contest_id<0: | ||
| contest_id = -1*contest_id |
There was a problem hiding this comment.
As mentioned elsewhere, not dealing with negative ints would be nicer.
| indexes[i] = letters[i] | ||
| standings = clist.format_standings(statistics, index_map, indexes) | ||
| ranklist = CRanklist(contest, standings, deltas=deltas if rated else None, problems_indexes=indexes) | ||
| return ranklist |
There was a problem hiding this comment.
A lot of these functions are on the form
if cf: minor logic + dispatch to cf_common
do complex clist logic
It might make sense to have a some overarching util (maybe resource_util for lack of better words) that does the backend agnostic work+the minor logic in the pseudocode above, and dispatches to cf_util or clist_util for specific implementations of e.g. ranklist. I.e. that ranklist functions does minor logic followed by dispatch to the specific impl of ranklist.
I suppose the resource code should also move there, just leaving the clist impl details here.
| @@ -5,6 +5,7 @@ | |||
| from discord.ext import commands | |||
| @@ -0,0 +1,25 @@ | |||
| from bs4 import BeautifulSoup | |||
| import requests | |||
There was a problem hiding this comment.
Might want to make this use aiohttp like the rest of the code which makes the request async.
| @@ -0,0 +1,25 @@ | |||
| from bs4 import BeautifulSoup | |||
There was a problem hiding this comment.
File comment:
If the core clist identify logic gets moved to clist_common this scraper code could be moved there.
| offset+=1000 | ||
| return results | ||
|
|
||
| class Contest(CfContest): |
There was a problem hiding this comment.
I think having Contest subclass CfContest to change one field is a bit weird. Should probably put this in a common class.
|
This is too stale to merge now. |
Implemented the following
;handle identify,;handle set,;handle list,;ranklistcommands for CodeChef / AtCoder / Google (Kickstart)