package rss import "time" // RSS源订阅信息-如果没有对应的订阅信息关联,则应该被清除 type RssFeed struct { ID int `json:"id" gorm:"primaryKey"` FeedURL string `json:"feed_url" gorm:"feed_url"` Creator string `json:"creator" gorm:"creator"` LastUpdate time.Time `json:"last_update" gorm:"last_update"` } func (RssFeed) TableName() string { return "rss_feed" } // 群订阅信息-通过此数据定时检测最新的rss数据是否有更新,若有则向对应群发送消息 type RssSubscribe struct { ID int `json:"id" gorm:"primaryKey"` FeedID int `json:"feed_id" gorm:"feed_id"` GroupID int `json:"group_id" gorm:"group_id"` Creator int `json:"creator" gorm:"creator"` CreateAt time.Time `json:"create_at" gorm:"create_at"` LastItemHash string `json:"last_item_hash" gorm:"last_item_hash"` } func (RssSubscribe) TableName() string { return "rss_subscribe" } // RSS条目信息 type RssItem struct { Title string `json:"title"` // 标题 Link string `json:"link"` // 链接 Description string `json:"description"` // 描述 PubDate time.Time `json:"pub_date"` // 发布时间 GUID string `json:"guid"` // 全局唯一标识符 Author string `json:"author"` // 作者 Category string `json:"category"` // 分类 Hash string `json:"hash"` // 内容哈希值,用于检测更新 } // RSS Feed结构体,用于解析XML type RSSFeed struct { XMLName string `xml:"rss"` Channel struct { Title string `xml:"title"` Link string `xml:"link"` Description string `xml:"description"` Items []RSSItem `xml:"item"` } `xml:"channel"` } // RSS Item结构体,用于解析XML中的item type RSSItem struct { Title string `xml:"title"` Link string `xml:"link"` Description string `xml:"description"` PubDate string `xml:"pubDate"` GUID string `xml:"guid"` Author string `xml:"author"` Category string `xml:"category"` } // Atom Feed结构体,用于解析Atom XML type AtomFeed struct { XMLName string `xml:"feed"` Title string `xml:"title"` Link []AtomLink `xml:"link"` ID string `xml:"id"` Updated string `xml:"updated"` Author AtomAuthor `xml:"author"` Entries []AtomEntry `xml:"entry"` } // Atom Link结构体 type AtomLink struct { Href string `xml:"href,attr"` Rel string `xml:"rel,attr"` } // Atom Author结构体 type AtomAuthor struct { Name string `xml:"name"` } // Atom Entry结构体,用于解析Atom XML中的entry type AtomEntry struct { Title string `xml:"title"` Link []AtomLink `xml:"link"` ID string `xml:"id"` Updated string `xml:"updated"` Published string `xml:"published"` Author AtomAuthor `xml:"author"` Content AtomContent `xml:"content"` Summary string `xml:"summary"` Category []AtomCategory `xml:"category"` } // Atom Content结构体 type AtomContent struct { Type string `xml:"type,attr"` Value string `xml:",chardata"` } // Atom Category结构体 type AtomCategory struct { Term string `xml:"term,attr"` } // OPML文件结构体,用于解析OPML XML type OPML struct { XMLName string `xml:"opml"` Version string `xml:"version,attr"` Head OPMLHead `xml:"head"` Body OPMLBody `xml:"body"` } // OPML Head结构体 type OPMLHead struct { Title string `xml:"title"` DateCreated string `xml:"dateCreated"` DateModified string `xml:"dateModified"` OwnerName string `xml:"ownerName"` OwnerEmail string `xml:"ownerEmail"` ExpansionState string `xml:"expansionState"` VertScrollState string `xml:"vertScrollState"` WindowTop string `xml:"windowTop"` WindowLeft string `xml:"windowLeft"` WindowBottom string `xml:"windowBottom"` WindowRight string `xml:"windowRight"` } // OPML Body结构体 type OPMLBody struct { Outlines []OPMLOutline `xml:"outline"` } // OPML Outline结构体,表示一个RSS源或分类 type OPMLOutline struct { Text string `xml:"text,attr"` Title string `xml:"title,attr"` Type string `xml:"type,attr"` XMLURL string `xml:"xmlUrl,attr"` HTMLURL string `xml:"htmlUrl,attr"` Description string `xml:"description,attr"` Language string `xml:"language,attr"` Version string `xml:"version,attr"` Outlines []OPMLOutline `xml:"outline"` } // OPML解析结果 type OPMLFeedInfo struct { Title string `json:"title"` // RSS源标题 XMLURL string `json:"xml_url"` // RSS源XML地址 HTMLURL string `json:"html_url"` // RSS源HTML地址 Description string `json:"description"` // RSS源描述 Category string `json:"category"` // 分类名称 }