Documentation
¶
Overview ¶
Package stories contains helpers to iterate over stories.
Index ¶
- type AllStoriesQueryBuilder
- type Elem
- type QueryBuilder
- func (q *QueryBuilder) GetAllStories() *AllStoriesQueryBuilder
- func (q *QueryBuilder) GetPinnedStories(p tg.InputPeerClass) *StoriesQueryBuilder
- func (q *QueryBuilder) GetStoriesArchive(p tg.InputPeerClass) *StoriesQueryBuilder
- func (q *QueryBuilder) GetStoriesByID(ctx context.Context, p tg.InputPeerClass, ids ...int) ([]tg.StoryItemClass, peer.Entities, error)
- func (q *QueryBuilder) GetStoryViewsList(p tg.InputPeerClass, id int) *ViewsQueryBuilder
- type StoriesQueryBuilder
- type ViewsQueryBuilder
- func (b *ViewsQueryBuilder) BatchSize(batchSize int) *ViewsQueryBuilder
- func (b *ViewsQueryBuilder) ForEach(ctx context.Context, ...) error
- func (b *ViewsQueryBuilder) ForwardsFirst(v bool) *ViewsQueryBuilder
- func (b *ViewsQueryBuilder) JustContacts(v bool) *ViewsQueryBuilder
- func (b *ViewsQueryBuilder) Offset(offset string) *ViewsQueryBuilder
- func (b *ViewsQueryBuilder) Query(q string) *ViewsQueryBuilder
- func (b *ViewsQueryBuilder) ReactionsFirst(v bool) *ViewsQueryBuilder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AllStoriesQueryBuilder ¶
type AllStoriesQueryBuilder struct {
// contains filtered or unexported fields
}
AllStoriesQueryBuilder is a query builder of stories.getAllStories.
func (*AllStoriesQueryBuilder) ForEach ¶
func (b *AllStoriesQueryBuilder) ForEach( ctx context.Context, cb func(ctx context.Context, stories tg.PeerStories, e peer.Entities) error, ) (string, error)
ForEach calls cb on each peer with active stories, following pagination, and returns the state to pass to State for the next call.
If nothing changed since given state, cb is not called.
On error (including an error returned by cb), the returned state is the one set by State, not the state of the last page: a state returned in the middle of pagination is only valid to fetch the next page, and passing it to State would skip the remaining pages. So the next call fetches again everything changed since the given state, and cb may get some peers again.
func (*AllStoriesQueryBuilder) Hidden ¶
func (b *AllStoriesQueryBuilder) Hidden(hidden bool) *AllStoriesQueryBuilder
Hidden sets whether to fetch stories of hidden peers (the "archive" of stories list) instead of visible ones.
func (*AllStoriesQueryBuilder) State ¶
func (b *AllStoriesQueryBuilder) State(state string) *AllStoriesQueryBuilder
State sets the state returned by previous iteration (see ForEach), to fetch only changes since then.
type QueryBuilder ¶
type QueryBuilder struct {
// contains filtered or unexported fields
}
QueryBuilder is a helper to create stories queries.
func NewQueryBuilder ¶
func NewQueryBuilder(raw *tg.Client) *QueryBuilder
NewQueryBuilder creates new QueryBuilder.
func (*QueryBuilder) GetAllStories ¶
func (q *QueryBuilder) GetAllStories() *AllStoriesQueryBuilder
GetAllStories creates query of active stories of all peers the user follows (contacts and channels).
func (*QueryBuilder) GetPinnedStories ¶
func (q *QueryBuilder) GetPinnedStories(p tg.InputPeerClass) *StoriesQueryBuilder
GetPinnedStories creates query of stories pinned to the profile of peer.
func (*QueryBuilder) GetStoriesArchive ¶
func (q *QueryBuilder) GetStoriesArchive(p tg.InputPeerClass) *StoriesQueryBuilder
GetStoriesArchive creates query of archived (expired) stories of peer, available to its owner or admins.
func (*QueryBuilder) GetStoriesByID ¶
func (q *QueryBuilder) GetStoriesByID(ctx context.Context, p tg.InputPeerClass, ids ...int) ([]tg.StoryItemClass, peer.Entities, error)
GetStoriesByID fetches stories of peer by IDs, in chunks of 100.
Returned stories may include storyItemDeleted for deleted ones.
func (*QueryBuilder) GetStoryViewsList ¶
func (q *QueryBuilder) GetStoryViewsList(p tg.InputPeerClass, id int) *ViewsQueryBuilder
GetStoryViewsList creates query of views of own story id of peer (self or a channel where the user is an admin).
type StoriesQueryBuilder ¶
type StoriesQueryBuilder struct {
// contains filtered or unexported fields
}
StoriesQueryBuilder is a query builder of paginated stories of a peer (pinned or archive).
func (*StoriesQueryBuilder) BatchSize ¶
func (b *StoriesQueryBuilder) BatchSize(batchSize int) *StoriesQueryBuilder
BatchSize sets number of stories per request.
func (*StoriesQueryBuilder) ForEach ¶
func (b *StoriesQueryBuilder) ForEach(ctx context.Context, cb func(ctx context.Context, raw tg.StoryItemClass, e Elem) error) error
ForEach calls cb on each story, from newest to oldest.
Deleted and skipped stories (storyItemDeleted, storyItemSkipped) are passed as well via raw, Elem.Story is nil for them; use GetStoriesByID to fetch skipped ones.
func (*StoriesQueryBuilder) OffsetID ¶
func (b *StoriesQueryBuilder) OffsetID(offsetID int) *StoriesQueryBuilder
OffsetID sets story ID to start from (exclusive), e.g. to resume.
type ViewsQueryBuilder ¶
type ViewsQueryBuilder struct {
// contains filtered or unexported fields
}
ViewsQueryBuilder is a query builder of stories.getStoryViewsList.
func (*ViewsQueryBuilder) BatchSize ¶
func (b *ViewsQueryBuilder) BatchSize(batchSize int) *ViewsQueryBuilder
BatchSize sets number of views per request.
func (*ViewsQueryBuilder) ForEach ¶
func (b *ViewsQueryBuilder) ForEach(ctx context.Context, cb func(ctx context.Context, view tg.StoryViewClass, e peer.Entities) error) error
ForEach calls cb on each story view, following pagination.
func (*ViewsQueryBuilder) ForwardsFirst ¶
func (b *ViewsQueryBuilder) ForwardsFirst(v bool) *ViewsQueryBuilder
ForwardsFirst sets whether to return forwards and reposts first.
func (*ViewsQueryBuilder) JustContacts ¶
func (b *ViewsQueryBuilder) JustContacts(v bool) *ViewsQueryBuilder
JustContacts sets whether to return only views of contacts.
func (*ViewsQueryBuilder) Offset ¶
func (b *ViewsQueryBuilder) Offset(offset string) *ViewsQueryBuilder
Offset sets offset to start from (NextOffset of a previous page), e.g. to resume.
func (*ViewsQueryBuilder) Query ¶
func (b *ViewsQueryBuilder) Query(q string) *ViewsQueryBuilder
Query sets search query for views.
func (*ViewsQueryBuilder) ReactionsFirst ¶
func (b *ViewsQueryBuilder) ReactionsFirst(v bool) *ViewsQueryBuilder
ReactionsFirst sets whether to return views with reactions first.