mirror of
https://github.com/prosolis/gogobee.git
synced 2026-07-16 08:52:42 +00:00
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:
@@ -92,12 +92,8 @@ func (p *ConcertsPlugin) OnMessage(ctx MessageContext) error {
|
||||
parts := strings.SplitN(args, " ", 2)
|
||||
sub := strings.ToLower(parts[0])
|
||||
|
||||
// DB-only subcommands
|
||||
switch sub {
|
||||
case "watch":
|
||||
if len(parts) < 2 || strings.TrimSpace(parts[1]) == "" {
|
||||
return p.SendReply(ctx.RoomID, ctx.EventID, "Usage: !concerts watch <artist>")
|
||||
}
|
||||
return p.handleWatch(ctx, strings.TrimSpace(parts[1]))
|
||||
case "watching":
|
||||
return p.handleWatching(ctx)
|
||||
case "unwatch":
|
||||
@@ -105,9 +101,26 @@ func (p *ConcertsPlugin) OnMessage(ctx MessageContext) error {
|
||||
return p.SendReply(ctx.RoomID, ctx.EventID, "Usage: !concerts unwatch <artist>")
|
||||
}
|
||||
return p.handleUnwatch(ctx, strings.TrimSpace(parts[1]))
|
||||
default:
|
||||
return p.handleSearch(ctx, args)
|
||||
}
|
||||
|
||||
// API-calling subcommands run async
|
||||
go func() {
|
||||
var err error
|
||||
switch sub {
|
||||
case "watch":
|
||||
if len(parts) < 2 || strings.TrimSpace(parts[1]) == "" {
|
||||
err = p.SendReply(ctx.RoomID, ctx.EventID, "Usage: !concerts watch <artist>")
|
||||
} else {
|
||||
err = p.handleWatch(ctx, strings.TrimSpace(parts[1]))
|
||||
}
|
||||
default:
|
||||
err = p.handleSearch(ctx, args)
|
||||
}
|
||||
if err != nil {
|
||||
slog.Error("concerts: handler error", "err", err)
|
||||
}
|
||||
}()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *ConcertsPlugin) handleSearch(ctx MessageContext, artist string) error {
|
||||
@@ -222,14 +235,11 @@ func (p *ConcertsPlugin) fetchEvents(artist string) ([]bandsintownEvent, error)
|
||||
|
||||
// Update cache
|
||||
data, _ := json.Marshal(events)
|
||||
_, err = d.Exec(
|
||||
db.Exec("concerts: cache write",
|
||||
`INSERT INTO concerts_cache (artist, data, cached_at) VALUES (?, ?, ?)
|
||||
ON CONFLICT(artist) DO UPDATE SET data = ?, cached_at = ?`,
|
||||
artistKey, string(data), time.Now().Unix(), string(data), time.Now().Unix(),
|
||||
)
|
||||
if err != nil {
|
||||
slog.Error("concerts: cache write", "err", err)
|
||||
}
|
||||
|
||||
return events, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user