mirror of
https://github.com/prosolis/gogobee.git
synced 2026-07-15 08:32:41 +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:
@@ -174,22 +174,33 @@ func FirePendingReminders(client *mautrix.Client) {
|
||||
|
||||
base := NewBase(client)
|
||||
|
||||
// Collect all pending reminders first, then close the rows.
|
||||
// Iterating rows while also writing to the DB can cause SQLite lock issues.
|
||||
type pendingReminder struct {
|
||||
ID, UserID, RoomID, Message string
|
||||
}
|
||||
var pending []pendingReminder
|
||||
for rows.Next() {
|
||||
var reminderID, userID, roomID, message string
|
||||
if err := rows.Scan(&reminderID, &userID, &roomID, &message); err != nil {
|
||||
var r pendingReminder
|
||||
if err := rows.Scan(&r.ID, &r.UserID, &r.RoomID, &r.Message); err != nil {
|
||||
slog.Error("reminders: scan row", "err", err)
|
||||
continue
|
||||
}
|
||||
pending = append(pending, r)
|
||||
}
|
||||
rows.Close()
|
||||
|
||||
msg := fmt.Sprintf("⏰ Reminder for %s: %s", userID, message)
|
||||
if err := base.SendMessage(id.RoomID(roomID), msg); err != nil {
|
||||
slog.Error("reminders: send reminder", "err", err, "id", reminderID)
|
||||
for _, r := range pending {
|
||||
// Mark fired BEFORE sending so a crash doesn't re-fire on restart.
|
||||
_, err := db.Get().Exec(`UPDATE reminders SET fired = 1 WHERE id = ?`, r.ID)
|
||||
if err != nil {
|
||||
slog.Error("reminders: mark fired", "err", err, "id", r.ID)
|
||||
continue
|
||||
}
|
||||
|
||||
_, err := db.Get().Exec(`UPDATE reminders SET fired = 1 WHERE id = ?`, reminderID)
|
||||
if err != nil {
|
||||
slog.Error("reminders: mark fired", "err", err, "id", reminderID)
|
||||
msg := fmt.Sprintf("⏰ Reminder for %s: %s", r.UserID, r.Message)
|
||||
if err := base.SendMessage(id.RoomID(r.RoomID), msg); err != nil {
|
||||
slog.Error("reminders: send reminder", "err", err, "id", r.ID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user