messages

package
v0.42.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: May 24, 2021 License: MIT Imports: 6 Imported by: 7

Documentation

Overview

Package messages contains message iteration helper.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Elem

type Elem struct {
	Msg      tg.NotEmptyMessage
	Peer     tg.InputPeerClass
	Entities peer.Entities
}

Elem is a message iterator element.

func (Elem) Document added in v0.33.0

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

Document returns document object if message has a document attachment (video, voice, audio, basically every type except photo).

func (Elem) File added in v0.33.0

func (e Elem) File() (File, bool)

File returns file location if message has a file attachment.

func (Elem) Photo added in v0.33.0

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

Photo returns photo object if message has a photo attachment.

type File added in v0.33.0

type File struct {
	Name     string
	MIMEType string
	Location tg.InputFileLocationClass
}

File represents file attachment.

type GetHistoryQueryBuilder

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

GetHistoryQueryBuilder is query builder of MessagesGetHistory.

func (*GetHistoryQueryBuilder) BatchSize

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

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 (*GetHistoryQueryBuilder) Collect

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

Collect creates iterator and collects all elements to slice.

func (*GetHistoryQueryBuilder) Count

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

Count fetches remote state to get number of elements.

func (*GetHistoryQueryBuilder) ForEach

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

ForEach calls given callback on each iterator element.

func (*GetHistoryQueryBuilder) Iter

func (b *GetHistoryQueryBuilder) Iter() *Iterator

Iter returns iterator using built query.

func (*GetHistoryQueryBuilder) OffsetDate

func (b *GetHistoryQueryBuilder) OffsetDate(offsetDate int) *GetHistoryQueryBuilder

OffsetDate sets offsetDate from which iterate start.

func (*GetHistoryQueryBuilder) OffsetID

func (b *GetHistoryQueryBuilder) OffsetID(offsetID int) *GetHistoryQueryBuilder

OffsetID sets offsetID from which iterate start.

func (*GetHistoryQueryBuilder) Peer

Peer sets Peer field of GetHistory query.

func (*GetHistoryQueryBuilder) Query

Query implements Query interface.

type GetRecentLocationsQueryBuilder

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

GetRecentLocationsQueryBuilder is query builder of MessagesGetRecentLocations.

func (*GetRecentLocationsQueryBuilder) 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 (*GetRecentLocationsQueryBuilder) Collect

Collect creates iterator and collects all elements to slice.

func (*GetRecentLocationsQueryBuilder) Count

Count fetches remote state to get number of elements.

func (*GetRecentLocationsQueryBuilder) ForEach

ForEach calls given callback on each iterator element.

func (*GetRecentLocationsQueryBuilder) Iter

Iter returns iterator using built query.

func (*GetRecentLocationsQueryBuilder) Peer

Peer sets Peer field of GetRecentLocations query.

func (*GetRecentLocationsQueryBuilder) Query

Query implements Query interface.

type GetRepliesQueryBuilder

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

GetRepliesQueryBuilder is query builder of MessagesGetReplies.

func (*GetRepliesQueryBuilder) BatchSize

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

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 (*GetRepliesQueryBuilder) Collect

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

Collect creates iterator and collects all elements to slice.

func (*GetRepliesQueryBuilder) Count

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

Count fetches remote state to get number of elements.

func (*GetRepliesQueryBuilder) ForEach

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

ForEach calls given callback on each iterator element.

func (*GetRepliesQueryBuilder) Iter

func (b *GetRepliesQueryBuilder) Iter() *Iterator

Iter returns iterator using built query.

func (*GetRepliesQueryBuilder) MsgID

func (b *GetRepliesQueryBuilder) MsgID(paramMsgID int) *GetRepliesQueryBuilder

MsgID sets MsgID field of GetReplies query.

func (*GetRepliesQueryBuilder) OffsetDate

func (b *GetRepliesQueryBuilder) OffsetDate(offsetDate int) *GetRepliesQueryBuilder

OffsetDate sets offsetDate from which iterate start.

func (*GetRepliesQueryBuilder) OffsetID

func (b *GetRepliesQueryBuilder) OffsetID(offsetID int) *GetRepliesQueryBuilder

OffsetID sets offsetID from which iterate start.

func (*GetRepliesQueryBuilder) Peer

Peer sets Peer field of GetReplies query.

func (*GetRepliesQueryBuilder) Query

Query implements Query interface.

type GetUnreadMentionsQueryBuilder

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

GetUnreadMentionsQueryBuilder is query builder of MessagesGetUnreadMentions.

func (*GetUnreadMentionsQueryBuilder) 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 (*GetUnreadMentionsQueryBuilder) Collect

Collect creates iterator and collects all elements to slice.

func (*GetUnreadMentionsQueryBuilder) Count

Count fetches remote state to get number of elements.

func (*GetUnreadMentionsQueryBuilder) ForEach

ForEach calls given callback on each iterator element.

func (*GetUnreadMentionsQueryBuilder) Iter

Iter returns iterator using built query.

func (*GetUnreadMentionsQueryBuilder) OffsetID

OffsetID sets offsetID from which iterate start.

func (*GetUnreadMentionsQueryBuilder) Peer

Peer sets Peer field of GetUnreadMentions query.

func (*GetUnreadMentionsQueryBuilder) Query

Query implements Query interface.

type Iterator

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

Iterator is a message 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) OffsetDate

func (m *Iterator) OffsetDate(offsetDate int) *Iterator

OffsetDate sets OffsetDate request parameter.

func (*Iterator) OffsetID

func (m *Iterator) OffsetID(offsetID int) *Iterator

OffsetID sets OffsetID request parameter.

func (*Iterator) OffsetPeer

func (m *Iterator) OffsetPeer(offsetPeer tg.InputPeerClass) *Iterator

OffsetPeer sets OffsetPeer request parameter.

func (*Iterator) OffsetRate

func (m *Iterator) OffsetRate(offsetRate int) *Iterator

OffsetRate sets OffsetRate 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.MessagesMessagesClass, error)
}

Query is a abstraction for messages 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) GetHistory

func (q *QueryBuilder) GetHistory(paramPeer tg.InputPeerClass) *GetHistoryQueryBuilder

GetHistory creates query builder of MessagesGetHistory.

func (*QueryBuilder) GetRecentLocations

func (q *QueryBuilder) GetRecentLocations(paramPeer tg.InputPeerClass) *GetRecentLocationsQueryBuilder

GetRecentLocations creates query builder of MessagesGetRecentLocations.

func (*QueryBuilder) GetReplies

func (q *QueryBuilder) GetReplies(paramPeer tg.InputPeerClass) *GetRepliesQueryBuilder

GetReplies creates query builder of MessagesGetReplies.

func (*QueryBuilder) GetUnreadMentions

func (q *QueryBuilder) GetUnreadMentions(paramPeer tg.InputPeerClass) *GetUnreadMentionsQueryBuilder

GetUnreadMentions creates query builder of MessagesGetUnreadMentions.

func (*QueryBuilder) Search

func (q *QueryBuilder) Search(paramPeer tg.InputPeerClass) *SearchQueryBuilder

Search creates query builder of MessagesSearch.

func (*QueryBuilder) SearchGlobal

func (q *QueryBuilder) SearchGlobal() *SearchGlobalQueryBuilder

SearchGlobal creates query builder of MessagesSearchGlobal.

func (*QueryBuilder) StatsGetMessagePublicForwards

func (q *QueryBuilder) StatsGetMessagePublicForwards(paramChannel tg.InputChannelClass) *StatsGetMessagePublicForwardsQueryBuilder

StatsGetMessagePublicForwards creates query builder of StatsGetMessagePublicForwards.

type QueryFunc

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

QueryFunc is a function adapter for Query.

func (QueryFunc) Query

Query implements Query interface.

type Request

type Request struct {
	AddOffset  int
	OffsetDate int
	OffsetID   int
	OffsetPeer tg.InputPeerClass
	OffsetRate int
	Limit      int
}

Request is a parameter for Query.

type SearchGlobalQueryBuilder

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

SearchGlobalQueryBuilder is query builder of MessagesSearchGlobal.

func (*SearchGlobalQueryBuilder) BatchSize

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

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 (*SearchGlobalQueryBuilder) ChatPhotos

ChatPhotos sets Filter field of SearchGlobal query.

func (*SearchGlobalQueryBuilder) Collect

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

Collect creates iterator and collects all elements to slice.

func (*SearchGlobalQueryBuilder) Contacts

Contacts sets Filter field of SearchGlobal query.

func (*SearchGlobalQueryBuilder) Count

Count fetches remote state to get number of elements.

func (*SearchGlobalQueryBuilder) Document

Document sets Filter field of SearchGlobal query.

func (*SearchGlobalQueryBuilder) Filter

Filter sets Filter field of SearchGlobal query.

func (*SearchGlobalQueryBuilder) FolderID

func (b *SearchGlobalQueryBuilder) FolderID(paramFolderID int) *SearchGlobalQueryBuilder

FolderID sets FolderID field of SearchGlobal query.

func (*SearchGlobalQueryBuilder) ForEach

ForEach calls given callback on each iterator element.

func (*SearchGlobalQueryBuilder) Geo

Geo sets Filter field of SearchGlobal query.

func (*SearchGlobalQueryBuilder) Gif

Gif sets Filter field of SearchGlobal query.

func (*SearchGlobalQueryBuilder) Iter

Iter returns iterator using built query.

func (*SearchGlobalQueryBuilder) MaxDate

func (b *SearchGlobalQueryBuilder) MaxDate(paramMaxDate int) *SearchGlobalQueryBuilder

MaxDate sets MaxDate field of SearchGlobal query.

func (*SearchGlobalQueryBuilder) MinDate

func (b *SearchGlobalQueryBuilder) MinDate(paramMinDate int) *SearchGlobalQueryBuilder

MinDate sets MinDate field of SearchGlobal query.

func (*SearchGlobalQueryBuilder) Music

Music sets Filter field of SearchGlobal query.

func (*SearchGlobalQueryBuilder) MyMentions

MyMentions sets Filter field of SearchGlobal query.

func (*SearchGlobalQueryBuilder) OffsetID

func (b *SearchGlobalQueryBuilder) OffsetID(offsetID int) *SearchGlobalQueryBuilder

OffsetID sets offsetID from which iterate start.

func (*SearchGlobalQueryBuilder) PhoneCalls

func (b *SearchGlobalQueryBuilder) PhoneCalls(paramMissed bool) *SearchGlobalQueryBuilder

PhoneCalls sets Filter field of SearchGlobal query.

func (*SearchGlobalQueryBuilder) PhotoVideo

PhotoVideo sets Filter field of SearchGlobal query.

func (*SearchGlobalQueryBuilder) Photos

Photos sets Filter field of SearchGlobal query.

func (*SearchGlobalQueryBuilder) Pinned

Pinned sets Filter field of SearchGlobal query.

func (*SearchGlobalQueryBuilder) Q

Q sets Q field of SearchGlobal query.

func (*SearchGlobalQueryBuilder) Query

Query implements Query interface.

func (*SearchGlobalQueryBuilder) RoundVideo

RoundVideo sets Filter field of SearchGlobal query.

func (*SearchGlobalQueryBuilder) RoundVoice

RoundVoice sets Filter field of SearchGlobal query.

func (*SearchGlobalQueryBuilder) URL

URL sets Filter field of SearchGlobal query.

func (*SearchGlobalQueryBuilder) Video

Video sets Filter field of SearchGlobal query.

func (*SearchGlobalQueryBuilder) Voice

Voice sets Filter field of SearchGlobal query.

type SearchQueryBuilder

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

SearchQueryBuilder is query builder of MessagesSearch.

func (*SearchQueryBuilder) BatchSize

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

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 (*SearchQueryBuilder) ChatPhotos

func (b *SearchQueryBuilder) ChatPhotos() *SearchQueryBuilder

ChatPhotos sets Filter field of Search query.

func (*SearchQueryBuilder) Collect

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

Collect creates iterator and collects all elements to slice.

func (*SearchQueryBuilder) Contacts

func (b *SearchQueryBuilder) Contacts() *SearchQueryBuilder

Contacts sets Filter field of Search query.

func (*SearchQueryBuilder) Count

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

Count fetches remote state to get number of elements.

func (*SearchQueryBuilder) Document

func (b *SearchQueryBuilder) Document() *SearchQueryBuilder

Document sets Filter field of Search query.

func (*SearchQueryBuilder) Filter

Filter sets Filter field of Search query.

func (*SearchQueryBuilder) ForEach

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

ForEach calls given callback on each iterator element.

func (*SearchQueryBuilder) FromID

func (b *SearchQueryBuilder) FromID(paramFromID tg.InputPeerClass) *SearchQueryBuilder

FromID sets FromID field of Search query.

func (*SearchQueryBuilder) Geo

Geo sets Filter field of Search query.

func (*SearchQueryBuilder) Gif

Gif sets Filter field of Search query.

func (*SearchQueryBuilder) Iter

func (b *SearchQueryBuilder) Iter() *Iterator

Iter returns iterator using built query.

func (*SearchQueryBuilder) MaxDate

func (b *SearchQueryBuilder) MaxDate(paramMaxDate int) *SearchQueryBuilder

MaxDate sets MaxDate field of Search query.

func (*SearchQueryBuilder) MinDate

func (b *SearchQueryBuilder) MinDate(paramMinDate int) *SearchQueryBuilder

MinDate sets MinDate field of Search query.

func (*SearchQueryBuilder) Music

Music sets Filter field of Search query.

func (*SearchQueryBuilder) MyMentions

func (b *SearchQueryBuilder) MyMentions() *SearchQueryBuilder

MyMentions sets Filter field of Search query.

func (*SearchQueryBuilder) OffsetID

func (b *SearchQueryBuilder) OffsetID(offsetID int) *SearchQueryBuilder

OffsetID sets offsetID from which iterate start.

func (*SearchQueryBuilder) Peer

Peer sets Peer field of Search query.

func (*SearchQueryBuilder) PhoneCalls

func (b *SearchQueryBuilder) PhoneCalls(paramMissed bool) *SearchQueryBuilder

PhoneCalls sets Filter field of Search query.

func (*SearchQueryBuilder) PhotoVideo

func (b *SearchQueryBuilder) PhotoVideo() *SearchQueryBuilder

PhotoVideo sets Filter field of Search query.

func (*SearchQueryBuilder) Photos

Photos sets Filter field of Search query.

func (*SearchQueryBuilder) Pinned

Pinned sets Filter field of Search query.

func (*SearchQueryBuilder) Q

Q sets Q field of Search query.

func (*SearchQueryBuilder) Query

Query implements Query interface.

func (*SearchQueryBuilder) RoundVideo

func (b *SearchQueryBuilder) RoundVideo() *SearchQueryBuilder

RoundVideo sets Filter field of Search query.

func (*SearchQueryBuilder) RoundVoice

func (b *SearchQueryBuilder) RoundVoice() *SearchQueryBuilder

RoundVoice sets Filter field of Search query.

func (*SearchQueryBuilder) TopMsgID

func (b *SearchQueryBuilder) TopMsgID(paramTopMsgID int) *SearchQueryBuilder

TopMsgID sets TopMsgID field of Search query.

func (*SearchQueryBuilder) URL

URL sets Filter field of Search query.

func (*SearchQueryBuilder) Video

Video sets Filter field of Search query.

func (*SearchQueryBuilder) Voice

Voice sets Filter field of Search query.

type StatsGetMessagePublicForwardsQueryBuilder

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

StatsGetMessagePublicForwardsQueryBuilder is query builder of StatsGetMessagePublicForwards.

func (*StatsGetMessagePublicForwardsQueryBuilder) 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 (*StatsGetMessagePublicForwardsQueryBuilder) Channel

Channel sets Channel field of StatsGetMessagePublicForwards query.

func (*StatsGetMessagePublicForwardsQueryBuilder) Collect

Collect creates iterator and collects all elements to slice.

func (*StatsGetMessagePublicForwardsQueryBuilder) Count

Count fetches remote state to get number of elements.

func (*StatsGetMessagePublicForwardsQueryBuilder) ForEach

ForEach calls given callback on each iterator element.

func (*StatsGetMessagePublicForwardsQueryBuilder) Iter

Iter returns iterator using built query.

func (*StatsGetMessagePublicForwardsQueryBuilder) MsgID

MsgID sets MsgID field of StatsGetMessagePublicForwards query.

func (*StatsGetMessagePublicForwardsQueryBuilder) OffsetID

OffsetID sets offsetID from which iterate start.

func (*StatsGetMessagePublicForwardsQueryBuilder) Query

Query implements Query interface.

Directories

Path Synopsis
stickers
featured
Package featured contains featured stickers iteration helper.
Package featured contains featured stickers iteration helper.

Jump to

Keyboard shortcuts

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