DeepLX/translate/utils.go
Vincent Young a9a5a914b6
refactor
2024-09-16 12:08:13 -04:00

41 lines
790 B
Go

/*
* @Author: Vincent Young
* @Date: 2024-09-16 11:59:24
* @LastEditors: Vincent Young
* @LastEditTime: 2024-09-16 12:06:44
* @FilePath: /DeepLX/translate/utils.go
* @Telegram: https://t.me/missuo
* @GitHub: https://github.com/missuo
*
* Copyright © 2024 by Vincent, All Rights Reserved.
*/
package translate
import (
"math/rand"
"strings"
"time"
)
func getICount(translateText string) int64 {
return int64(strings.Count(translateText, "i"))
}
func getRandomNumber() int64 {
src := rand.NewSource(time.Now().UnixNano())
rng := rand.New(src)
num := rng.Int63n(99999) + 8300000
return num * 1000
}
func getTimeStamp(iCount int64) int64 {
ts := time.Now().UnixMilli()
if iCount != 0 {
iCount = iCount + 1
return ts - ts%iCount + iCount
} else {
return ts
}
}