Skip to content

Commit

Permalink
feat: disable fixed checkpoints validation (#206)
Browse files Browse the repository at this point in the history
* feat: disable fixed checkpoints validation

* fix: incorrect direction on message deletion check
  • Loading branch information
wopian authored Jun 14, 2024
1 parent ae21f75 commit beff9d2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/config/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 4 additions & 1 deletion src/config/requirements.ts
Original file line number Diff line number Diff line change
@@ -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 = []
8 changes: 4 additions & 4 deletions src/sendDiscussionMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
4 changes: 2 additions & 2 deletions src/setupClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit beff9d2

Please sign in to comment.