regex/doGetNextAutoTopic.go

23 lines
390 B
Go

package main
import (
"strconv"
"strings"
"go.wit.com/log"
)
func doGetNextAutoTopic() {
max := 0
for _, chat := range me.chats.GetChats() {
if strings.HasPrefix(chat.GetChatName(), "Auto ") {
numStr := strings.TrimPrefix(chat.GetChatName(), "Auto ")
num, err := strconv.Atoi(numStr)
if err == nil && num > max {
max = num
}
}
}
log.Printf("Auto %d", max+1)
}