async def problem_info(self, ctx, problem_set):
        problems, categories = self.helper.get_give_list(problem_set)
        problems = list(set(problems))  # erase duplicate problems
        total_problem = len(problems)
        message = str(total_problem) + " problems."
        if len(categories) >= 1:
            message = "Categories: " + categories + ". " + message
        if total_problem > 26:
            message = "Too many problems to show. " + message
            await ctx.send(message)
            return
        style = table.Style('{:<}  {:<}  {:<}')
        t = table.Table(style)
        t += table.Header('Name', 'Fixer', 'Reviewer')
        t += table.Line()
        index = 0
        for p in problems:
            p = "VOJ-" + p.upper().replace('_', '-')
            if (p not in self.problem_name_to_id):
                continue
            fixer = self.db_gave.get(p)
            fixer = self.format_beautiful_string(fixer)
            reviewer = self.db_reviewed.get(p)
            reviewer = self.format_beautiful_string(reviewer)
            if self.db_deleted.is_deleted(p):
                fixer = 'DELETED'
                reviewer = 'DELETED'

            t += table.Data(p[4:], fixer, reviewer)

        msg = message + '```\n' + str(t) + '\n```'

        await ctx.send(msg)
Esempio n. 2
0
        def make_page(chunk, page_num):
            style = table.Style('{:>}  {:<}  {:<}')
            t = table.Table(style)
            t += table.Header('#', 'Handle', 'Point')
            t += table.Line()
            for index, (point, handle) in enumerate(chunk):
                point_str = '{:.3f}'.format(point)
                t += table.Data(_PER_PAGE * page_num + index, handle, point_str)

            table_str = f'```yml\n{t}\n```'
            embed = discord.Embed(description=table_str)
            return 'Bảng xếp hạng VOJ', embed
    async def deleted_list(self, ctx):
        cur = self.db_deleted.list()
        style = table.Style('{:<}  {:<}')
        t = table.Table(style)
        t += table.Header('Name', 'Reason')
        t += table.Line()
        index = 0
        for p in cur:
            t += table.Data(p, cur[p])

        msg = '```\n' + str(t) + '\n```'

        await ctx.send(msg)
 def get_link_codeforces(self, problems, mashup_id):
     cur = self.db_deleted.list()
     style = table.Style('{:<}  {:<}')
     t = table.Table(style)
     t += table.Header('Name', 'Link')
     t += table.Line()
     pattern = 'https://codeforces.com/group/FLVn1Sc504/contest/{0}/problem/{1}'
     cur_char = 'A'
     res = ''
     for p in problems:
         p = p.upper()
         t += table.Data(p, pattern.format(mashup_id, cur_char))
         cur_char = chr(ord(cur_char) + 1)
     msg = '```\n' + str(t) + '\n```'
     return msg
Esempio n. 5
0
        def make_page(chunk, page_num, tag_rank=False):
            style = table.Style('{:>}  {:<}  {:<}')
            t = table.Table(style)
            if tag_rank:
                t += table.Header('#', 'Tag', 'Số bài')
            else:
                t += table.Header('#', 'Username', 'Số bài')
            t += table.Line()
            for index, (cnt_tagged, User) in enumerate(chunk):
                t += table.Data(_PER_PAGE * page_num + index, User, cnt_tagged)

            table_str = f'```yml\n{t}\n```'
            embed = discord.Embed(description=table_str)
            if tag_rank:
                return 'Số bài đã tag theo từng tag', embed
            return 'Bảng xếp hạng', embed
    async def staff_list(self, ctx):
        cur = self.db.list()
        style = table.Style('{:>}  {:<}  {:<}')
        t = table.Table(style)
        t += table.Header('#', 'Name', 'Polygon')
        t += table.Line()
        index = 0
        for user_id in cur:
            member = ctx.guild.get_member(int(user_id))
            if member is None:
                continue
            index += 1
            name = member.display_name
            t += table.Data(index, name, cur[user_id])

        msg = '```\n' + str(t) + '\n```'

        await ctx.send(msg)
    async def stats(self, ctx):

        data = self.get_data()
        if data is None:
            await ctx.send('API Failed')
            return
        style = table.Style('{:<}  {:<}  {:<}   {:<}')
        t = table.Table(style)
        t += table.Header('Corona :(', 'Cases', 'Recovered', 'Deaths')
        t += table.Line()
        for country in data:
            name = country[0].upper() + country[1:]
            t += table.Data(name, data[country]['cases'],
                            data[country]['recovered'],
                            data[country]['deaths'])
        msg = "Some statistics about total corona virus cases: \n" + \
            "Current time: " + self.current_time() + '```\n' + str(t) + '\n```'

        await ctx.send(msg)
Esempio n. 8
0
 async def badge(self, ctx):
     """
     Hiện phần trăm điểm yêu cầu để đạt được huy hiệu tương ứng.
     """
     style = table.Style('{:<}  {:<}  {:<}')
     t = table.Table(style)
     t += table.Header('Tên huy hiệu', '% yêu cầu', '% giới hạn')
     t += table.Line()
     for rank in badge.RATED_RANKS:
         title = rank.title
         low = max(0, rank.low)
         hi = min(100, rank.high)
         low = "{:.2f}%".format(low)
         hi = "{:.2f}%".format(hi)
         t += table.Data(title, low, hi)
     table_str = f'```\n{t}\n```'
     embed = discord_common.cf_color_embed(
         title="% điểm yêu cầu."
         "Tổng điểm hiện tại SUM_SCORE={:.2f}".format(badge.MAX_SCORE),
         description=table_str)
     await ctx.send(embed=embed)