diff --git a/irc.go b/irc.go index 696f67b..53aea21 100644 --- a/irc.go +++ b/irc.go @@ -14,9 +14,6 @@ import ( const ( twitchRequestTimeout = 2 * time.Second - // 20 join attempts per 10 seconds per user (2000 for verified bots) - // https://dev.twitch.tv/docs/irc/guide - twitchChannelJoinDelay = time.Second ) const ( @@ -51,6 +48,9 @@ func newIRCHandler() (*ircHandler, error) { User: username, Name: username, Handler: h, + + SendLimit: cfg.IRCRateLimit, + SendBurst: 0, // Twitch uses a bucket system, we don't have anything to replicate that in this IRC client }) h.conn = conn h.user = username @@ -63,9 +63,6 @@ func (i ircHandler) Close() error { return i.conn.Close() } func (i ircHandler) ExecuteJoins(channels []string) { for _, ch := range channels { i.c.Write(fmt.Sprintf("JOIN #%s", strings.TrimLeft(ch, "#"))) - - // We need to wait a moment between joins not to get kicked - time.Sleep(twitchChannelJoinDelay) } } diff --git a/main.go b/main.go index 276d538..784fd02 100644 --- a/main.go +++ b/main.go @@ -20,6 +20,7 @@ var ( cfg = struct { CommandTimeout time.Duration `flag:"command-timeout" default:"30s" description:"Timeout for command execution"` Config string `flag:"config,c" default:"./config.yaml" description:"Location of configuration file"` + IRCRateLimit time.Duration `flag:"rate-limit" default:"1500ms" description:"How often to send a message (default: 20/30s=1500ms, if your bot is mod everywhere: 100/30s=300ms, different for known/verified bots)"` LogLevel string `flag:"log-level" default:"info" description:"Log level (debug, info, warn, error, fatal)"` StorageFile string `flag:"storage-file" default:"./storage.json.gz" description:"Where to store the data"` TwitchClient string `flag:"twitch-client" default:"" description:"Client ID to act as"`