feat(bots): anonConfess + shitpostLeaderboard built-in bots
- ConfessBot: polls for /confess messages, deletes original, reposts anonymous - LeaderboardBot: daily top-10 message count recap from DB - BotFunc extended with *sql.DB param for DB-reading bots - Both types registered in runner + BotManager UI
This commit is contained in:
@@ -11,8 +11,8 @@ import (
|
||||
)
|
||||
|
||||
// BotFunc is the signature for a built-in bot type's run function.
|
||||
// It blocks until ctx is cancelled. Use send to post messages.
|
||||
type BotFunc func(ctx context.Context, config json.RawMessage, send SendMessageFunc)
|
||||
// It blocks until ctx is cancelled. Use send to post messages, db to read.
|
||||
type BotFunc func(ctx context.Context, db *sql.DB, config json.RawMessage, send SendMessageFunc)
|
||||
|
||||
// SendMessageFunc posts a message to a channel as this bot.
|
||||
type SendMessageFunc func(channelID, content string)
|
||||
@@ -91,7 +91,7 @@ func (r *Runner) Start(botID, botType string, config json.RawMessage) {
|
||||
r.logger.Error("bot panic", "bot_id", botID, "type", botType, "panic", rec)
|
||||
}
|
||||
}()
|
||||
fn(ctx, config, send)
|
||||
fn(ctx, r.db, config, send)
|
||||
r.logger.Info("bot stopped", "bot_id", botID, "type", botType)
|
||||
}()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user