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:
@@ -2,7 +2,6 @@ package plugin
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
@@ -630,7 +629,7 @@ func (p *HangmanPlugin) endGame(roomID id.RoomID, game *hangmanGame) error {
|
||||
eligibleParticipants = append(eligibleParticipants, uid)
|
||||
}
|
||||
|
||||
solverName := p.displayName(game.solvedBy)
|
||||
solverName := p.DisplayName(game.solvedBy)
|
||||
participantCount := len(eligibleParticipants)
|
||||
|
||||
var sb strings.Builder
|
||||
@@ -652,7 +651,7 @@ func (p *HangmanPlugin) endGame(roomID id.RoomID, game *hangmanGame) error {
|
||||
}
|
||||
p.euro.Credit(uid, payout, "hangman_win")
|
||||
p.recordHangmanScore(uid, payout)
|
||||
name := p.displayName(uid)
|
||||
name := p.DisplayName(uid)
|
||||
sb.WriteString(fmt.Sprintf(" **%s**: +€%d%s\n", name, int(payout), label))
|
||||
}
|
||||
}
|
||||
@@ -779,7 +778,7 @@ func (p *HangmanPlugin) handleBoard(ctx MessageContext) error {
|
||||
var won int
|
||||
rows.Scan(&userID, &earned, &won)
|
||||
rank++
|
||||
name := p.displayName(id.UserID(userID))
|
||||
name := p.DisplayName(id.UserID(userID))
|
||||
sb.WriteString(fmt.Sprintf("%d. **%s** — €%d earned (%d wins)\n", rank, name, int(earned), won))
|
||||
}
|
||||
|
||||
@@ -791,8 +790,7 @@ func (p *HangmanPlugin) handleBoard(ctx MessageContext) error {
|
||||
}
|
||||
|
||||
func (p *HangmanPlugin) recordHangmanScore(userID id.UserID, earned float64) {
|
||||
d := db.Get()
|
||||
_, _ = d.Exec(
|
||||
db.Exec("hangman: record score",
|
||||
`INSERT INTO hangman_scores (user_id, total_earned, games_played, games_won)
|
||||
VALUES (?, ?, 1, 1)
|
||||
ON CONFLICT(user_id) DO UPDATE SET
|
||||
@@ -803,10 +801,3 @@ func (p *HangmanPlugin) recordHangmanScore(userID id.UserID, earned float64) {
|
||||
)
|
||||
}
|
||||
|
||||
func (p *HangmanPlugin) displayName(userID id.UserID) string {
|
||||
resp, err := p.Client.GetDisplayName(context.Background(), userID)
|
||||
if err != nil || resp.DisplayName == "" {
|
||||
return string(userID)
|
||||
}
|
||||
return resp.DisplayName
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user