<commit_before>package commands

import (
	"fmt"
	"time"

	"github.com/camd67/moebot/moebot_bot/util/db"
)

type TimerCommand struct {
	StartTime time.Time
}

func (tc *TimerCommand) Execute(pack *CommPackage) {
	pack.session.ChannelMessageSend(pack.message.ChannelID, fmtDuration(time.Since(tc.StartTime)))
}

func fmtDuration(dur time.Duration) string {
	remainingDur := dur.Round(time.Second)
	hours := remainingDur / time.Hour
	remainingDur -= hours * time.Hour
	minutes := remainingDur / time.Minute
	remainingDur -= minutes * time.Minute
	seconds := remainingDur / time.Second
	return fmt.Sprintf("%02d:%02d:%02d", hours, minutes, seconds)
}

func (tc *TimerCommand) GetPermLevel() db.Permission {
	return db.PermAll
}

func (tc *TimerCommand) GetCommandKeys() []string {
	return []string{"TIMER"}
}

func (tc *TimerCommand) GetCommandHelp(commPrefix string) string {
	return fmt.Sprintf("`%[1]s timer` - Checks the timestamp. Moderators may provide the `--start` option to begin start or restart the timer.", commPrefix)
}
<commit_msg>Add option for starting timer<commit_after>package commands

import (
	"fmt"
	"strings"
	"time"

	"github.com/camd67/moebot/moebot_bot/util/db"
)

type TimerCommand struct {
	StartTime time.Time
}

func (tc *TimerCommand) Execute(pack *CommPackage) {
	if len(pack.params) > 0 && strings.EqualFold(pack.params[0], "start") {
		tc.StartTime = time.Now()
		pack.session.ChannelMessageSend(pack.message.ChannelID, "Timer started")
	} else {
		pack.session.ChannelMessageSend(pack.message.ChannelID, fmtDuration(time.Since(tc.StartTime)))
	}
}

func fmtDuration(dur time.Duration) string {
	remainingDur := dur.Round(time.Second)
	hours := remainingDur / time.Hour
	remainingDur -= hours * time.Hour
	minutes := remainingDur / time.Minute
	remainingDur -= minutes * time.Minute
	seconds := remainingDur / time.Second
	return fmt.Sprintf("%02d:%02d:%02d", hours, minutes, seconds)
}

func (tc *TimerCommand) GetPermLevel() db.Permission {
	return db.PermAll
}

func (tc *TimerCommand) GetCommandKeys() []string {
	return []string{"TIMER"}
}

func (tc *TimerCommand) GetCommandHelp(commPrefix string) string {
	return fmt.Sprintf("`%[1]s timer` - Checks the timestamp. Moderators may provide the `--start` option to begin start or restart the timer.", commPrefix)
}

{'fraction_non_alphanumeric': 0.1316818774445893, 'fraction_numerical': 0.008691873098652759, 'mean_word_length': 5.08994708994709, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '104543', 'n_tokens_mistral': 794, 'n_tokens_neox': 761, 'n_words': 184}