Dev branch beginning with a bunch of shit added. All I know is that it builds.

This commit is contained in:
2026-01-09 12:43:15 -05:00
parent af61f60759
commit d1183d5867
4 changed files with 558 additions and 19 deletions

View File

@ -4,10 +4,14 @@ import (
"regexp"
"strconv"
"strings"
"time"
)
// Pattern matches "Wordle XXXX Y/6" format
var pattern = regexp.MustCompile(`(?i)Wordle\s+(\d+)\s+([X1-6])/6`)
// Pattern matches "Wordle XXXX Y/6" format (with optional comma in number)
var pattern = regexp.MustCompile(`(?i)Wordle\s+([\d,]+)\s+([X1-6])/6`)
// Wordle #1 was June 19, 2021
var wordleStartDate = time.Date(2021, 6, 19, 0, 0, 0, 0, time.UTC)
// Match represents a matched Wordle score
type Match struct {
@ -15,6 +19,20 @@ type Match struct {
Score string
}
// GetExpectedPuzzleNumber returns the expected Wordle puzzle number for a given date
func GetExpectedPuzzleNumber(date time.Time) int {
daysSinceStart := int(date.Sub(wordleStartDate).Hours() / 24)
return daysSinceStart + 1
}
// IsValidPuzzleNumber checks if a puzzle number is valid for the given date
// Allows for timezone differences (±1 day)
func IsValidPuzzleNumber(puzzleNumber int, date time.Time) bool {
expected := GetExpectedPuzzleNumber(date)
// Allow ±1 day for timezone differences
return puzzleNumber >= expected-1 && puzzleNumber <= expected+1
}
// Find searches for a Wordle pattern in the given text
// Returns the match and a boolean indicating if a match was found
func Find(text string) (*Match, bool) {
@ -23,7 +41,9 @@ func Find(text string) (*Match, bool) {
return nil, false
}
puzzleNumber, _ := strconv.Atoi(matches[1])
// Remove commas from puzzle number before parsing
puzzleNumberStr := strings.ReplaceAll(matches[1], ",", "")
puzzleNumber, _ := strconv.Atoi(puzzleNumberStr)
score := strings.ToUpper(matches[2])
return &Match{