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

@@ -70,38 +70,39 @@ func (p *URLsPlugin) OnMessage(ctx MessageContext) error {
return nil
}
for _, u := range urls {
title, desc, err := p.fetchPreview(u)
if err != nil {
slog.Debug("urls: fetch preview failed", "url", u, "err", err)
continue
}
go p.previewURL(ctx, urls[0])
return nil
}
if title == "" && desc == "" {
continue
}
var preview strings.Builder
if title != "" {
preview.WriteString(fmt.Sprintf("Title: %s", title))
}
if desc != "" {
if preview.Len() > 0 {
preview.WriteString("\n")
}
// Truncate long descriptions
if len(desc) > 200 {
desc = desc[:200] + "..."
}
preview.WriteString(fmt.Sprintf("Description: %s", desc))
}
if err := p.SendReply(ctx.RoomID, ctx.EventID, preview.String()); err != nil {
slog.Error("urls: send preview", "err", err)
}
func (p *URLsPlugin) previewURL(ctx MessageContext, targetURL string) {
title, desc, err := p.fetchPreview(targetURL)
if err != nil {
slog.Debug("urls: fetch preview failed", "url", targetURL, "err", err)
return
}
return nil
if title == "" && desc == "" {
return
}
var preview strings.Builder
if title != "" {
preview.WriteString(fmt.Sprintf("Title: %s", title))
}
if desc != "" {
if preview.Len() > 0 {
preview.WriteString("\n")
}
// Truncate long descriptions
if len(desc) > 200 {
desc = desc[:200] + "..."
}
preview.WriteString(fmt.Sprintf("Description: %s", desc))
}
if err := p.SendReply(ctx.RoomID, ctx.EventID, preview.String()); err != nil {
slog.Error("urls: send preview", "err", err)
}
}
// fetchPreview retrieves og:title and og:description, checking cache first.
@@ -127,14 +128,11 @@ func (p *URLsPlugin) fetchPreview(rawURL string) (string, string, error) {
}
// Cache the result
_, cacheErr := d.Exec(
db.Exec("urls: cache write",
`INSERT INTO url_cache (url, title, description, cached_at) VALUES (?, ?, ?, ?)
ON CONFLICT(url) DO UPDATE SET title = ?, description = ?, cached_at = ?`,
rawURL, title, desc, now, title, desc, now,
)
if cacheErr != nil {
slog.Error("urls: cache write", "err", cacheErr)
}
return title, desc, nil
}