New features: TG Telegram robot terminal [One-click configuration] and [Subscription conversion]

This commit is contained in:
心隨緣動 2025-10-07 23:33:33 +08:00 committed by GitHub
parent 5d27e4ebdb
commit ec8c3a8d02
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

18
util/common/random.go Normal file
View File

@ -0,0 +1,18 @@
package common
import (
"crypto/rand"
"math/big"
)
// RandomInt 返回一个 0 .. max-1 之间的随机整数(使用 crypto/rand
func RandomInt(max int) int {
if max <= 0 {
return 0
}
n, err := rand.Int(rand.Reader, big.NewInt(int64(max)))
if err != nil {
return 0
}
return int(n.Int64())
}