chore: drop unnessary crypto/rand (#1267)
This commit is contained in:
parent
9a13ed50d0
commit
110fc71349
1 changed files with 5 additions and 11 deletions
|
|
@ -4,11 +4,10 @@ package feishu
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"crypto/rand"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"math/big"
|
"math/rand"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
@ -201,18 +200,13 @@ func (c *FeishuChannel) SendPlaceholder(ctx context.Context, chatID string) (str
|
||||||
func (c *FeishuChannel) ReactToMessage(ctx context.Context, chatID, messageID string) (func(), error) {
|
func (c *FeishuChannel) ReactToMessage(ctx context.Context, chatID, messageID string) (func(), error) {
|
||||||
// Get emoji list from config
|
// Get emoji list from config
|
||||||
emojiList := c.config.RandomReactionEmoji
|
emojiList := c.config.RandomReactionEmoji
|
||||||
|
var chosenEmoji string
|
||||||
if len(emojiList) == 0 {
|
if len(emojiList) == 0 {
|
||||||
// Default to "Pin" if no config
|
// Default to "Pin" if no config
|
||||||
emojiList = []string{"Pin"}
|
chosenEmoji = "Pin"
|
||||||
}
|
|
||||||
|
|
||||||
// Randomly choose one from the list using crypto/rand for better distribution
|
|
||||||
idx, err := rand.Int(rand.Reader, big.NewInt(int64(len(emojiList))))
|
|
||||||
var chosenEmoji string
|
|
||||||
if err != nil {
|
|
||||||
chosenEmoji = emojiList[0]
|
|
||||||
} else {
|
} else {
|
||||||
chosenEmoji = emojiList[idx.Int64()]
|
idx := rand.Intn(len(emojiList))
|
||||||
|
chosenEmoji = emojiList[idx]
|
||||||
}
|
}
|
||||||
|
|
||||||
req := larkim.NewCreateMessageReactionReqBuilder().
|
req := larkim.NewCreateMessageReactionReqBuilder().
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue