TD Light Simple Telegram Client - OTR/Kotlin-Telegram-Client GitHub Wiki

Class SimpleTelegramClient

Description

This class provides a simple way to interact with the Telegram Database Library (TDLib).

Constructor

public SimpleTelegramClient(TDLibSettings settings)

Class instance Public Properties

Get Authentication Data

@Override
public void getAuthenticationData(Consumer<AuthenticationData> result)

Set Client Interaction

public void setClientInteraction(ClientInteraction clientInteraction)

Add Command Handler

public <T extends TdApi.Update> void addCommandHandler(
    String commandName,
    CommandHandler handler
)

Add Update Handler

public <T extends TdApi.Update> void addUpdateHandler(
    Class<T> updateType,
    GenericUpdateHandler<T> handler
)

Add Updates Handler

public void addUpdatesHandler(GenericUpdateHandler<TdApi.Update> handler)

Add Update Exception Handler

Optional handler to handle errors received from TDLib

public void addUpdateExceptionHandler(ExceptionHandler updateExceptionHandler) {

Add Default Exception Handler

Optional handler to handle uncaught errors (when using send without an appropriate error handler)

public void addDefaultExceptionHandler(ExceptionHandler defaultExceptionHandlers

Start

Start the client

public void start(AuthenticationData authenticationData)

Send with exception handler set as null

Sends a request to TDLib and get the result.

  • function : TdApi.Function - The request to TDLib.
  • resultHandler TdApi.ResultHandler - Result handler. If it is null, nothing will be called.
public <R extends TdApi.Object> void send(
    TdApi.Function<R> function,
    GenericResultHandler<R> resultHandler
)

Send with passed exception handler

  • function : TdApi.Function - The request to TDLib.
  • resultHandler : TdApi.GenericResultHandler - Result handler. If it is null, nothing will be called.
  • resultHandler : TdApi.ExceptionHandler - Handle exceptions thrown inside the result handler. If it is null, the default exception handler will be called.
public <R extends TdApi.Object> void send(
    TdApi.Function<R> function,
    GenericResultHandler<R> resultHandler,
    ExceptionHandler resultHandlerExceptionHandler
)

Execute

Execute a synchronous function. Please note that only some functions can be executed using this method.

If you want to execute a function please use send(Function, GenericResultHandler) method

public <R extends TdApi.Object> Result<R> execute(TdApi.Function<R> function)

Send Close

Send the close signal but don't wait

public void sendClose()

Close and Wait

Send the close signal and wait for exit

public void closeAndWait() 

Wait For Exit

Wait until TDLight is closed

public void waitForExit()

Get Me

public User getMe()

Is Main Chats List Loaded

public boolean isMainChatsListLoaded()

Is Archive Chats List Loaded

public boolean isArchivedChatsListLoaded()

Static Public Properties

LOG field

public static final Logger LOG = LoggerFactory.getLogger(SimpleTelegramClient.class);

blockingExecutor field

public static ExecutorService blockingExecutor = Executors.newSingleThreadExecutor();

Inner Class SimpleTelegramClientInteraction

Constructor

public SimpleTelegramClientInteraction(ExecutorService blockingExecutor) {
			this.blockingExecutor = blockingExecutor;
		}

Public method onParameterRequest

@Override
public void onParameterRequest(
    InputParameter parameter,
    ParameterInfo parameterInfo,
    Consumer<String> result
)

Example

Reference

⚠️ **GitHub.com Fallback** ⚠️