participants

package
v0.56.0-alpha.0 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2022 License: MIT Imports: 5 Imported by: 8

Documentation

Overview

Package participants contains channel participants iteration helper.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Elem

type Elem struct {
	Participant tg.ChannelParticipantClass
	Entities    peer.Entities
}

Elem is a channel participants iterator element.

func (Elem) Admin added in v0.33.0

func (e Elem) Admin() (*tg.User, *tg.ChannelParticipantAdmin, bool)

Admin returns participant user object and meta info if participant is admin of channel.

func (Elem) Creator added in v0.33.0

func (e Elem) Creator() (*tg.User, *tg.ChannelParticipantCreator, bool)

Creator returns participant user object and meta info if participant is a creator of channel.

func (Elem) User added in v0.33.0

func (e Elem) User() (*tg.User, bool)

User tries to get participant user object.

func (Elem) UserPhotos added in v0.33.0

func (e Elem) UserPhotos(raw *tg.Client) (*photos.GetUserPhotosQueryBuilder, bool)

UserPhotos returns new user photo query builder for participant.

type GetParticipantsQueryBuilder

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

GetParticipantsQueryBuilder is query builder of ChannelsGetParticipants.

func (*GetParticipantsQueryBuilder) Admins

Admins sets Filter field of GetParticipants query.

func (*GetParticipantsQueryBuilder) Banned

Banned sets Filter field of GetParticipants query.

func (*GetParticipantsQueryBuilder) BatchSize

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 (*GetParticipantsQueryBuilder) Bots

Bots sets Filter field of GetParticipants query.

func (*GetParticipantsQueryBuilder) Channel

Channel sets Channel field of GetParticipants query.

func (*GetParticipantsQueryBuilder) Collect

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

Collect creates iterator and collects all elements to slice.

func (*GetParticipantsQueryBuilder) Contacts

Contacts sets Filter field of GetParticipants query.

func (*GetParticipantsQueryBuilder) Count

Count fetches remote state to get number of elements.

func (*GetParticipantsQueryBuilder) Filter

Filter sets Filter field of GetParticipants query.

func (*GetParticipantsQueryBuilder) ForEach

ForEach calls given callback on each iterator element.

func (*GetParticipantsQueryBuilder) Iter

Iter returns iterator using built query.

func (*GetParticipantsQueryBuilder) Kicked

Kicked sets Filter field of GetParticipants query.

func (*GetParticipantsQueryBuilder) Mentions

func (b *GetParticipantsQueryBuilder) Mentions(paramQ string, paramTopMsgID int) *GetParticipantsQueryBuilder

Mentions sets Filter field of GetParticipants query.

func (*GetParticipantsQueryBuilder) Query

Query implements Query interface.

func (*GetParticipantsQueryBuilder) Recent

Recent sets Filter field of GetParticipants query.

func (*GetParticipantsQueryBuilder) Search

Search sets Filter field of GetParticipants query.

type Iterator

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

Iterator is a channel participants 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.

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.ChannelsChannelParticipantsClass, error)
}

Query is an abstraction for participants 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) GetParticipants

func (q *QueryBuilder) GetParticipants(paramChannel tg.InputChannelClass) *GetParticipantsQueryBuilder

GetParticipants creates query builder of ChannelsGetParticipants.

type QueryFunc

type QueryFunc func(ctx context.Context, req Request) (tg.ChannelsChannelParticipantsClass, 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