From beff9d2a6cec56474d80f855ad38f2a6f921bd08 Mon Sep 17 00:00:00 2001 From: James Harris <3440094+wopian@users.noreply.github.com> Date: Fri, 14 Jun 2024 19:55:56 +0100 Subject: [PATCH] feat: disable fixed checkpoints validation (#206) * feat: disable fixed checkpoints validation * fix: incorrect direction on message deletion check --- src/config/constants.ts | 2 +- src/config/requirements.ts | 5 ++++- src/sendDiscussionMessage.ts | 8 ++++---- src/setupClient.ts | 4 ++-- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/config/constants.ts b/src/config/constants.ts index 0ef241a..3830607 100644 --- a/src/config/constants.ts +++ b/src/config/constants.ts @@ -20,6 +20,6 @@ export const DISCORD_JUDGE_CHANNEL_ID = process.env.DISCORD_JUDGE_CHANNEL_ID export const ZEEPKIST_THEME_NAME = process.env.ZEEPKIST_THEME_NAME -export const THREE_DAYS_AGO = Date.now() - 1000 * 60 * 60 * 24 * 3 +export const FIVE_DAYS_AGO = Date.now() - 1000 * 60 * 60 * 24 * 5 export const FIVE_MINUTES_AGO = Date.now() - 1000 * 60 * 5 diff --git a/src/config/requirements.ts b/src/config/requirements.ts index 4ecb806..eea49e0 100644 --- a/src/config/requirements.ts +++ b/src/config/requirements.ts @@ -1,13 +1,16 @@ export const BLOCK_LIMIT = 4000 // 4000 export const MINIMUM_TIME = 30 // seconds export const MAXIMUM_TIME = 75 // seconds -export const MINIMUM_CHECKPOINTS = 4 +export const MINIMUM_CHECKPOINTS = 2 // eslint-disable-next-line @typescript-eslint/no-inferrable-types export const MAXIMUM_WIDTH: number = 0 // x 1x1 blocks wide export const START_FINISH_PROXIMITY: number = 0 // 5 blocks apart (16 * 5) +/* export const FIXED_CHECKPOINTS = [ '1615,-32,8,112,0,0,0,0.999,0.999,0.999', '1278,8,80,64,0,90,0,1,1,1', '1276,32,48,192,0,0,0,1,1,1', '1615,80,48,96,0,0,0,0.999,0.999,0.999' ] +*/ +export const FIXED_CHECKPOINTS = [] diff --git a/src/sendDiscussionMessage.ts b/src/sendDiscussionMessage.ts index cf0bbba..a4e143b 100644 --- a/src/sendDiscussionMessage.ts +++ b/src/sendDiscussionMessage.ts @@ -3,7 +3,7 @@ import { italic, ThreadChannel, User } from 'discord.js' import { FIVE_MINUTES_AGO, SILENT_MODE, - THREE_DAYS_AGO + FIVE_DAYS_AGO } from './config/constants.js' import { BLOCK_LIMIT, @@ -39,10 +39,10 @@ export const sendDiscussionMessage = async ({ } = level.validity const hashedLevel = getLevelHash(level.workshopId) - const invalidatedAt = hashedLevel?.invalidatedAt ?? 0 + const invalidatedAt = hashedLevel?.invalidatedAt ?? FIVE_DAYS_AGO - 1 // Don't send the message if the level has been invalidated less than 5 days ago - if (invalidatedAt > THREE_DAYS_AGO && invalidatedAt < FIVE_MINUTES_AGO) { + if (invalidatedAt < FIVE_DAYS_AGO && invalidatedAt > FIVE_MINUTES_AGO) { debug( `"${level.name}" has been invalidated less than five days ago, not pinging user`, import.meta @@ -89,5 +89,5 @@ export const sendDiscussionMessage = async ({ console.log(SILENT_MODE, channel.id, messageContent) // TODO: Refactor invalidation logic - // if (!SILENT_MODE) await channel.send(messageContent) + if (!SILENT_MODE) await channel.send(messageContent) } diff --git a/src/setupClient.ts b/src/setupClient.ts index cff5c76..11da659 100644 --- a/src/setupClient.ts +++ b/src/setupClient.ts @@ -5,7 +5,7 @@ import { DISCORD_JUDGE_CHANNEL_ID, DISCORD_SUBMISSION_CHANNEL_ID, SILENT_MODE, - THREE_DAYS_AGO + FIVE_DAYS_AGO } from './config/constants.js' import { getChannelMessages } from './getChannelMessages.js' import { debug, error } from './log.js' @@ -46,7 +46,7 @@ export const setupClient = async (client: Client) => { if (!SILENT_MODE) { // Delete any bot messages sent in a previous run for await (const message of getChannelMessages(discussionChannel)) { - if (message.author.bot && message.createdTimestamp < THREE_DAYS_AGO) { + if (message.author.bot && message.createdTimestamp > FIVE_DAYS_AGO) { debug( `Deleting bot message ${message.id} as it was created over 5 days ago`, import.meta,