Markov updates
This commit is contained in:
@ -11,9 +11,11 @@ MESSAGE_COUNT_THRESHOLD=5
|
|||||||
HIMBUCKS_COOLDOWN_MINUTES=1
|
HIMBUCKS_COOLDOWN_MINUTES=1
|
||||||
|
|
||||||
# Markov Chain Configuration
|
# Markov Chain Configuration
|
||||||
MARKOV_DEFAULT_MESSAGES=100
|
MARKOV_DEFAULT_MESSAGES=500
|
||||||
MARKOV_MAX_MESSAGES=1000
|
MARKOV_MAX_MESSAGES=1000
|
||||||
MARKOV_CACHE_SIZE=10
|
MARKOV_CACHE_SIZE=50
|
||||||
|
MARKOV_MAX_NGRAM=5
|
||||||
|
MARKOV_MEMORY_LIMIT_MB=100
|
||||||
|
|
||||||
# Database Configuration
|
# Database Configuration
|
||||||
DB_MAX_OPEN_CONNS=25
|
DB_MAX_OPEN_CONNS=25
|
||||||
|
1237
command/markov.go
1237
command/markov.go
File diff suppressed because it is too large
Load Diff
@ -16,6 +16,8 @@ services:
|
|||||||
- MARKOV_DEFAULT_MESSAGES=${MARKOV_DEFAULT_MESSAGES:-100}
|
- MARKOV_DEFAULT_MESSAGES=${MARKOV_DEFAULT_MESSAGES:-100}
|
||||||
- MARKOV_MAX_MESSAGES=${MARKOV_MAX_MESSAGES:-1000}
|
- MARKOV_MAX_MESSAGES=${MARKOV_MAX_MESSAGES:-1000}
|
||||||
- MARKOV_CACHE_SIZE=${MARKOV_CACHE_SIZE:-10}
|
- 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
|
# Database Configuration
|
||||||
- DB_MAX_OPEN_CONNS=${DB_MAX_OPEN_CONNS:-25}
|
- DB_MAX_OPEN_CONNS=${DB_MAX_OPEN_CONNS:-25}
|
||||||
|
29
env.example
29
env.example
@ -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
|
|
@ -20,6 +20,8 @@ type Config struct {
|
|||||||
MarkovDefaultMessages int
|
MarkovDefaultMessages int
|
||||||
MarkovMaxMessages int
|
MarkovMaxMessages int
|
||||||
MarkovCacheSize 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
|
// Database settings
|
||||||
MaxOpenConns int
|
MaxOpenConns int
|
||||||
@ -30,6 +32,7 @@ type Config struct {
|
|||||||
PingCooldown int
|
PingCooldown int
|
||||||
HsCooldown int
|
HsCooldown int
|
||||||
MarkovCooldown int
|
MarkovCooldown int
|
||||||
|
MarkovAskCooldown int
|
||||||
HimbucksCooldown int
|
HimbucksCooldown int
|
||||||
HimboardCooldown int
|
HimboardCooldown int
|
||||||
SendbucksCooldown int
|
SendbucksCooldown int
|
||||||
@ -52,6 +55,8 @@ func LoadConfig() *Config {
|
|||||||
MarkovDefaultMessages: getEnvInt("MARKOV_DEFAULT_MESSAGES", 100),
|
MarkovDefaultMessages: getEnvInt("MARKOV_DEFAULT_MESSAGES", 100),
|
||||||
MarkovMaxMessages: getEnvInt("MARKOV_MAX_MESSAGES", 1000),
|
MarkovMaxMessages: getEnvInt("MARKOV_MAX_MESSAGES", 1000),
|
||||||
MarkovCacheSize: getEnvInt("MARKOV_CACHE_SIZE", 10),
|
MarkovCacheSize: getEnvInt("MARKOV_CACHE_SIZE", 10),
|
||||||
|
MarkovMaxNGram: getEnvInt("MARKOV_MAX_NGRAM", 5),
|
||||||
|
MarkovMemoryLimit: getEnvInt("MARKOV_MEMORY_LIMIT_MB", 100),
|
||||||
|
|
||||||
// Database settings
|
// Database settings
|
||||||
MaxOpenConns: getEnvInt("DB_MAX_OPEN_CONNS", 25),
|
MaxOpenConns: getEnvInt("DB_MAX_OPEN_CONNS", 25),
|
||||||
@ -62,6 +67,7 @@ func LoadConfig() *Config {
|
|||||||
PingCooldown: getEnvInt("PING_COOLDOWN_SECONDS", 5),
|
PingCooldown: getEnvInt("PING_COOLDOWN_SECONDS", 5),
|
||||||
HsCooldown: getEnvInt("HS_COOLDOWN_SECONDS", 10),
|
HsCooldown: getEnvInt("HS_COOLDOWN_SECONDS", 10),
|
||||||
MarkovCooldown: getEnvInt("MARKOV_COOLDOWN_SECONDS", 30),
|
MarkovCooldown: getEnvInt("MARKOV_COOLDOWN_SECONDS", 30),
|
||||||
|
MarkovAskCooldown: getEnvInt("MARKOV_ASK_COOLDOWN_SECONDS", 30),
|
||||||
HimbucksCooldown: getEnvInt("HIMBUCKS_COOLDOWN_SECONDS", 5),
|
HimbucksCooldown: getEnvInt("HIMBUCKS_COOLDOWN_SECONDS", 5),
|
||||||
HimboardCooldown: getEnvInt("HIMBOARD_COOLDOWN_SECONDS", 5),
|
HimboardCooldown: getEnvInt("HIMBOARD_COOLDOWN_SECONDS", 5),
|
||||||
SendbucksCooldown: getEnvInt("SENDBUCKS_COOLDOWN_SECONDS", 1800),
|
SendbucksCooldown: getEnvInt("SENDBUCKS_COOLDOWN_SECONDS", 1800),
|
||||||
|
33
main.go
33
main.go
@ -191,8 +191,8 @@ func initCommands(config *lib.Config) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "markov",
|
Name: "gen",
|
||||||
Description: "Why did the Markov chain break up with its partner? Because it couldn't handle the past!",
|
Description: "Generate a random message using markov chains based on channel history",
|
||||||
Options: []*discordgo.ApplicationCommandOption{
|
Options: []*discordgo.ApplicationCommandOption{
|
||||||
{
|
{
|
||||||
Type: discordgo.ApplicationCommandOptionInteger,
|
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",
|
Name: "himbucks",
|
||||||
Description: "Check your himbucks balance",
|
Description: "Check your himbucks balance",
|
||||||
@ -235,11 +253,12 @@ func initCommands(config *lib.Config) {
|
|||||||
// initCommandHandlers initializes command handlers with configuration
|
// initCommandHandlers initializes command handlers with configuration
|
||||||
func initCommandHandlers(config *lib.Config) {
|
func initCommandHandlers(config *lib.Config) {
|
||||||
commandHandlers = map[string]func(s *discordgo.Session, i *discordgo.InteractionCreate){
|
commandHandlers = map[string]func(s *discordgo.Session, i *discordgo.InteractionCreate){
|
||||||
"ping": lib.HandleCommand("ping", time.Duration(config.PingCooldown)*time.Second, command.PingCommand),
|
"ping": lib.HandleCommand("ping", time.Duration(config.PingCooldown)*time.Second, command.PingCommand),
|
||||||
"hs": lib.HandleCommand("hs", time.Duration(config.HsCooldown)*time.Second, command.HsCommand),
|
"hs": lib.HandleCommand("hs", time.Duration(config.HsCooldown)*time.Second, command.HsCommand),
|
||||||
"markov": lib.HandleCommand("markov", time.Duration(config.MarkovCooldown)*time.Second, command.MarkovCommand),
|
"gen": lib.HandleCommand("gen", time.Duration(config.MarkovCooldown)*time.Second, command.MarkovCommand),
|
||||||
"himbucks": lib.HandleCommand("himbucks", time.Duration(config.HimbucksCooldown)*time.Second, command.BalanceGetCommand),
|
"ask": lib.HandleCommand("ask", time.Duration(config.MarkovAskCooldown)*time.Second, command.MarkovQuestionCommand),
|
||||||
"himboard": lib.HandleCommand("himboard", time.Duration(config.HimboardCooldown)*time.Second, command.LeaderboardCommand),
|
"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),
|
"sendbucks": lib.HandleCommand("sendbucks", time.Duration(config.SendbucksCooldown)*time.Second, command.BalanceSendCommand),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user