style(qq): fix lint issues

This commit is contained in:
Hoshina 2026-03-18 14:03:50 +08:00
parent 441116450a
commit 55feab5641
4 changed files with 18 additions and 18 deletions

View file

@ -17,7 +17,7 @@ func newBotGoLogger(component string) *botGoLogger {
return &botGoLogger{Logger: logger.NewLogger(component)} return &botGoLogger{Logger: logger.NewLogger(component)}
} }
func (b *botGoLogger) Info(v ...interface{}) { func (b *botGoLogger) Info(v ...any) {
message := fmt.Sprint(v...) message := fmt.Sprint(v...)
if shouldDemoteBotGoInfo(message) { if shouldDemoteBotGoInfo(message) {
b.Logger.Debug(message) b.Logger.Debug(message)
@ -26,7 +26,7 @@ func (b *botGoLogger) Info(v ...interface{}) {
b.Logger.Info(message) b.Logger.Info(message)
} }
func (b *botGoLogger) Infof(format string, v ...interface{}) { func (b *botGoLogger) Infof(format string, v ...any) {
message := fmt.Sprintf(format, v...) message := fmt.Sprintf(format, v...)
if shouldDemoteBotGoInfo(message) { if shouldDemoteBotGoInfo(message) {
b.Logger.Debug(message) b.Logger.Debug(message)

View file

@ -51,7 +51,7 @@ type qqAPI interface {
PostC2CMessage( PostC2CMessage(
ctx context.Context, userID string, msg dto.APIMessage, opt ...options.Option, ctx context.Context, userID string, msg dto.APIMessage, opt ...options.Option,
) (*dto.Message, error) ) (*dto.Message, error)
Transport(ctx context.Context, method, url string, body interface{}) ([]byte, error) Transport(ctx context.Context, method, url string, body any) ([]byte, error)
} }
type QQChannel struct { type QQChannel struct {
@ -413,9 +413,9 @@ func (c *QQChannel) buildMediaUpload(part bus.MediaPart) (*qqMediaUpload, error)
} }
if limitBytes := c.maxBase64FileSizeBytes(); limitBytes > 0 { if limitBytes := c.maxBase64FileSizeBytes(); limitBytes > 0 {
info, err := os.Stat(resolved) info, statErr := os.Stat(resolved)
if err != nil { if statErr != nil {
return nil, fmt.Errorf("qq stat local media %q: %v: %w", resolved, err, channels.ErrSendFailed) return nil, fmt.Errorf("qq stat local media %q: %v: %w", resolved, statErr, channels.ErrSendFailed)
} }
if info.Size() > limitBytes { if info.Size() > limitBytes {
return nil, fmt.Errorf( return nil, fmt.Errorf(

View file

@ -179,8 +179,8 @@ func TestSendMedia_UploadsLocalFileAsBase64(t *testing.T) {
defer tmpFile.Close() defer tmpFile.Close()
content := []byte("local-image-data") content := []byte("local-image-data")
if _, err := tmpFile.Write(content); err != nil { if _, writeErr := tmpFile.Write(content); writeErr != nil {
t.Fatalf("Write() error = %v", err) t.Fatalf("Write() error = %v", writeErr)
} }
ref, err := store.Store(tmpFile.Name(), media.MediaMeta{ ref, err := store.Store(tmpFile.Name(), media.MediaMeta{
@ -357,8 +357,8 @@ func TestSendMedia_ReturnsSendFailedWhenLocalFileExceedsBase64MiBLimit(t *testin
defer tmpFile.Close() defer tmpFile.Close()
content := make([]byte, bytesPerMiB+1) content := make([]byte, bytesPerMiB+1)
if _, err := tmpFile.Write(content); err != nil { if _, writeErr := tmpFile.Write(content); writeErr != nil {
t.Fatalf("Write() error = %v", err) t.Fatalf("Write() error = %v", writeErr)
} }
ref, err := store.Store(tmpFile.Name(), media.MediaMeta{ ref, err := store.Store(tmpFile.Name(), media.MediaMeta{
@ -443,7 +443,7 @@ func (f *fakeQQAPI) PostC2CMessage(
return &dto.Message{}, f.c2cErr return &dto.Message{}, f.c2cErr
} }
func (f *fakeQQAPI) Transport(_ context.Context, method, url string, body interface{}) ([]byte, error) { func (f *fakeQQAPI) Transport(_ context.Context, method, url string, body any) ([]byte, error) {
upload, ok := body.(*qqMediaUpload) upload, ok := body.(*qqMediaUpload)
if !ok { if !ok {
return nil, errors.New("unexpected transport body type") return nil, errors.New("unexpected transport body type")

View file

@ -347,15 +347,15 @@ type MaixCamConfig struct {
} }
type QQConfig struct { type QQConfig struct {
Enabled bool `json:"enabled" env:"PICOCLAW_CHANNELS_QQ_ENABLED"` Enabled bool `json:"enabled" env:"PICOCLAW_CHANNELS_QQ_ENABLED"`
AppID string `json:"app_id" env:"PICOCLAW_CHANNELS_QQ_APP_ID"` AppID string `json:"app_id" env:"PICOCLAW_CHANNELS_QQ_APP_ID"`
AppSecret string `json:"app_secret" env:"PICOCLAW_CHANNELS_QQ_APP_SECRET"` AppSecret string `json:"app_secret" env:"PICOCLAW_CHANNELS_QQ_APP_SECRET"`
AllowFrom FlexibleStringSlice `json:"allow_from" env:"PICOCLAW_CHANNELS_QQ_ALLOW_FROM"` AllowFrom FlexibleStringSlice `json:"allow_from" env:"PICOCLAW_CHANNELS_QQ_ALLOW_FROM"`
GroupTrigger GroupTriggerConfig `json:"group_trigger,omitempty"` GroupTrigger GroupTriggerConfig `json:"group_trigger,omitempty"`
MaxMessageLength int `json:"max_message_length" env:"PICOCLAW_CHANNELS_QQ_MAX_MESSAGE_LENGTH"` MaxMessageLength int `json:"max_message_length" env:"PICOCLAW_CHANNELS_QQ_MAX_MESSAGE_LENGTH"`
MaxBase64FileSizeMiB int64 `json:"max_base64_file_size_mib" env:"PICOCLAW_CHANNELS_QQ_MAX_BASE64_FILE_SIZE_MIB"` MaxBase64FileSizeMiB int64 `json:"max_base64_file_size_mib" env:"PICOCLAW_CHANNELS_QQ_MAX_BASE64_FILE_SIZE_MIB"`
SendMarkdown bool `json:"send_markdown" env:"PICOCLAW_CHANNELS_QQ_SEND_MARKDOWN"` SendMarkdown bool `json:"send_markdown" env:"PICOCLAW_CHANNELS_QQ_SEND_MARKDOWN"`
ReasoningChannelID string `json:"reasoning_channel_id" env:"PICOCLAW_CHANNELS_QQ_REASONING_CHANNEL_ID"` ReasoningChannelID string `json:"reasoning_channel_id" env:"PICOCLAW_CHANNELS_QQ_REASONING_CHANNEL_ID"`
} }
type DingTalkConfig struct { type DingTalkConfig struct {