Files
tiennm99 629b513c91 feat(games): move /wordle and /loldle to the web games and add /loldledaily
/wordle and /loldle now send the wordle and loldle BotFather games in an
unlimited mode: each player gets their own word or champion, saved after
every guess, with a New game button. Cards the bot did not record as
unlimited, including the daily cards, play the daily puzzle. The helper
commands keep working on the player's round.

/loldledaily mirrors /wordledaily: one champion per day at 07:00 ICT,
subscribe and unsubscribe, the morning recap and the live group results.

The daily and unlimited machinery is shared in util/guessgame, the old
in-chat wordle module is removed, and a one-time startup migration carries
each player's stats and unfinished round over without changing old data.
2026-10-10 09:29:48 +07:00

44 lines
1.4 KiB
Go

package loldle
import (
"context"
"time"
"github.com/go-telegram/bot"
"github.com/go-telegram/bot/models"
"github.com/tiennm99/tiennm99bot/internal/modules/util/guessgame"
)
const (
msgDisabled = "LoLdle isn't configured on this server."
msgNoGameTarget = "Couldn't find the game message. Send /loldle or /loldledaily to play."
msgCardLookup = "Couldn't open the game right now. Try again later."
)
// handlePlay answers a Play press with the game URL carrying a signed token.
// A /loldle card opens the player's unlimited round; every other card,
// /loldledaily, the 07:00 push, an inline share or an expired record, opens
// today's daily champion.
func (s *service) handlePlay(ctx context.Context, b *bot.Bot, update *models.Update) error {
return guessgame.HandlePlay(ctx, b, update.CallbackQuery, guessgame.PlayParams{
Enabled: s.enabled(),
Cards: s.cards,
Now: s.cfg.now(),
TokenKey: s.tokenKey,
PageURL: s.cfg.baseURL + routePrefix,
MsgDisabled: msgDisabled,
MsgNoTarget: msgNoGameTarget,
MsgCardLookup: msgCardLookup,
LogName: ShortName,
})
}
func (s *service) signToken(c guessgame.Claims) (string, error) {
return guessgame.SignToken(s.tokenKey, c)
}
func (s *service) verifyToken(token string, now time.Time) (guessgame.Claims, error) {
return guessgame.VerifyToken(s.tokenKey, token, now)
}