mirror of
https://github.com/sipeed/picoclaw.git
synced 2026-06-12 18:08:54 +00:00
828971d549
* feat(qq): support media uploads and inbound attachments * docs(qq): document media size limit settings * chore(web): add QQ media size limit hints * fix(qq): demote botgo heartbeat logs * style(qq): fix lint issues
42 lines
936 B
Go
42 lines
936 B
Go
package qq
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"github.com/sipeed/picoclaw/pkg/logger"
|
|
)
|
|
|
|
// botGoLogger preserves useful SDK info logs while demoting noisy heartbeat
|
|
// traffic to DEBUG so long-running QQ sessions do not spam the console.
|
|
type botGoLogger struct {
|
|
*logger.Logger
|
|
}
|
|
|
|
func newBotGoLogger(component string) *botGoLogger {
|
|
return &botGoLogger{Logger: logger.NewLogger(component)}
|
|
}
|
|
|
|
func (b *botGoLogger) Info(v ...any) {
|
|
message := fmt.Sprint(v...)
|
|
if shouldDemoteBotGoInfo(message) {
|
|
b.Logger.Debug(message)
|
|
return
|
|
}
|
|
b.Logger.Info(message)
|
|
}
|
|
|
|
func (b *botGoLogger) Infof(format string, v ...any) {
|
|
message := fmt.Sprintf(format, v...)
|
|
if shouldDemoteBotGoInfo(message) {
|
|
b.Logger.Debug(message)
|
|
return
|
|
}
|
|
b.Logger.Info(message)
|
|
}
|
|
|
|
func shouldDemoteBotGoInfo(message string) bool {
|
|
return strings.Contains(message, " write Heartbeat message") ||
|
|
strings.Contains(message, " receive HeartbeatAck message")
|
|
}
|