497 lines
19 KiB
Go
497 lines
19 KiB
Go
package creator
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
)
|
|
|
|
const (
|
|
PlatformDouyin = "douyin"
|
|
PlatformXiaohongshu = "xiaohongshu"
|
|
|
|
SourceOwned = "owned"
|
|
SourceCompetitor = "competitor"
|
|
|
|
ActionDM = "dm"
|
|
ActionReplyComment = "reply_comment"
|
|
ActionLikeComment = "like_comment"
|
|
ActionLikeWork = "like_work"
|
|
ActionFollow = "follow"
|
|
ActionRepost = "repost"
|
|
|
|
MessageTypeText = "text"
|
|
MessageTypeImage = "image"
|
|
MessageTypeVoice = "voice"
|
|
MessageTypeVideo = "video"
|
|
MessageTypeSticker = "sticker"
|
|
MessageTypeUnknown = "non_text"
|
|
)
|
|
|
|
type Settings struct {
|
|
LookbackDays int `json:"lookback_days"`
|
|
NewWorkIntervalSeconds int64 `json:"new_work_interval_seconds"`
|
|
MetricInitialIntervalSeconds int64 `json:"metric_initial_interval_seconds"`
|
|
MetricMultiplier float64 `json:"metric_multiplier"`
|
|
MetricMaxIntervalSeconds int64 `json:"metric_max_interval_seconds"`
|
|
MetricAgeSeconds int64 `json:"metric_age_seconds"`
|
|
AIProvider string `json:"ai_provider"`
|
|
AIModel string `json:"ai_model"`
|
|
AIConfigured bool `json:"ai_configured"`
|
|
TranscriptionProvider string `json:"transcription_provider"`
|
|
TranscriptionModel string `json:"transcription_model"`
|
|
TranscriptionConfigured bool `json:"transcription_configured"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
type SettingsUpdate struct {
|
|
LookbackDays int `json:"lookback_days"`
|
|
NewWorkIntervalSeconds int64 `json:"new_work_interval_seconds"`
|
|
MetricInitialIntervalSeconds int64 `json:"metric_initial_interval_seconds"`
|
|
MetricMultiplier float64 `json:"metric_multiplier"`
|
|
MetricMaxIntervalSeconds int64 `json:"metric_max_interval_seconds"`
|
|
MetricAgeSeconds int64 `json:"metric_age_seconds"`
|
|
AIProvider string `json:"ai_provider"`
|
|
AIModel string `json:"ai_model"`
|
|
AIConfigured bool `json:"ai_configured"`
|
|
TranscriptionProvider string `json:"transcription_provider"`
|
|
TranscriptionModel string `json:"transcription_model"`
|
|
TranscriptionConfigured bool `json:"transcription_configured"`
|
|
}
|
|
|
|
type AccountProfile struct {
|
|
ID string `json:"id"`
|
|
Name string `json:"name"`
|
|
Platform string `json:"platform"`
|
|
PlatformAccountKey string `json:"platform_account_key"`
|
|
AuthorizationStatus string `json:"authorization_status"`
|
|
RuntimeStatus string `json:"runtime_status"`
|
|
LoginUsername string `json:"login_username"`
|
|
PasswordConfigured bool `json:"password_configured"`
|
|
RealNameStatus string `json:"real_name_status"`
|
|
RealName string `json:"real_name"`
|
|
IdentityNumber string `json:"identity_number"`
|
|
Note string `json:"note"`
|
|
BusinessStatus string `json:"business_status"`
|
|
BigAccount bool `json:"big_account"`
|
|
ReplyRequirements string `json:"reply_requirements"`
|
|
LoginStatus string `json:"login_status"`
|
|
LoginReason string `json:"login_reason"`
|
|
LoginCheckedAt *time.Time `json:"login_checked_at,omitempty"`
|
|
CooldownSeconds int64 `json:"cooldown_seconds"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
type AccountProfileUpdate struct {
|
|
LoginUsername string `json:"login_username"`
|
|
Password string `json:"password"`
|
|
RealNameStatus string `json:"real_name_status"`
|
|
RealName string `json:"real_name"`
|
|
IdentityNumber string `json:"identity_number"`
|
|
Note string `json:"note"`
|
|
BusinessStatus string `json:"business_status"`
|
|
BigAccount bool `json:"big_account"`
|
|
ReplyRequirements string `json:"reply_requirements"`
|
|
CooldownSeconds int64 `json:"cooldown_seconds"`
|
|
}
|
|
|
|
type LoginResult struct {
|
|
AccountID string `json:"account_id"`
|
|
Status string `json:"status"`
|
|
Reason string `json:"reason"`
|
|
ActualKey string `json:"actual_platform_account_key,omitempty"`
|
|
CheckedAt time.Time `json:"checked_at"`
|
|
}
|
|
|
|
type Competitor struct {
|
|
ID string `json:"id"`
|
|
Platform string `json:"platform"`
|
|
PlatformAccountKey string `json:"platform_account_key"`
|
|
Nickname string `json:"nickname"`
|
|
AvatarURL string `json:"avatar_url"`
|
|
HomepageURL string `json:"homepage_url"`
|
|
Enabled bool `json:"enabled"`
|
|
SyncStatus string `json:"sync_status"`
|
|
SyncCursor string `json:"sync_cursor,omitempty"`
|
|
SyncError string `json:"sync_error,omitempty"`
|
|
SyncLeaseUntil *time.Time `json:"sync_lease_until,omitempty"`
|
|
LastSyncAt *time.Time `json:"last_sync_at,omitempty"`
|
|
NextSyncAt *time.Time `json:"next_sync_at,omitempty"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
type CompetitorInput struct {
|
|
Platform string `json:"platform"`
|
|
PlatformAccountKey string `json:"platform_account_key"`
|
|
Nickname string `json:"nickname"`
|
|
AvatarURL string `json:"avatar_url"`
|
|
HomepageURL string `json:"homepage_url"`
|
|
}
|
|
|
|
type WorkSource struct {
|
|
Platform string `json:"platform"`
|
|
SourceType string `json:"source_type"`
|
|
SourceID string `json:"source_id"`
|
|
}
|
|
|
|
type Work struct {
|
|
ID string `json:"id"`
|
|
Platform string `json:"platform"`
|
|
WorkKey string `json:"work_key"`
|
|
SourceType string `json:"source_type"`
|
|
SourceID string `json:"source_id"`
|
|
Sources []WorkSource `json:"sources,omitempty"`
|
|
AuthorName string `json:"author_name"`
|
|
Title string `json:"title"`
|
|
Body string `json:"body"`
|
|
PublishedAt *time.Time `json:"published_at,omitempty"`
|
|
PublishedAtStatus string `json:"published_at_status"`
|
|
OriginalURL string `json:"original_url"`
|
|
CoverURL string `json:"cover_url"`
|
|
Likes *int64 `json:"likes"`
|
|
CommentsCount *int64 `json:"comments_count"`
|
|
Shares *int64 `json:"shares"`
|
|
LatestMetricsAt *time.Time `json:"latest_metrics_at,omitempty"`
|
|
NextMetricAt *time.Time `json:"next_metric_at,omitempty"`
|
|
MetricStopReason string `json:"metric_stop_reason,omitempty"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
RawPayload string `json:"-"`
|
|
}
|
|
|
|
type WorkInput struct {
|
|
Platform string `json:"platform"`
|
|
WorkKey string `json:"work_key"`
|
|
SourceType string `json:"source_type"`
|
|
SourceID string `json:"source_id"`
|
|
AuthorName string `json:"author_name"`
|
|
Title string `json:"title"`
|
|
Body string `json:"body"`
|
|
PublishedAt *time.Time `json:"published_at"`
|
|
PublishedAtStatus string `json:"published_at_status"`
|
|
OriginalURL string `json:"original_url"`
|
|
CoverURL string `json:"cover_url"`
|
|
Likes *int64 `json:"likes"`
|
|
CommentsCount *int64 `json:"comments_count"`
|
|
Shares *int64 `json:"shares"`
|
|
RawPayload string `json:"-"`
|
|
}
|
|
|
|
type WorkFilter struct {
|
|
Platform string
|
|
SourceID string
|
|
PublishedAtStatus string
|
|
SourceType string
|
|
PublishedAfter *time.Time
|
|
PublishedBefore *time.Time
|
|
MinLikes *int64
|
|
MinComments *int64
|
|
MinShares *int64
|
|
}
|
|
|
|
type MetricInput struct {
|
|
WorkID string
|
|
CollectedAt time.Time
|
|
Likes *int64
|
|
CommentsCount *int64
|
|
Shares *int64
|
|
}
|
|
|
|
type MetricPoint struct {
|
|
CollectedAt time.Time `json:"collected_at"`
|
|
Likes *int64 `json:"likes"`
|
|
CommentsCount *int64 `json:"comments_count"`
|
|
Shares *int64 `json:"shares"`
|
|
}
|
|
|
|
type MaterialJob struct {
|
|
WorkID string `json:"work_id"`
|
|
Selected bool `json:"selected"`
|
|
SelectConfirmedAt *time.Time `json:"select_confirmed_at,omitempty"`
|
|
DownloadStatus string `json:"download_status"`
|
|
VideoReference string `json:"video_reference,omitempty"`
|
|
AudioStatus string `json:"audio_status"`
|
|
AudioReference string `json:"audio_reference,omitempty"`
|
|
TranscriptionStatus string `json:"transcription_status"`
|
|
Transcript string `json:"transcript,omitempty"`
|
|
FailedStep string `json:"failed_step,omitempty"`
|
|
FailureReason string `json:"failure_reason,omitempty"`
|
|
RewriteConfirmedAt *time.Time `json:"rewrite_confirmed_at,omitempty"`
|
|
RewriteRequirement string `json:"rewrite_requirement,omitempty"`
|
|
GeneratedTitle string `json:"generated_title,omitempty"`
|
|
GeneratedScript string `json:"generated_script,omitempty"`
|
|
ProcessingStep string `json:"processing_step,omitempty"`
|
|
ProcessingToken string `json:"processing_token,omitempty"`
|
|
ProcessingStartedAt *time.Time `json:"processing_started_at,omitempty"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
type Comment struct {
|
|
ID string `json:"id"`
|
|
Platform string `json:"platform"`
|
|
CommentKey string `json:"comment_key"`
|
|
WorkID string `json:"work_id"`
|
|
AuthorUID string `json:"author_uid,omitempty"`
|
|
AuthorName string `json:"author_name,omitempty"`
|
|
Content string `json:"content"`
|
|
PublishedAt *time.Time `json:"published_at,omitempty"`
|
|
CollectedAt time.Time `json:"collected_at"`
|
|
CommentType string `json:"comment_type"`
|
|
RawPayload string `json:"-"`
|
|
}
|
|
|
|
type CommentInput struct {
|
|
Platform string `json:"platform"`
|
|
CommentKey string `json:"comment_key"`
|
|
WorkID string `json:"work_id"`
|
|
AuthorUID string `json:"author_uid"`
|
|
AuthorName string `json:"author_name"`
|
|
Content string `json:"content"`
|
|
PublishedAt *time.Time `json:"published_at"`
|
|
CommentType string `json:"comment_type"`
|
|
RawPayload string `json:"-"`
|
|
}
|
|
|
|
type LeadRule struct {
|
|
ID string `json:"id"`
|
|
Name string `json:"name"`
|
|
Enabled bool `json:"enabled"`
|
|
SourceType string `json:"source_type"`
|
|
Topic string `json:"topic"`
|
|
IncludeKeywords []string `json:"include_keywords"`
|
|
ExcludeKeywords []string `json:"exclude_keywords"`
|
|
AIRequirement string `json:"ai_requirement"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
type LeadRuleInput struct {
|
|
Name string `json:"name"`
|
|
Enabled bool `json:"enabled"`
|
|
SourceType string `json:"source_type"`
|
|
Topic string `json:"topic"`
|
|
IncludeKeywords []string `json:"include_keywords"`
|
|
ExcludeKeywords []string `json:"exclude_keywords"`
|
|
AIRequirement string `json:"ai_requirement"`
|
|
}
|
|
|
|
type RuleResult struct {
|
|
CommentID string `json:"comment_id"`
|
|
RuleID string `json:"rule_id"`
|
|
Status string `json:"status"`
|
|
Reason string `json:"reason"`
|
|
MatchedKeywords []string `json:"matched_keywords"`
|
|
RuleSnapshot LeadRule `json:"rule_snapshot"`
|
|
AnalysedAt *time.Time `json:"analysed_at,omitempty"`
|
|
}
|
|
|
|
type RuleAnalysisItem struct {
|
|
CommentID string `json:"comment_id"`
|
|
Result *RuleResult `json:"result,omitempty"`
|
|
Error string `json:"error,omitempty"`
|
|
}
|
|
|
|
type Lead struct {
|
|
Comment Comment `json:"comment"`
|
|
RuleIDs []string `json:"rule_ids"`
|
|
Results []RuleResult `json:"results"`
|
|
}
|
|
|
|
type Strategy struct {
|
|
ID string `json:"id"`
|
|
BigAccountID string `json:"big_account_id"`
|
|
ExecutionAccountID string `json:"execution_account_id"`
|
|
Position int `json:"position"`
|
|
Enabled bool `json:"enabled"`
|
|
EventTypes []string `json:"event_types"`
|
|
Action string `json:"action"`
|
|
TargetType string `json:"target_type"`
|
|
CandidateTexts []string `json:"candidate_texts"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
type StrategyInput struct {
|
|
ExecutionAccountID string `json:"execution_account_id"`
|
|
Position int `json:"position"`
|
|
Enabled bool `json:"enabled"`
|
|
EventTypes []string `json:"event_types"`
|
|
Action string `json:"action"`
|
|
TargetType string `json:"target_type"`
|
|
CandidateTexts []string `json:"candidate_texts"`
|
|
}
|
|
|
|
type Relation struct {
|
|
BigAccountID string `json:"big_account_id"`
|
|
SmallAccountID string `json:"small_account_id"`
|
|
}
|
|
|
|
type ListenerState struct {
|
|
AccountID string `json:"account_id"`
|
|
Platform string `json:"platform"`
|
|
Generation string `json:"generation"`
|
|
Status string `json:"status"`
|
|
BoundaryAt *time.Time `json:"boundary_at,omitempty"`
|
|
LastDeliveryID string `json:"last_delivery_id,omitempty"`
|
|
Reason string `json:"reason,omitempty"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
SessionToken string `json:"-"`
|
|
Invalidated bool `json:"-"`
|
|
}
|
|
|
|
type Page[T any] struct {
|
|
Data []T `json:"data"`
|
|
Page int `json:"page"`
|
|
PageSize int `json:"page_size"`
|
|
Total int `json:"total"`
|
|
HasNext bool `json:"has_next"`
|
|
}
|
|
|
|
type InteractionEvent struct {
|
|
ID string `json:"id"`
|
|
Platform string `json:"platform"`
|
|
Generation string `json:"generation,omitempty"`
|
|
ReceivingAccountID string `json:"receiving_account_id"`
|
|
EventKey string `json:"event_key"`
|
|
EventType string `json:"event_type"`
|
|
Baseline bool `json:"baseline,omitempty"`
|
|
BaselineReason string `json:"-"`
|
|
InteractorUID string `json:"interactor_uid"`
|
|
CommentID string `json:"comment_id"`
|
|
WorkID string `json:"work_id"`
|
|
MessageType string `json:"message_type"`
|
|
MessageText string `json:"message_text,omitempty"`
|
|
PlatformEventAt *time.Time `json:"platform_event_at,omitempty"`
|
|
GatewayReceivedAt *time.Time `json:"gateway_received_at,omitempty"`
|
|
ReceivedAt time.Time `json:"received_at"`
|
|
ProcessingStartedAt *time.Time `json:"processing_started_at,omitempty"`
|
|
ProcessingFinishedAt *time.Time `json:"processing_finished_at,omitempty"`
|
|
DisplayedAt *time.Time `json:"displayed_at,omitempty"`
|
|
State string `json:"state"`
|
|
Reason string `json:"reason,omitempty"`
|
|
StrategyID string `json:"strategy_id,omitempty"`
|
|
ExecutionAccountID string `json:"execution_account_id,omitempty"`
|
|
}
|
|
|
|
type Operation struct {
|
|
ID string `json:"id"`
|
|
IdempotencyKey string `json:"idempotency_key"`
|
|
Source string `json:"source"`
|
|
Action string `json:"action"`
|
|
Platform string `json:"platform"`
|
|
AccountID string `json:"account_id"`
|
|
TargetUID string `json:"target_uid,omitempty"`
|
|
TargetCommentID string `json:"target_comment_id,omitempty"`
|
|
TargetWorkID string `json:"target_work_id,omitempty"`
|
|
Text string `json:"text,omitempty"`
|
|
EventID string `json:"event_id,omitempty"`
|
|
StrategyID string `json:"strategy_id,omitempty"`
|
|
State string `json:"state"`
|
|
Evidence map[string]string `json:"evidence"`
|
|
Reason string `json:"reason,omitempty"`
|
|
VerificationState string `json:"verification_state"`
|
|
VerificationProof map[string]string `json:"verification_evidence"`
|
|
VerifiedAt *time.Time `json:"verified_at,omitempty"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
type OperationInput struct {
|
|
IdempotencyKey string `json:"idempotency_key"`
|
|
Source string `json:"source"`
|
|
Action string `json:"action"`
|
|
Platform string `json:"platform"`
|
|
AccountID string `json:"account_id"`
|
|
TargetUID string `json:"target_uid"`
|
|
TargetCommentID string `json:"target_comment_id"`
|
|
TargetWorkID string `json:"target_work_id"`
|
|
Text string `json:"text"`
|
|
EventID string `json:"event_id"`
|
|
StrategyID string `json:"strategy_id"`
|
|
}
|
|
|
|
type Conversation struct {
|
|
ID string `json:"id"`
|
|
Platform string `json:"platform"`
|
|
AccountID string `json:"account_id"`
|
|
PeerUID string `json:"peer_uid"`
|
|
PeerName string `json:"peer_name"`
|
|
LastMessageAt *time.Time `json:"last_message_at,omitempty"`
|
|
HistoryCursor string `json:"history_cursor,omitempty"`
|
|
HistoryHasMore bool `json:"history_has_more,omitempty"`
|
|
HistorySyncedAt *time.Time `json:"history_synced_at,omitempty"`
|
|
}
|
|
|
|
type Message struct {
|
|
ID string `json:"id"`
|
|
ConversationID string `json:"conversation_id"`
|
|
PlatformMessageKey string `json:"platform_message_key"`
|
|
OperationID string `json:"operation_id,omitempty"`
|
|
Direction string `json:"direction"`
|
|
MessageType string `json:"message_type"`
|
|
Text string `json:"text,omitempty"`
|
|
SentState string `json:"sent_state"`
|
|
MessageAt *time.Time `json:"message_at,omitempty"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
type MessageInput struct {
|
|
Platform string `json:"platform"`
|
|
AccountID string `json:"account_id"`
|
|
PeerUID string `json:"peer_uid"`
|
|
PeerName string `json:"peer_name"`
|
|
PlatformMessageKey string `json:"platform_message_key"`
|
|
OperationID string `json:"operation_id,omitempty"`
|
|
Direction string `json:"direction"`
|
|
MessageType string `json:"message_type"`
|
|
Text string `json:"text"`
|
|
SentState string `json:"sent_state"`
|
|
MessageAt *time.Time `json:"message_at"`
|
|
}
|
|
|
|
type ActionRequest struct {
|
|
OperationID string
|
|
Action string
|
|
Platform string
|
|
AccountID string
|
|
TargetUID string
|
|
TargetCommentID string
|
|
TargetWorkID string
|
|
Text string
|
|
}
|
|
|
|
type ActionResult struct {
|
|
State string
|
|
Evidence map[string]string
|
|
Reason string
|
|
}
|
|
|
|
type AutomaticResult struct {
|
|
Event InteractionEvent `json:"event"`
|
|
Operation *Operation `json:"operation,omitempty"`
|
|
Duplicate bool `json:"duplicate"`
|
|
}
|
|
|
|
type StrategyTrace struct {
|
|
EventID string `json:"event_id"`
|
|
StrategyID string `json:"strategy_id"`
|
|
Position int `json:"position"`
|
|
Outcome string `json:"outcome"`
|
|
Reason string `json:"reason,omitempty"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
type ActionExecutor interface {
|
|
Execute(context.Context, ActionRequest) (ActionResult, error)
|
|
}
|
|
|
|
type TextGenerator interface {
|
|
Generate(context.Context, string, string) (string, error)
|
|
}
|
|
|
|
type ThemeAnalyzer interface {
|
|
MatchTheme(context.Context, string, string, string) (bool, string, error)
|
|
MatchLead(context.Context, string, string, string) (bool, string, error)
|
|
}
|