fix los buguos

This commit is contained in:
unintendedfraud
2025-05-22 12:43:10 +02:00
parent fb3f2261de
commit f11ca7d61f
2 changed files with 13 additions and 2 deletions
+2 -1
View File
@@ -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{
+11 -1
View File
@@ -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 {