Project 04 · Python · In progress

loba

A Discord bot that announces Codeforces contests.

It shows up in a server as Kim. A server manager picks a channel and, optionally, a role to ping.

When it posts ↓

# contests

  1. Kim App

    New contest

    Codeforces Round (Div. 2)

    Startsin 5 daysDuration2 hours

  2. Kim App

    Starts in 24 hours

    Codeforces Round (Div. 2)

    Startsin 24 hoursDuration2 hours

  3. Kim App

    Starts in 2 hours

    Codeforces Round (Div. 2)

    Startsin 2 hoursDuration2 hours

  4. Kim App

    @contest-ping

    Starts in 15 minutes

    Codeforces Round (Div. 2)

    Startsin 15 minutesDuration2 hours

Sample messages in the bot’s format. The contest is made up.

When it posts

Four messages per contest, at fixed times before it starts. Only the last one pings the role.

  1. when it is listed

    New contest

  2. 24 hours before

    Starts in 24 hours

  3. 2 hours before

    Starts in 2 hours

  4. 15 minutes before

    Starts in 15 minutes

    @contest-ping

  5. Contest starts

  • Contest rescheduled

    Posted when the start time changes, with the old time and the new one.

  • Contest cancelled

    Posted when a contest leaves the Codeforces schedule before it starts.

  • Two minutes before each message is due, the bot checks Codeforces once more, in case the contest moved.
  • A message more than five minutes late is skipped instead of posted stale.

How it’s built

Three parts with one job each. The Discord layer uses the other two; the logic touches nothing outside itself.

  1. Discordbot/cogs/

    Slash commands, listeners and the timed loops. Kept thin.

  2. Logicbot/services/

    What is due and what changed. Pure functions: no Discord, no network, no database.

  3. Storagebot/db/

    SQLite through aiosqlite. SQL lives only here.

Users never trigger a request
Commands read a cache the bot refreshes every 15 minutes.
One request per 2 seconds
The Codeforces API limit, kept with a lock and a timer.
Backs off
When Codeforces fails, the refresh interval doubles, up to an hour.
Stops after repeated failures
After 3 failed sends in a row, that server’s announcements turn off.
Restart-safe
The schema is applied on every start, so every statement is idempotent.
Old rows are pruned
Announcement rows go a week after the contest starts.

Commands

  • /cf setchannel<channel> [role]

    Announce Codeforces contests in a channel.

    Manage Server
  • /cf upcoming

    Show the next Codeforces contests.

  • /cf settings

    Show the current announcement settings.

  • /cf disable

    Stop Codeforces contest announcements.

    Manage Server
  • /ping

    Check the bot’s latency.

  • /about

    About this bot.

Jump to

↑ ↓ move↵ openesc close

You found the 8.

mi8ess can read this board but cannot generate moves yet, so both sides are moved by hand.

Play e4 to start

Open mi8ess

Click anywhere to close