blocked

package
v0.0.0-...-3ee0582 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package blocked contains blocked contacts iteration helper.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Elem

type Elem struct {
	Contact  tg.PeerBlocked
	Entities peer.Entities
}

Elem is a contact iterator element.

type GetBlockedQueryBuilder

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

GetBlockedQueryBuilder is query builder of ContactsGetBlocked.

func (*GetBlockedQueryBuilder) BatchSize

func (b *GetBlockedQueryBuilder) BatchSize(batchSize int) *GetBlockedQueryBuilder

BatchSize sets buffer of message loaded from one request. Be carefully, when set this limit, because Telegram does not return error if limit is too big, so results can be incorrect.

func (*GetBlockedQueryBuilder) Collect

func (b *GetBlockedQueryBuilder) Collect(ctx context.Context) ([]Elem, error)

Collect creates iterator and collects all elements to slice.

func (*GetBlockedQueryBuilder) Count

func (b *GetBlockedQueryBuilder) Count(ctx context.Context) (int, error)

Count fetches remote state to get number of elements.

func (*GetBlockedQueryBuilder) ForEach

func (b *GetBlockedQueryBuilder) ForEach(ctx context.Context, cb func(context.Context, Elem) error) error

ForEach calls given callback on each iterator element.

func (*GetBlockedQueryBuilder) Iter

func (b *GetBlockedQueryBuilder) Iter() *Iterator

Iter returns iterator using built query.

func (*GetBlockedQueryBuilder) MyStoriesFrom

func (b *GetBlockedQueryBuilder) MyStoriesFrom(paramMyStoriesFrom bool) *GetBlockedQueryBuilder

MyStoriesFrom sets MyStoriesFrom field of GetBlocked query.

func (*GetBlockedQueryBuilder) Query

Query implements Query interface.

type Iterator

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

Iterator is a blocked contacts stream iterator.

func NewIterator

func NewIterator(query Query, limit int) *Iterator

NewIterator creates new iterator.

func (*Iterator) Err

func (m *Iterator) Err() error

Err returns the error, if any, that was encountered during iteration.

func (*Iterator) FetchTotal

func (m *Iterator) FetchTotal(ctx context.Context) (int, error)

FetchTotal fetches and returns count of elements.

func (*Iterator) Next

func (m *Iterator) Next(ctx context.Context) bool

Next prepares the next message for reading with the Value method. It returns true on success, or false if there is no next message or an error happened while preparing it. Err should be consulted to distinguish between the two cases.

func (*Iterator) Offset

func (m *Iterator) Offset(offset int) *Iterator

Offset sets Offset request parameter.

func (*Iterator) Total

func (m *Iterator) Total(ctx context.Context) (int, error)

Total returns last fetched count of elements. If count was not fetched before, it requests server using FetchTotal.

func (*Iterator) Value

func (m *Iterator) Value() Elem

Value returns current message.

type Query

type Query interface {
	Query(ctx context.Context, req Request) (tg.ContactsBlockedClass, error)
}

Query is an abstraction for blocked request. NB: iterator mutates returned data (sorts, at least).

type QueryBuilder

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

QueryBuilder is a helper to create message queries.

func NewQueryBuilder

func NewQueryBuilder(raw *tg.Client) *QueryBuilder

NewQueryBuilder creates new QueryBuilder.

func (*QueryBuilder) GetBlocked

func (q *QueryBuilder) GetBlocked() *GetBlockedQueryBuilder

GetBlocked creates query builder of ContactsGetBlocked.

type QueryFunc

type QueryFunc func(ctx context.Context, req Request) (tg.ContactsBlockedClass, error)

QueryFunc is a function adapter for Query.

func (QueryFunc) Query

Query implements Query interface.

type Request

type Request struct {
	Offset int
	Limit  int
}

Request is a parameter for Query.

Jump to

Keyboard shortcuts

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