service

package
v0.0.0-...-7b2405d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 8, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BaseURL   = "https://api.zsxq.com/v2"
	UserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36"
)

Functions

func ParseCookies

func ParseCookies(cookie string, v interface{}) (err error)

ParseCookies parse cookie string to cookie options

Types

type Answer

type Answer struct {
	Owner  User    `json:"owner"`  // 回答者
	Text   string  `json:"text"`   // 回答内容
	Images []Image `json:"images"` // 回答图片
}

type Article

type Article struct {
	Title            string `json:"title"`
	ArticleID        string `json:"article_id"`
	ArticleURL       string `json:"article_url"`
	InlineArticleUrl string `json:"inline_article_url"`
}

type Column

type Column struct {
	ColumnId   int64  `json:"column_id"`
	Name       string `json:"name"`
	CoverUrl   string `json:"cover_url"`
	Statistics struct {
		TopicsCount int `json:"topics_count"`
	} `json:"statistics"`
	CreateTime          string `json:"create_time"`
	LastTopicAttachTime string `json:"last_topic_attach_time"`
}

type ColumnTopic

type ColumnTopic struct {
	TopicId              int64  `json:"topic_id"`
	Title                string `json:"title"`
	Text                 string `json:"text"`
	CreateTime           string `json:"create_time"`
	AttachedToColumnTime string `json:"attached_to_column_time"`
}

type ColumnTopics

type ColumnTopics struct {
	Topics []ColumnTopic `json:"topics,omitempty"`
}

type Columns

type Columns struct {
	Columns []Column `json:"columns"`
}

type Comment

type Comment struct {
	CommentId       int64   `json:"comment_id"`
	CreateTime      string  `json:"create_time"`
	Owner           User    `json:"owner"`
	Text            string  `json:"text"`
	LikesCount      int     `json:"likes_count"`
	RewardsCount    int     `json:"rewards_count"`
	Sticky          bool    `json:"sticky"`
	Images          []Image `json:"images,omitempty"`
	RepliesCount    int     `json:"replies_count,omitempty"`
	RepliedComments []struct {
		CommentId       int64  `json:"comment_id"`
		ParentCommentId int64  `json:"parent_comment_id"`
		CreateTime      string `json:"create_time"`
		Owner           User   `json:"owner"`
		Text            string `json:"text"`
		LikesCount      int    `json:"likes_count"`
		RewardsCount    int    `json:"rewards_count"`
		Sticky          bool   `json:"sticky"`
		Repliee         User   `json:"repliee"`
	} `json:"replied_comments,omitempty"`
}

type Comments

type Comments struct {
	Comments []Comment `json:"comments"`
}

type CookieOptions

type CookieOptions struct {
	Zsxqsessionid   string `json:"zsxqsessionid"`
	AbtestEnv       string `json:"abtest_env" mapstructure:"abtest_env"`
	ZsxqAccessToken string `json:"zsxq_access_token" mapstructure:"zsxq_access_token"`
	UabCollina      string `json:"_uab_collina" mapstructure:"_uab_collina"`
	Debug           bool   `json:"debug"`
}

CookieOptions dedao cookie options

type File

type File struct {
	FileId        int64  `json:"file_id"`
	Name          string `json:"name"`
	Hash          string `json:"hash"`
	Size          int    `json:"size"`
	DownloadCount int    `json:"download_count"`
	CreateTime    string `json:"create_time"`
	Duration      int    `json:"duration"`
}

type Group

type Group struct {
	GroupId       int64  `json:"group_id"`
	Name          string `json:"name"`
	Type          string `json:"type"`
	BackgroundURL string `json:"background_url"`
}

type GroupInfo

type GroupInfo struct {
	GroupId                          int64  `json:"group_id"`
	Number                           int    `json:"number"`
	Name                             string `json:"name"`
	Description                      string `json:"description"`
	CreateTime                       string `json:"create_time"`
	UpdateTime                       string `json:"update_time"`
	PrivilegeUserLastTopicCreateTime string `json:"privilege_user_last_topic_create_time"`
	LatestTopicCreateTime            string `json:"latest_topic_create_time"`
	AliveTime                        string `json:"alive_time"`
	BackgroundUrl                    string `json:"background_url"`
	Type                             string `json:"type"`
	RiskLevel                        string `json:"risk_level"`
	Category                         struct {
		CategoryId int    `json:"category_id"`
		Title      string `json:"title"`
	} `json:"category"`
	Owner      User          `json:"owner"`
	AdminIds   []int64       `json:"admin_ids"`
	GuestIds   []int64       `json:"guest_ids"`
	PartnerIds []int64       `json:"partner_ids"`
	Promos     []interface{} `json:"promos"`
	Policies   struct {
		NeedExamine             bool   `json:"need_examine"`
		EnableScoreboard        bool   `json:"enable_scoreboard"`
		FreeQuestionsLimitCount int    `json:"free_questions_limit_count"`
		EnableMemberNumber      bool   `json:"enable_member_number"`
		MembersVisibility       string `json:"members_visibility"`
		AllowSharing            bool   `json:"allow_sharing"`
		AllowPrivateChat        bool   `json:"allow_private_chat"`
		AllowSearch             bool   `json:"allow_search"`
		AllowJoin               bool   `json:"allow_join"`
		AllowAnonymousQuestion  bool   `json:"allow_anonymous_question"`
		SilenceNewMember        bool   `json:"silence_new_member"`
		EnableWatermark         bool   `json:"enable_watermark"`
		ParseBookTitle          bool   `json:"parse_book_title"`
		AllowCopy               bool   `json:"allow_copy"`
		AllowDownload           bool   `json:"allow_download"`
		EnableIap               bool   `json:"enable_iap"`
	} `json:"policies"`
	Privileges struct {
		AccessGroupData     string `json:"access_group_data"`
		AccessIncomesData   string `json:"access_incomes_data"`
		AccessWeeklyReports string `json:"access_weekly_reports"`
		CreateTopic         string `json:"create_topic"`
		CreateComment       string `json:"create_comment"`
	} `json:"privileges"`
	Statistics struct {
		Topics struct {
			TopicsCount  int `json:"topics_count"`
			AnswersCount int `json:"answers_count"`
			DigestsCount int `json:"digests_count"`
		} `json:"topics"`
		Files struct {
			Count int `json:"count"`
		} `json:"files"`
		Members struct {
			Count int `json:"count"`
		} `json:"members"`
	} `json:"statistics"`
	UserSpecific struct {
		JoinTime        string `json:"join_time"`
		RewardedOwner   bool   `json:"rewarded_owner"`
		EnableFootprint bool   `json:"enable_footprint"`
	} `json:"user_specific"`
}

type GroupInfoResp

type GroupInfoResp struct {
	Group GroupInfo `json:"group"`
}

type Groups

type Groups struct {
	Groups []Group `json:"groups"`
}

type Image

type Image struct {
	ImageId   int64     `json:"image_id"`
	Type      string    `json:"type"`
	Thumbnail ImageMeta `json:"thumbnail"`
	Large     ImageMeta `json:"large"`
	Original  ImageMeta `json:"original,omitempty"`
}

type ImageMeta

type ImageMeta struct {
	Url    string `json:"url"`
	Width  int    `json:"width"`
	Height int    `json:"height"`
	Size   int    `json:"size,omitempty"`
}
type Menu struct {
	MenuId                int64  `json:"menu_id"`
	Title                 string `json:"title"`
	Preset                bool   `json:"preset"`
	PresetType            string `json:"preset_type"`
	LatestTopicCreateTime string `json:"latest_topic_create_time,omitempty"`
}
type Menus struct {
	Menus []Menu `json:"menus"`
}

type Question

type Question struct {
	Owner  User    `json:"owner"`  // 提问者
	Text   string  `json:"text"`   // 问题内容
	Images []Image `json:"images"` // 问题图片
}

type Response

type Response struct {
	Succeeded bool   `json:"succeeded"`
	Code      int    `json:"code,omitempty"`
	Info      string `json:"info,omitempty"`
	RespData  respC  `json:"resp_data"`
}

Response response

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service dedao service

func NewService

func NewService(co *CookieOptions) *Service

NewService new service

func (*Service) GetArticle

func (s *Service) GetArticle(url string) (info string, err error)

func (*Service) GetColumnTopics

func (s *Service) GetColumnTopics(groupID, columnID string) (list ColumnTopics, err error)

GetColumnTopics group columns topics 导读二级分类

func (*Service) GetColumns

func (s *Service) GetColumns(groupID string) (list Columns, err error)

GetColumns group columns 导读分类

func (*Service) GetGroupInfo

func (s *Service) GetGroupInfo(groupID string) (info GroupInfoResp, err error)

func (*Service) GetGroupTopics

func (s *Service) GetGroupTopics(groupID, scope, count, endTime string) (list Topics, err error)

GetGroupTopics scope= all 最新, digests 精华, by_owner 只看星主, questions 问答,with_files 文件

func (*Service) GetGroups

func (s *Service) GetGroups() (list Groups, err error)

func (*Service) GetMenus

func (s *Service) GetMenus(groupID string) (list Menus, err error)

func (*Service) GetSettings

func (s *Service) GetSettings() (io.ReadCloser, error)

func (*Service) GetTopicInfo

func (s *Service) GetTopicInfo(topicID string) (info TopicInfo, err error)

GetTopicInfo group columns topics

func (*Service) GetUserSelf

func (s *Service) GetUserSelf() (user UserInfo, err error)

type ShowComment

type ShowComment struct {
	CommentId       int64   `json:"comment_id"`
	CreateTime      string  `json:"create_time"`
	Owner           User    `json:"owner"`
	Text            string  `json:"text"`
	LikesCount      int     `json:"likes_count"`
	RewardsCount    int     `json:"rewards_count"`
	Sticky          bool    `json:"sticky"`
	RepliesCount    int     `json:"replies_count,omitempty"`
	ParentCommentId int64   `json:"parent_comment_id,omitempty"`
	Repliee         User    `json:"repliee,omitempty"`
	Images          []Image `json:"images,omitempty"`
}

type Summary

type Summary struct {
	HasColumns bool   `json:"has_columns"`
	Title      string `json:"title"`
}

type Topic

type Topic struct {
	Question Question `json:"question"` // 提问
	Answer   Answer   `json:"answer"`   // 回答
	TopicId  int64    `json:"topic_id"`
	Group    Group    `json:"group"`
	Type     string   `json:"type"`
	Talk     struct {
		Owner   User    `json:"owner"`
		Text    string  `json:"text"`
		Article Article `json:"article,omitempty"`
		Images  []Image `json:"images,omitempty"`
		Files   []File  `json:"files,omitempty"`
	} `json:"talk"`
	// LatestLikes []struct {
	// 	CreateTime string `json:"create_time"`
	// 	Owner      User   `json:"owner"`
	// } `json:"latest_likes"`
	// ShowComments  []ShowComment `json:"show_comments"`
	LikesCount    int    `json:"likes_count"`
	RewardsCount  int    `json:"rewards_count"`
	CommentsCount int    `json:"comments_count"`
	ReadingCount  int    `json:"reading_count"`
	ReadersCount  int    `json:"readers_count"`
	Digested      bool   `json:"digested"`
	Sticky        bool   `json:"sticky"`
	CreateTime    string `json:"create_time"`
	UserSpecific  struct {
		Liked      bool `json:"liked"`
		Subscribed bool `json:"subscribed"`
	} `json:"user_specific"`
	Title   string `json:"title"`
	Columns []struct {
		ColumnId int64  `json:"column_id"`
		Name     string `json:"name"`
	} `json:"columns"`
}

type TopicInfo

type TopicInfo struct {
	Topic Topic  `json:"topic"`
	Type  string `json:"type"`
}

type Topics

type Topics struct {
	Topics []Topic `json:"topics"`
}

type User

type User struct {
	UserId      int64  `json:"user_id"`
	Name        string `json:"name"`
	AvatarUrl   string `json:"avatar_url"`
	Description string `json:"description,omitempty"`
	Location    string `json:"location"`
	Alias       string `json:"alias,omitempty"`
	Number      int    `json:"number,omitempty"`
	UniqueId    string `json:"unique_id,omitempty"`
}

type UserInfo

type UserInfo struct {
	User User `json:"user"`
	Chat struct {
		Identifier string `json:"identifier"`
	} `json:"chat"`
	Accounts struct {
		Phone struct {
			CountryCode string `json:"country_code"`
			PhoneNumber string `json:"phone_number"`
		} `json:"phone"`
		Wechat struct {
			Name      string `json:"name"`
			AvatarUrl string `json:"avatar_url"`
		} `json:"wechat"`
	} `json:"accounts"`
	IdentityStatus   string `json:"identity_status"`
	SubscribedWechat bool   `json:"subscribed_wechat"`
	Subscriptions    struct {
		SubscribedXiaomiquanvip bool `json:"subscribed_xiaomiquanvip"`
		SubscribedXingqiusvip   bool `json:"subscribed_xingqiusvip"`
	} `json:"subscriptions"`
	AssociatedEnterprise bool `json:"associated_enterprise"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL