Documentation
¶
Overview ¶
Package mtp provides some functions for the gotd/td functions
Index ¶
- Variables
- type Client
- func (c *Client) CreateChat(ctx context.Context, title string, userIDs ...int64) error
- func (c *Client) DeleteMessages(ctx context.Context, dlg Entity, messages []messages.Elem) (int, error)
- func (c *Client) GetChannels(ctx context.Context) ([]Entity, error)
- func (c *Client) GetChats(ctx context.Context) ([]Entity, error)
- func (c *Client) GetEntities(ctx context.Context, filterFn FilterFunc) ([]Entity, error)
- func (c *Client) Run(ctx context.Context, fn func(context.Context, *telegram.Client) error) error
- func (c *Client) SearchAllMessages(ctx context.Context, dlg Entity, who tg.InputPeerClass, cb func(n int)) ([]messages.Elem, error)
- func (c *Client) SearchAllMyMessages(ctx context.Context, dlg Entity, cb func(n int)) ([]messages.Elem, error)
- func (c *Client) Start(ctx context.Context) error
- func (c *Client) Stop() error
- type Entity
- type FilterFunc
- type MemStorage
- func (ms *MemStorage) Add(_ context.Context, value storage.Peer) error
- func (ms *MemStorage) Assign(_ context.Context, key string, value storage.Peer) error
- func (ms *MemStorage) Close() error
- func (ms *MemStorage) Err() error
- func (ms *MemStorage) Find(ctx context.Context, key storage.PeerKey) (storage.Peer, error)
- func (ms *MemStorage) IsIterating() bool
- func (ms *MemStorage) Iterate(ctx context.Context) (storage.PeerIterator, error)
- func (ms *MemStorage) Next(ctx context.Context) bool
- func (ms *MemStorage) Resolve(_ context.Context, key string) (storage.Peer, error)
- func (ms *MemStorage) Value() storage.Peer
- type Option
Constants ¶
This section is empty.
Variables ¶
var ( // ErrAlreadyRunning is returned if the attempt is made to start the client, // while there's another instance running asynchronously. ErrAlreadyRunning = errors.New("already running asynchronously, stop the running instance first") )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) CreateChat ¶
CreateChat creates a Chat (not a Mega- or Gigagroup).
Example
if err := cl.CreateChat(ctx, "mtproto-test",123455678, 312849128); err != nil { return err }
func (*Client) DeleteMessages ¶
func (*Client) GetChannels ¶
GetChannels retrieves the account channels.
func (*Client) GetEntities ¶
GetEntities ensures that storage is populated, then iterates through storage peers calling filterFn for each peer. The filterFn should return Entity and true, if the peer satisfies the criteria, or nil and false, otherwise.
func (*Client) SearchAllMessages ¶
func (c *Client) SearchAllMessages(ctx context.Context, dlg Entity, who tg.InputPeerClass, cb func(n int)) ([]messages.Elem, error)
SearchAllMessages search messages in the chat or channel `dlg`. It finds ALL messages from the person `who`. returns a slice of message.Elem. For each API call, the callback function will be invoked, if not nil.
func (*Client) SearchAllMyMessages ¶
func (c *Client) SearchAllMyMessages(ctx context.Context, dlg Entity, cb func(n int)) ([]messages.Elem, error)
SearchAllMyMessages returns the current authorized user messages from chat or channel `dlg`. For each API call, the callback function will be invoked, if not nil.
type Entity ¶
Entity interface is the subset of functions that are commonly defined on most entities in telegram lib. It can be a user, a chat or channel, or any other telegram Entity.
type FilterFunc ¶
func FilterChannel ¶
func FilterChannel() FilterFunc
func FilterChat ¶
func FilterChat() FilterFunc
type MemStorage ¶
type MemStorage struct {
// contains filtered or unexported fields
}
MemStorage is the default peer storage for MTP. It uses a map to store all peers, hence, it's not a persistent store.
func NewMemStorage ¶
func NewMemStorage() *MemStorage
func (*MemStorage) Close ¶
func (ms *MemStorage) Close() error
func (*MemStorage) Err ¶
func (ms *MemStorage) Err() error
func (*MemStorage) IsIterating ¶
func (ms *MemStorage) IsIterating() bool
func (*MemStorage) Iterate ¶
func (ms *MemStorage) Iterate(ctx context.Context) (storage.PeerIterator, error)
func (*MemStorage) Value ¶
func (ms *MemStorage) Value() storage.Peer
type Option ¶
type Option func(c *Client)
func WithApiCredsFile ¶
func WithAuth ¶
func WithAuth(flow authflow.FullAuthFlow) Option
WithAuth allows to override the authorization flow
func WithMTPOptions ¶
func WithPeerStorage ¶
func WithPeerStorage(s storage.PeerStorage) Option
WithPeerStorage allows to specify a custom storage for peer data.
func WithStorage ¶
WithStorage allows to specify custom session storage.