Documentation ¶
Index ¶
- Variables
- type Feeds
- func (f *Feeds) AddFeed(url string, tx *sqlx.Tx) (*models.Feed, error)
- func (f *Feeds) AddSubscription(url string, chatId int64) (*Post, error)
- func (f *Feeds) DeleteSubscription(feedId int64, chatId int64) error
- func (f *Feeds) GetFeedByURL(url string, tx *sqlx.Tx) (*models.Feed, error)
- func (f *Feeds) Init(ctx context.Context) (err error)
- func (f *Feeds) ListSubscriptions(chatId int64) ([]models.Feed, error)
- func (f *Feeds) QueueUpdate()
- func (f *Feeds) RequestDockerFeed(feed *models.Feed) (posts *gofeed.Feed, err error)
- func (f *Feeds) RequestFeed(feed *models.Feed) (posts *gofeed.Feed, err error)
- func (f *Feeds) RequestMetadata(post *Post)
- func (f *Feeds) RequestRSSFeed(feed *models.Feed) (posts *gofeed.Feed, err error)
- func (f *Feeds) SetUpdateChan(ch chan<- UpdateMessage)
- type Post
- type UpdateMessage
Constants ¶
This section is empty.
Variables ¶
var ErrAlreadySubscribed = errors.New("already_subscribed")
Error returned when we're already subscribed
Functions ¶
This section is empty.
Types ¶
type Feeds ¶
type Feeds struct {
// contains filtered or unexported fields
}
Feeds is an object that manages feeds and subscriptions
func (*Feeds) AddSubscription ¶
AddSubscription subscribes a chat to a feed, adding the feed if required
func (*Feeds) DeleteSubscription ¶
DeleteSubscription removes a subscription to a feed If this is the last subscription to a feed, remove the feed too
func (*Feeds) GetFeedByURL ¶
GetFeedByURL returns a feed from its URL, or 0 if it's not present The transaction is optional
func (*Feeds) ListSubscriptions ¶
ListSubscriptions lists all subscriptions for a chat
func (*Feeds) RequestDockerFeed ¶
RequestDockerFeed requests a "feed" containing the latest tags for an image on Docker Hub
func (*Feeds) RequestFeed ¶
RequestFeed requests a feed of any kind
func (*Feeds) RequestMetadata ¶
RequestMetadata requests the web page to get the title, description, and image from the page's metadata itself This method updates the value of the post argument as a side effect Errors are logged only and then ignored
func (*Feeds) RequestRSSFeed ¶
RequestRSSFeed requests a RSS feed and parses it with gofeed We're using this rather than gofeed.ParseURL to have more control on the request
func (*Feeds) SetUpdateChan ¶
func (f *Feeds) SetUpdateChan(ch chan<- UpdateMessage)
SetUpdateChan sets the channel to use for notify the bot of new messages for subscribers