✨ add a way to spawn a shell to debug
also can show partial tirages
This commit is contained in:
parent
1148d669cd
commit
43701f1a53
|
@ -1,11 +1,13 @@
|
|||
#!/bin/python
|
||||
import asyncio
|
||||
import code
|
||||
import os
|
||||
import random
|
||||
import sys
|
||||
import traceback
|
||||
from collections import defaultdict, namedtuple
|
||||
from pathlib import Path
|
||||
from pprint import pprint
|
||||
from typing import Dict, Type
|
||||
|
||||
import discord
|
||||
|
@ -39,7 +41,7 @@ TIRAGES_FILE = Path(__file__).parent / "tirages.yaml"
|
|||
|
||||
|
||||
def in_passage_order(teams, round=0):
|
||||
return sorted(teams, key=lambda team: team.passage_order[round], reverse=True)
|
||||
return sorted(teams, key=lambda team: team.passage_order[round] or 0, reverse=True)
|
||||
|
||||
|
||||
class TfjmError(Exception):
|
||||
|
@ -202,14 +204,15 @@ class Tirage(yaml.YAMLObject):
|
|||
records = [
|
||||
Record(
|
||||
team.name,
|
||||
team.accepted_problems[round][0],
|
||||
(team.accepted_problems[round] or "- None")[0],
|
||||
f"k = {team.coeff(round)} ",
|
||||
)
|
||||
for team in in_passage_order(self.teams, round)
|
||||
]
|
||||
|
||||
msg += f"\n\n**{ROUND_NAMES[round].capitalize()}**:\n"
|
||||
msg += table.format(*records[round]) + "\n"
|
||||
code.interact(local=locals())
|
||||
msg += table.format(*records) + "\n"
|
||||
for team in self.teams:
|
||||
msg += team.details(round)
|
||||
|
||||
|
@ -625,6 +628,7 @@ async def abort_draw_cmd(ctx):
|
|||
|
||||
|
||||
@bot.command(name="draw-skip", aliases=["skip"])
|
||||
@commands.has_role(CNO_ROLE)
|
||||
async def draw_skip(ctx, *teams):
|
||||
channel = ctx.channel.id
|
||||
tirages[channel] = tirage = Tirage(ctx, channel, teams)
|
||||
|
@ -750,6 +754,24 @@ async def show_cmd(ctx: Context, arg: str):
|
|||
await tirage.show(ctx)
|
||||
|
||||
|
||||
@bot.command()
|
||||
@commands.has_role(CNO_ROLE)
|
||||
async def interrupt_cmd(ctx):
|
||||
await ctx.send(
|
||||
"J'ai été arrêté et une console interactive a été ouverte là où je tourne. "
|
||||
"Toutes les commandes rateront tant que cette console est ouverte.\n"
|
||||
"Soyez rapides, je déteste les opérations à coeur ouvert... :confounded:"
|
||||
)
|
||||
|
||||
# Utility function
|
||||
def _show(o):
|
||||
print(*dir(o), sep="\n")
|
||||
|
||||
code.interact(local={**globals(), **locals()})
|
||||
|
||||
await ctx.send("Tout va mieux !")
|
||||
|
||||
|
||||
@bot.event
|
||||
async def on_command_error(ctx: Context, error, *args, **kwargs):
|
||||
if isinstance(error, commands.CommandInvokeError):
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
&id001 !<Tirage>
|
||||
channel: 703310860365594624
|
||||
phase: !!python/object:__main__.TirageOrderPhase
|
||||
name: des tirages
|
||||
order_name: tirage_order
|
||||
reverse: false
|
||||
round: 0
|
||||
tirage: *id001
|
||||
teams:
|
||||
- !<Team>
|
||||
accepted_problems:
|
||||
- null
|
||||
- null
|
||||
drawn_problem: null
|
||||
mention: <@&703923322483900426>
|
||||
name: AAA
|
||||
passage_order:
|
||||
- null
|
||||
- null
|
||||
rejected:
|
||||
- !!set {}
|
||||
- !!set {}
|
||||
tirage_order:
|
||||
- null
|
||||
- null
|
||||
- !<Team>
|
||||
accepted_problems:
|
||||
- null
|
||||
- null
|
||||
drawn_problem: null
|
||||
mention: <@&703923681931296831>
|
||||
name: BBB
|
||||
passage_order:
|
||||
- null
|
||||
- null
|
||||
rejected:
|
||||
- !!set {}
|
||||
- !!set {}
|
||||
tirage_order:
|
||||
- null
|
||||
- null
|
||||
- !<Team>
|
||||
accepted_problems:
|
||||
- null
|
||||
- null
|
||||
drawn_problem: null
|
||||
mention: <@&703923724465733632>
|
||||
name: CCC
|
||||
passage_order:
|
||||
- null
|
||||
- null
|
||||
rejected:
|
||||
- !!set {}
|
||||
- !!set {}
|
||||
tirage_order:
|
||||
- null
|
||||
- null
|
Loading…
Reference in New Issue