fix los buguos
This commit is contained in:
+2
-1
@@ -38,7 +38,8 @@ func (client Client) GenerateContent(content []*genai.Content) (*genai.GenerateC
|
||||
client.model,
|
||||
content,
|
||||
&genai.GenerateContentConfig{
|
||||
Temperature: &temp,
|
||||
Temperature: &temp,
|
||||
MaxOutputTokens: 800,
|
||||
SystemInstruction: &genai.Content{
|
||||
Role: "system",
|
||||
Parts: []*genai.Part{
|
||||
|
||||
@@ -16,6 +16,8 @@ import (
|
||||
|
||||
const MAX_HISTORY = 50
|
||||
|
||||
const DISCORD_MAX_CHAR = 4000
|
||||
|
||||
const (
|
||||
SPAM_PERIOD = 5 * time.Minute
|
||||
MESSAGES_PER_PERIOD = 10
|
||||
@@ -118,11 +120,19 @@ func cleanMessage(p string) string {
|
||||
}
|
||||
|
||||
func sendResponse(s *discordgo.Session, channelID string, response string) {
|
||||
if _, err := s.ChannelMessageSend(channelID, response); err != nil {
|
||||
if _, err := s.ChannelMessageSend(channelID, truncateIfNeeded(response)); err != nil {
|
||||
log.Printf("\nfailed to send the response [%s] to the discord channel [%s]", response, err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func truncateIfNeeded(response string) string {
|
||||
if len(response) > DISCORD_MAX_CHAR {
|
||||
return response
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%s %s", response[:3990], "[...]")
|
||||
}
|
||||
|
||||
func containHal(users []*discordgo.User, userID string) bool {
|
||||
for _, u := range users {
|
||||
if u.ID == userID {
|
||||
|
||||
Reference in New Issue
Block a user