data

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2023 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrSubmitted = errors.New("您已提交过")
View Source
var (
	Posts db.DB
)
View Source
var TestPost = &Post{
	Platform: "weibo",
	Mid:      "4952487292307646",
	Time:     "1696248446",
	Text:     `<span class="url-icon"><img alt=[good] src="https://h5.sinaimg.cn/m/emoticon/icon/others/h_good-0c51afc69c.png" style="width:1em; height:1em;" /></span><span class="url-icon"><img alt=[good] src="https://h5.sinaimg.cn/m/emoticon/icon/others/h_good-0c51afc69c.png" style="width:1em; height:1em;" /></span><span class="url-icon"><img alt=[good] src="https://h5.sinaimg.cn/m/emoticon/icon/others/h_good-0c51afc69c.png" style="width:1em; height:1em;" /></span><span class="url-icon"><img alt=[good] src="https://h5.sinaimg.cn/m/emoticon/icon/others/h_good-0c51afc69c.png" style="width:1em; height:1em;" /></span><span class="url-icon"><img alt=[赞] src="https://h5.sinaimg.cn/m/emoticon/icon/others/h_zan-44ddc70637.png" style="width:1em; height:1em;" /></span><span class="url-icon"><img alt=[赞] src="https://h5.sinaimg.cn/m/emoticon/icon/others/h_zan-44ddc70637.png" style="width:1em; height:1em;" /></span><span class="url-icon"><img alt=[赞] src="https://h5.sinaimg.cn/m/emoticon/icon/others/h_zan-44ddc70637.png" style="width:1em; height:1em;" /></span><span class="url-icon"><img alt=[赞] src="https://h5.sinaimg.cn/m/emoticon/icon/others/h_zan-44ddc70637.png" style="width:1em; height:1em;" /></span>`,
	Source:   "🦈iPhone 14 Pro Max",
	Blogger: Blogger{
		Platform:    "weibo",
		Uid:         "7198559139",
		Name:        "七海Nana7mi",
		Create:      "1699116457",
		Follower:    "104.8万",
		Following:   "192",
		Description: "蓝色饭团",
		Face: Attachment{
			Url: "https://wx4.sinaimg.cn/orj480/007Raq4zly8hd1vqpx3coj30u00u00uv.jpg",
		},
	},
	Repost: &Post{
		Platform: "weibo",
		Mid:      "4952449691946355",
		Time:     "1696239481",
		Text:     "[看书] ",
		Source:   "iPhone 13 Pro Max",
		Blogger: Blogger{
			Platform:    "weibo",
			Uid:         "2203177060",
			Name:        "阿梓从小就很可爱",
			Create:      "1699116457",
			Follower:    "61.9万",
			Following:   "306",
			Description: "本人只喜欢读书",
			Face: Attachment{
				Url: "https://wx4.sinaimg.cn/orj480/8351d064ly8hiph621dryj20u00u00vw.jpg",
			},
		},
		Comments: make([]Post, 0),
		Attachments: Attachments{
			{Url: "https://wx2.sinaimg.cn/large/8351d064ly1hih23pb486j21tk19k7wk.jpg"},
		},
		Submitter: &user.User{Uid: "188888131", Permission: 1},
	},
	Comments:    make([]Post, 0),
	Attachments: make(Attachments, 0),
	Submitter:   &user.User{Uid: "188888131", Permission: 1},
}

测试博文

Functions

func CheckFiles added in v0.6.0

func CheckFiles() error

func GetBranches

func GetBranches(platform, mid string, r *[]Post)

获取分支

func GetPosts

func GetPosts(begin, end string, r *[]Post)

通过起始与结束时间获取范围内博文合集

func HasPost

func HasPost(platform, mid string) bool

判断博文是否存在

func Init added in v0.7.0

func Init(r *configs.Config)

func Save

func Save(url string) string

Types

type Attachment

type Attachment struct {
	db.Model
	// 原网址
	Url string `json:"url" form:"url" gorm:"unique;not null" cmps:"1"`
	// 本站链接
	Link string `json:"link"`
	// 本地路径
	Local string `json:"-"`
	// 同浏览器 MIME type 附件的媒体类型
	MIME string `json:"MIME"`
}

附件

func (*Attachment) Detect added in v0.11.4

func (a *Attachment) Detect(content []byte)

func (*Attachment) Download

func (a *Attachment) Download() error

下载附件

func (*Attachment) Init added in v0.13.0

func (a *Attachment) Init()

func (*Attachment) Save added in v0.7.0

func (a *Attachment) Save(_ any)

func (*Attachment) Store

func (a *Attachment) Store(content []byte)

func (Attachment) String

func (a Attachment) String() string

type Attachments

type Attachments []Attachment

附件合集

func (Attachments) String

func (as Attachments) String() string

func (Attachments) Urls

func (as Attachments) Urls() string

type Blogger

type Blogger struct {
	db.Model
	Platform    string `form:"platform" json:"platform"`
	Uid         string `form:"uid" json:"uid" cmps:"1"`
	Name        string `form:"name" json:"name"`
	Create      string `form:"create" json:"create"`
	Follower    string `form:"follower" json:"follower"`
	Following   string `form:"following" json:"following"`
	Description string `form:"description" json:"description"`

	FaceID int64      `gorm:"column:face" json:"-"`
	Face   Attachment `form:"face" json:"face" default:"Save"`

	PendantID int64      `gorm:"column:pendant" json:"-"`
	Pendant   Attachment `form:"pendant" json:"pendant" default:"Save"`
}

博主信息部分

func (*Blogger) Query

func (b *Blogger) Query(now time.Time) *Blogger

查询某一时刻前最近的用户状态

func (*Blogger) SetPlatform added in v0.10.0

func (b *Blogger) SetPlatform(p *Post)

func (Blogger) String

func (b Blogger) String() string

type Monitor

type Monitor struct {
	sync.Mutex
	Score float64
	Posts []*Post
}

博文检查器

func (*Monitor) IsSubmitted

func (m *Monitor) IsSubmitted(uid string) bool

判断用户是否已经提交

func (*Monitor) Parse

func (m *Monitor) Parse(post *Post)

解析接收到的博文

type Post

type Post struct {
	db.Model
	// 平台
	Platform string `form:"platform" json:"platform"`
	// 博文序号
	Mid string `form:"mid" json:"mid"`
	// 发送时间
	Time string `form:"time" json:"time"`
	// 文本
	Text string `form:"text" json:"text"`
	// 来源
	Source string `form:"source" json:"source"`
	// 博主
	BloggerID string  `form:"-" json:"-" gorm:"column:blogger"`
	Blogger   Blogger `form:"blogger" json:"blogger" default:"SetPlatform;initial.Default"`
	// 回复
	RepostID *uint64 `form:"-" json:"-" gorm:"column:repost"`
	Repost   *Post   `form:"repost" json:"repost" binding:"omitempty" default:"SetRepost;initial.Default"`
	// 评论
	CommentID *uint64 `form:"-" json:"-" gorm:"column:comment"`
	Comments  []Post  `form:"comments" json:"comments" gorm:"foreignKey:CommentID" default:"range.SetSubmitter;range.initial.Default"`
	// 附件
	Attachments Attachments `form:"attachments" json:"attachments" gorm:"many2many:post_attachments;" default:"range.Save"`
	// 提交者
	Submitter *user.User `form:"-" json:"submitter"`
	// 编辑距离
	Distance int `gorm:"-" form:"-" json:"-" cmps:"1"`
	// contains filtered or unexported fields
}

博文或评论

func GetPost

func GetPost(platform, mid string) *Post

通过平台和序号获取唯一博文

func (*Post) Parse added in v0.13.1

func (p *Post) Parse() error

func (*Post) Send added in v0.12.0

func (p *Post) Send(jobs []user.Job) []*request.ResultWithJob

func (*Post) SetRepost added in v0.10.0

func (p *Post) SetRepost(parent *Post) error

func (*Post) SetSubmitter added in v0.10.0

func (p *Post) SetSubmitter(parent *Post)

func (*Post) String

func (p *Post) String() string

func (*Post) Type

func (p *Post) Type() string

func (*Post) Webhook

func (p *Post) Webhook()

回调博文

Jump to

Keyboard shortcuts

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