fix: resolve mnd lint issues with named constants
This commit is contained in:
@@ -11,6 +11,15 @@ import (
|
||||
"git.eeqj.de/sneak/chat/cmd/chat-cli/api"
|
||||
)
|
||||
|
||||
const (
|
||||
// splitParts is the number of parts to split a command into (command + args).
|
||||
splitParts = 2
|
||||
// pollTimeout is the long-poll timeout in seconds.
|
||||
pollTimeout = 15
|
||||
// pollRetryDelay is the delay before retrying a failed poll.
|
||||
pollRetryDelay = 2 * time.Second
|
||||
)
|
||||
|
||||
// App holds the application state.
|
||||
type App struct {
|
||||
ui *UI
|
||||
@@ -89,7 +98,7 @@ func (a *App) handleInput(text string) {
|
||||
}
|
||||
|
||||
func (a *App) handleCommand(text string) {
|
||||
parts := strings.SplitN(text, " ", 2)
|
||||
parts := strings.SplitN(text, " ", splitParts)
|
||||
cmd := strings.ToLower(parts[0])
|
||||
|
||||
args := ""
|
||||
@@ -285,8 +294,8 @@ func (a *App) cmdPart(channel string) {
|
||||
}
|
||||
|
||||
func (a *App) cmdMsg(args string) {
|
||||
parts := strings.SplitN(args, " ", 2)
|
||||
if len(parts) < 2 {
|
||||
parts := strings.SplitN(args, " ", splitParts)
|
||||
if len(parts) < splitParts {
|
||||
a.ui.AddStatus("[red]Usage: /msg <nick> <text>")
|
||||
|
||||
return
|
||||
@@ -514,10 +523,10 @@ func (a *App) pollLoop() {
|
||||
return
|
||||
}
|
||||
|
||||
msgs, err := client.PollMessages(lastID, 15)
|
||||
msgs, err := client.PollMessages(lastID, pollTimeout)
|
||||
if err != nil {
|
||||
// Transient error — retry after delay.
|
||||
time.Sleep(2 * time.Second)
|
||||
time.Sleep(pollRetryDelay)
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user