package catalogs import ( "encoding/json" "os" "path/filepath" "sync" ) var _ = json.RawMessage{} var _ = sync.Mutex{} var _ = os.ReadFile var _ = filepath.Join // One 趴趴 post instance as the server publishes it, from Configs/BubblePosts.json. type BubblePost4229938 struct { Id uint32 `json:"id"` PostConfigId uint32 `json:"postConfigId"` Publisher uint32 `json:"publisher"` AgentType uint32 `json:"agentType"` Likes uint32 `json:"likes"` Comments []uint32 `json:"comments"` IsStory bool `json:"isStory"` IsPinStory bool `json:"isPinStory"` WithMe bool `json:"withMe"` ImageOssKey string `json:"imageOssKey"` ImageUrl string `json:"imageUrl"` } // // Reads Configs/BubblePosts.json — a projection of the official SocialMediaConfig (55 rows) plus // the publisher → agent-type mapping SocialMediaNPCConfig + NpcCultivationConfig (see // _gen_bubble_posts.py). // The client owns all three tables, so this catalogue deliberately carries only what a server has // to decide: that a post exists, which SocialMediaConfig row it is, and its flags. Everything // displayed (text, images, comment bodies, author name and avatar) stays client-side. // A missing or malformed file is not fatal: the catalogue turns empty and LoadError // explains why, so AskMomentsPostSimpleInfos can answer with an empty list instead of throwing. // var ( BubbleCatalog4229938_cacheLock sync.RWMutex BubbleCatalog4229938_cached = false BubbleCatalog4229938_entries []any ) // LoadBubbleCatalog4229938 loads catalog records from client config directory func LoadBubbleCatalog4229938(configDir string) ([]any, error) { BubbleCatalog4229938_cacheLock.RLock() if BubbleCatalog4229938_cached { defer BubbleCatalog4229938_cacheLock.RUnlock() return BubbleCatalog4229938_entries, nil } BubbleCatalog4229938_cacheLock.RUnlock() BubbleCatalog4229938_cacheLock.Lock() defer BubbleCatalog4229938_cacheLock.Unlock() if BubbleCatalog4229938_cached { return BubbleCatalog4229938_entries, nil } filePath := filepath.Join(configDir, "BubbleCatalog.json.json") data, err := os.ReadFile(filePath) if err != nil { return nil, err } var raw struct { Records []json.RawMessage `json:"records"` } if err := json.Unmarshal(data, &raw); err != nil { return nil, err } var result []any for _, item := range raw.Records { var m map[string]any if err := json.Unmarshal(item, &m); err == nil { result = append(result, m) } } BubbleCatalog4229938_entries = result BubbleCatalog4229938_cached = true return result, nil }