Files
goodBaby/drivers/bilibili/bilibili.go
T

32 lines
680 B
Go
Raw Normal View History

2026-04-05 10:36:22 +08:00
package bilibili
import (
"context"
2026-07-26 22:19:41 +08:00
"fmt"
2026-04-05 10:36:22 +08:00
"github.com/CuteReimu/bilibili/v2"
2026-07-26 22:19:41 +08:00
"github.com/ssdomei232/goodBaby/internal/retry"
2026-04-05 10:36:22 +08:00
)
2026-09-12 15:32:27 +08:00
// SendDynamic 用给定账号发送一条 B 站动态
2026-04-05 10:36:22 +08:00
//
// 暂时没有处理 429 和 403 的区别对待
2026-09-12 15:32:27 +08:00
func SendDynamic(ctx context.Context, account *BiliAccount, config *BiliDynamicConfig) error {
client := newClient(account.RawCookies)
params := bilibili.CreateDynamicParam{
2026-04-05 10:36:22 +08:00
DynamicId: 0,
Type: 4,
Rid: 0,
2026-09-12 15:32:27 +08:00
Content: config.Msg,
2026-04-05 10:36:22 +08:00
}
2026-07-26 22:19:41 +08:00
if err := retry.Do(ctx, func() error {
2026-09-12 15:32:27 +08:00
_, err := client.CreateDynamic(params)
2026-07-26 22:19:41 +08:00
return err
}); err != nil {
return fmt.Errorf("发送B站动态失败: %w", err)
2026-04-05 10:36:22 +08:00
}
2026-07-26 22:19:41 +08:00
return nil
2026-04-05 10:36:22 +08:00
}