Add forex plugin, stability fixes, and async HTTP dispatch

- Add forex plugin (Frankfurter v2 API) with rate lookups, analysis,
  DM-based alerts, and daily cron poll. Backfills 1 year of history
  on startup for moving averages and buy signal scoring.

- Fix bot hang caused by SQLite lock contention in reminder polling:
  rows cursor was held open while writing to the same DB. Collect
  results first, close cursor, then process. Same fix in milkcarton.

- Add sync retry loop so the bot reconnects after network drops
  instead of silently exiting. StopSync() for clean Ctrl+C shutdown.

- Add panic recovery to all dispatch, syncer, and cron paths.

- Make all HTTP-calling plugin commands async (goroutines) so a slow
  or dead external API cannot block the message dispatch pipeline.
  Affects: lookup, stocks, forex, anime, movies, concerts, gaming,
  retro, wotd, urls, howami.

- Extract DisplayName to Base, add db.Exec helper, convert silent
  error discards across the codebase.

- Fix UNO mercy-kill bug (eliminated bot continues playing), adventure
  DM nag spam, stats column mismatch, per-call regex/replacer allocs.

- Update README: forex commands, Finance section, 47 plugins.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
prosolis
2026-03-26 09:22:02 -07:00
parent c7c1b76589
commit 9c6ded13fa
68 changed files with 5784 additions and 724 deletions

View File

@@ -1,9 +1,7 @@
package plugin
import (
"context"
"fmt"
"log/slog"
"math/rand/v2"
"os"
"strings"
@@ -583,7 +581,7 @@ func (p *UnoPlugin) handleChallenge(ctx MessageContext, announceRoom id.RoomID,
p.mu.Unlock()
// Room announcement
playerName := p.unoDisplayName(ctx.Sender)
playerName := p.DisplayName(ctx.Sender)
botName := unoBotName()
modeTag := ""
startComment := pickCommentary("start")
@@ -1741,7 +1739,7 @@ func (p *UnoPlugin) playerWins(game *unoGame) error {
p.euro.Credit(game.playerID, totalPayout, "uno_win")
newPot := p.getPot()
playerName := p.unoDisplayName(game.playerID)
playerName := p.DisplayName(game.playerID)
p.SendMessage(game.dmRoomID, "🎉 **Uno out! You win!**")
@@ -1772,7 +1770,7 @@ func (p *UnoPlugin) botWins(game *unoGame) error {
potBefore := p.getPot()
p.addToPot(game.wager)
newPot := p.getPot()
playerName := p.unoDisplayName(game.playerID)
playerName := p.DisplayName(game.playerID)
p.SendMessage(game.dmRoomID, "💀 **"+unoBotName()+" wins.** Better luck next time.")
p.SendMessage(game.roomID, fmt.Sprintf(
@@ -1796,7 +1794,7 @@ func (p *UnoPlugin) forfeitGame(game *unoGame, timeout bool) error {
potBefore := p.getPot()
p.addToPot(game.wager)
playerName := p.unoDisplayName(game.playerID)
playerName := p.DisplayName(game.playerID)
if timeout {
p.SendMessage(game.dmRoomID,
@@ -1881,23 +1879,13 @@ func (p *UnoPlugin) cleanupGame(game *unoGame) {
}
func (p *UnoPlugin) recordGame(game *unoGame, result string, potBefore float64) {
d := db.Get()
_, err := d.Exec(
db.Exec("uno: record game",
`INSERT INTO uno_games (player_id, wager, result, pot_before, pot_after, turns, started_at, ended_at)
VALUES (?, ?, ?, ?, ?, ?, ?, ?)`,
string(game.playerID), game.wager, result, potBefore, p.getPot(),
game.turns, game.startedAt.UTC().Format("2006-01-02 15:04:05"),
time.Now().UTC().Format("2006-01-02 15:04:05"),
)
if err != nil {
slog.Error("uno: failed to record game", "err", err)
}
}
func (p *UnoPlugin) unoDisplayName(userID id.UserID) string {
resp, err := p.Client.GetDisplayName(context.Background(), userID)
if err != nil || resp.DisplayName == "" {
return string(userID)
}
return resp.DisplayName
}