Markov updates

This commit is contained in:
2025-05-27 00:09:48 -06:00
parent b306143db2
commit 6955421fd7
6 changed files with 1254 additions and 59 deletions

View File

@ -11,9 +11,11 @@ MESSAGE_COUNT_THRESHOLD=5
HIMBUCKS_COOLDOWN_MINUTES=1
# Markov Chain Configuration
MARKOV_DEFAULT_MESSAGES=100
MARKOV_DEFAULT_MESSAGES=500
MARKOV_MAX_MESSAGES=1000
MARKOV_CACHE_SIZE=10
MARKOV_CACHE_SIZE=50
MARKOV_MAX_NGRAM=5
MARKOV_MEMORY_LIMIT_MB=100
# Database Configuration
DB_MAX_OPEN_CONNS=25

File diff suppressed because it is too large Load Diff

View File

@ -16,6 +16,8 @@ services:
- MARKOV_DEFAULT_MESSAGES=${MARKOV_DEFAULT_MESSAGES:-100}
- MARKOV_MAX_MESSAGES=${MARKOV_MAX_MESSAGES:-1000}
- MARKOV_CACHE_SIZE=${MARKOV_CACHE_SIZE:-10}
- MARKOV_MAX_NGRAM=${MARKOV_MAX_NGRAM:-5}
- MARKOV_MEMORY_LIMIT_MB=${MARKOV_MEMORY_LIMIT_MB:-100}
# Database Configuration
- DB_MAX_OPEN_CONNS=${DB_MAX_OPEN_CONNS:-25}

View File

@ -1,29 +0,0 @@
# Discord Configuration
DISCORD_TOKEN=your_discord_bot_token_here
# Docker Configuration
IMAGE=your_image_name:latest
ROOT_DIR=./himbot_data
# Himbucks System Configuration (optional - defaults provided)
# HIMBUCKS_PER_REWARD=10
# MESSAGE_COUNT_THRESHOLD=5
# HIMBUCKS_COOLDOWN_MINUTES=1
# Markov Chain Configuration (optional - defaults provided)
# MARKOV_DEFAULT_MESSAGES=100
# MARKOV_MAX_MESSAGES=1000
# MARKOV_CACHE_SIZE=10
# Database Configuration (optional - defaults provided)
# DB_MAX_OPEN_CONNS=25
# DB_MAX_IDLE_CONNS=5
# DB_CONN_MAX_LIFETIME_MINUTES=5
# Command Cooldowns in seconds (optional - defaults provided)
# PING_COOLDOWN_SECONDS=5
# HS_COOLDOWN_SECONDS=10
# MARKOV_COOLDOWN_SECONDS=30
# HIMBUCKS_COOLDOWN_SECONDS=5
# HIMBOARD_COOLDOWN_SECONDS=5
# SENDBUCKS_COOLDOWN_SECONDS=1800

View File

@ -20,6 +20,8 @@ type Config struct {
MarkovDefaultMessages int
MarkovMaxMessages int
MarkovCacheSize int
MarkovMaxNGram int // Maximum n-gram level (3, 4, 5, etc.)
MarkovMemoryLimit int // Memory limit in MB for n-gram chains
// Database settings
MaxOpenConns int
@ -30,6 +32,7 @@ type Config struct {
PingCooldown int
HsCooldown int
MarkovCooldown int
MarkovAskCooldown int
HimbucksCooldown int
HimboardCooldown int
SendbucksCooldown int
@ -52,6 +55,8 @@ func LoadConfig() *Config {
MarkovDefaultMessages: getEnvInt("MARKOV_DEFAULT_MESSAGES", 100),
MarkovMaxMessages: getEnvInt("MARKOV_MAX_MESSAGES", 1000),
MarkovCacheSize: getEnvInt("MARKOV_CACHE_SIZE", 10),
MarkovMaxNGram: getEnvInt("MARKOV_MAX_NGRAM", 5),
MarkovMemoryLimit: getEnvInt("MARKOV_MEMORY_LIMIT_MB", 100),
// Database settings
MaxOpenConns: getEnvInt("DB_MAX_OPEN_CONNS", 25),
@ -62,6 +67,7 @@ func LoadConfig() *Config {
PingCooldown: getEnvInt("PING_COOLDOWN_SECONDS", 5),
HsCooldown: getEnvInt("HS_COOLDOWN_SECONDS", 10),
MarkovCooldown: getEnvInt("MARKOV_COOLDOWN_SECONDS", 30),
MarkovAskCooldown: getEnvInt("MARKOV_ASK_COOLDOWN_SECONDS", 30),
HimbucksCooldown: getEnvInt("HIMBUCKS_COOLDOWN_SECONDS", 5),
HimboardCooldown: getEnvInt("HIMBOARD_COOLDOWN_SECONDS", 5),
SendbucksCooldown: getEnvInt("SENDBUCKS_COOLDOWN_SECONDS", 1800),

33
main.go
View File

@ -191,8 +191,8 @@ func initCommands(config *lib.Config) {
},
},
{
Name: "markov",
Description: "Why did the Markov chain break up with its partner? Because it couldn't handle the past!",
Name: "gen",
Description: "Generate a random message using markov chains based on channel history",
Options: []*discordgo.ApplicationCommandOption{
{
Type: discordgo.ApplicationCommandOptionInteger,
@ -202,6 +202,24 @@ func initCommands(config *lib.Config) {
},
},
},
{
Name: "ask",
Description: "Ask a question and get a markov chain answer based on channel contents (like ChatGPT but dumb!)",
Options: []*discordgo.ApplicationCommandOption{
{
Type: discordgo.ApplicationCommandOptionString,
Name: "question",
Description: "The question you want to ask",
Required: true,
},
{
Type: discordgo.ApplicationCommandOptionInteger,
Name: "messages",
Description: fmt.Sprintf("Number of messages to use (default: %d, max: %d)", config.MarkovDefaultMessages, config.MarkovMaxMessages),
Required: false,
},
},
},
{
Name: "himbucks",
Description: "Check your himbucks balance",
@ -235,11 +253,12 @@ func initCommands(config *lib.Config) {
// initCommandHandlers initializes command handlers with configuration
func initCommandHandlers(config *lib.Config) {
commandHandlers = map[string]func(s *discordgo.Session, i *discordgo.InteractionCreate){
"ping": lib.HandleCommand("ping", time.Duration(config.PingCooldown)*time.Second, command.PingCommand),
"hs": lib.HandleCommand("hs", time.Duration(config.HsCooldown)*time.Second, command.HsCommand),
"markov": lib.HandleCommand("markov", time.Duration(config.MarkovCooldown)*time.Second, command.MarkovCommand),
"himbucks": lib.HandleCommand("himbucks", time.Duration(config.HimbucksCooldown)*time.Second, command.BalanceGetCommand),
"himboard": lib.HandleCommand("himboard", time.Duration(config.HimboardCooldown)*time.Second, command.LeaderboardCommand),
"ping": lib.HandleCommand("ping", time.Duration(config.PingCooldown)*time.Second, command.PingCommand),
"hs": lib.HandleCommand("hs", time.Duration(config.HsCooldown)*time.Second, command.HsCommand),
"gen": lib.HandleCommand("gen", time.Duration(config.MarkovCooldown)*time.Second, command.MarkovCommand),
"ask": lib.HandleCommand("ask", time.Duration(config.MarkovAskCooldown)*time.Second, command.MarkovQuestionCommand),
"himbucks": lib.HandleCommand("himbucks", time.Duration(config.HimbucksCooldown)*time.Second, command.BalanceGetCommand),
"himboard": lib.HandleCommand("himboard", time.Duration(config.HimboardCooldown)*time.Second, command.LeaderboardCommand),
"sendbucks": lib.HandleCommand("sendbucks", time.Duration(config.SendbucksCooldown)*time.Second, command.BalanceSendCommand),
}
}