package telegram

Import Path
	github.com/gotd/td/telegram (on go.dev)

Dependency Relation
	imports 41 packages, and imported by 0 packages


Package-Level Type Names (total 17, in which 13 are exported)
/* sort exporteds by: | */
Client represents a MTProto client to Telegram. API returns *tg.Client for calling raw MTProto methods. Auth returns auth client. Config returns current config. DC creates new multi-connection invoker to given DC. Invoke invokes raw MTProto RPC method. It sends input and decodes result into output. MediaOnly creates new multi-connection invoker to given DC ID. It connects to MediaOnly DCs. MigrateTo forces client to migrate to another DC. Ping sends low level ping request to Telegram server. Pool creates new multi-connection invoker to current DC. QR returns QR login helper. RandInt64 returns new random int64 from random source. Useful helper for places in API where random int is required. Run starts client session and blocks until connection close. The f callback is called on successful session initialization and Run will return on f() result. Context of callback will be canceled if fatal error is detected. The ctx is used for background operations like updates handling or pools. See `examples/bg-run` and `contrib/gb` package for classic approach without explicit callback, with Connect and defer close(). Self returns current user. You can use tg.User.Bot to check whether current user is bot. SendMessage sends message to peer. Deprecated: use helpers like message.NewSender. *Client : github.com/gotd/td/tg.Invoker func ClientFromEnvironment(opts Options) (*Client, error) func NewClient(appID int, appHash string, opt Options) *Client func RunUntilCanceled(ctx context.Context, client *Client) error
CloseInvoker is a closeable tg.Invoker. ( CloseInvoker) Close() error ( CloseInvoker) Invoke(ctx context.Context, input bin.Encoder, output bin.Decoder) error *github.com/gotd/td/internal/pool.DC CloseInvoker : github.com/gotd/td/tg.Invoker CloseInvoker : io.Closer func (*Client).DC(ctx context.Context, dc int, max int64) (CloseInvoker, error) func (*Client).MediaOnly(ctx context.Context, dc int, max int64) (CloseInvoker, error) func (*Client).Pool(max int64) (CloseInvoker, error)
DeviceConfig is config which send when Telegram connection session created.
Error represents RPC error returned to request.
FileSessionStorage is alias of mtproto.FileSessionStorage.
InvokeFunc implements tg.Invoker as function. Invoke implements tg.Invoker. InvokeFunc : github.com/gotd/td/tg.Invoker func Middleware.Handle(next tg.Invoker) InvokeFunc func MiddlewareFunc.Handle(next tg.Invoker) InvokeFunc
Middleware returns new InvokeFunc for next invoker. ( Middleware) Handle(next tg.Invoker) InvokeFunc MiddlewareFunc
MiddlewareFunc implements Middleware as function. Handle implements Middleware. MiddlewareFunc : Middleware
Options of Client. AckBatchSize is limit of MTProto ACK buffer size. AckInterval is maximum time to buffer MTProto ACK. Clock clock.Clock CompressThreshold is a threshold in bytes to determine that message is large enough to be compressed using GZIP. If < 0, compression will be disabled. If == 0, default value will be used. DC ID to connect. If not provided, 2 will be used by default. DCList is initial list of addresses to connect. Device is device config. Will be sent with session creation request. DialTimeout is timeout of creating connection. ExchangeTimeout is timeout of every key exchange request. Logger is instance of zap.Logger. No logs by default. MaxRetries is limit of send retries. MessageID mtproto.MessageIDSource Middlewares list allows wrapping tg.Invoker. Can be useful for metrics, tracing, etc. Note that order is important, see ExampleMiddleware. Middlewares are called in order from first to last. MigrationTimeout configures migration timeout. NoUpdates enables no updates mode. Enabled by default if no UpdateHandler is provided. PublicKeys of telegram. If not provided, embedded public keys will be used. Random is random source. Defaults to crypto. ReconnectionBackoff configures and returns reconnection backoff object. Resolver to use. RetryInterval is duration between send retries. SessionStorage will be used to load and save session data. NB: Very sensitive data, save with care. OpenTelemetry. UpdateHandler will be called on received update. func OptionsFromEnvironment(opts Options) (Options, error) func BotFromEnvironment(ctx context.Context, opts Options, setup func(ctx context.Context, client *Client) error, cb func(ctx context.Context, client *Client) error) error func ClientFromEnvironment(opts Options) (*Client, error) func NewClient(appID int, appHash string, opt Options) *Client func OptionsFromEnvironment(opts Options) (Options, error) func TestClient(ctx context.Context, opts Options, cb func(ctx context.Context, client *Client) error) error
PublicKey is a Telegram server public key.
SessionStorage is alias of mtproto.SessionStorage.
UpdateHandler will be called on received updates from Telegram. ( UpdateHandler) Handle(ctx context.Context, u tg.UpdatesClass) error UpdateHandlerFunc github.com/gotd/td/tg.UpdateDispatcher
UpdateHandlerFunc type is an adapter to allow the use of ordinary function as update handler. UpdateHandlerFunc(f) is an UpdateHandler that calls f. Handle calls f(ctx, u) UpdateHandlerFunc : UpdateHandler
Package-Level Functions (total 13, in which 6 are exported)
BotFromEnvironment creates bot client using ClientFromEnvironment connects to server and authenticates it. Variables: BOT_TOKEN — token from BotFather.
ClientFromEnvironment creates client using OptionsFromEnvironment but does not connect to server. Variables: APP_ID: app_id of Telegram app. APP_HASH: app_hash of Telegram app.
NewClient creates new unstarted client.
OptionsFromEnvironment fills unfilled field in opts parameter using environment variables. Variables: SESSION_FILE: path to session file SESSION_DIR: path to session directory, if SESSION_FILE is not set ALL_PROXY, NO_PROXY: see https://pkg.go.dev/golang.org/x/net/proxy#FromEnvironment
RunUntilCanceled is client callback which locks until client context is canceled.
TestClient creates and authenticates user telegram.Client using Telegram test server.
Package-Level Variables (total 3, in which 1 is exported)
AsFloodWait returns wait duration and true boolean if err is the "FLOOD_WAIT" error. Client should wait for that duration before issuing new requests with same method.
Package-Level Constants (total 6, all are exported)
Available MTProto default server addresses. See https://my.telegram.org/apps.
Available MTProto default server addresses. See https://my.telegram.org/apps.
ErrFloodWait is error type of "FLOOD_WAIT" error.
Port is default port used by telegram.
Test-only credentials. Can be used with AddrTest and TestAuth to test authentication. Reference: - https://github.com/telegramdesktop/tdesktop/blob/5f665b8ecb48802cd13cfb48ec834b946459274a/docs/api_credentials.md
Test-only credentials. Can be used with AddrTest and TestAuth to test authentication. Reference: - https://github.com/telegramdesktop/tdesktop/blob/5f665b8ecb48802cd13cfb48ec834b946459274a/docs/api_credentials.md