TD Light Simple Telegram Client - OTR/Kotlin-Telegram-Client GitHub Wiki
This class provides a simple way to interact with the Telegram Database Library (TDLib).
public SimpleTelegramClient(TDLibSettings settings)
@Override
public void getAuthenticationData(Consumer<AuthenticationData> result)
public void setClientInteraction(ClientInteraction clientInteraction)
public <T extends TdApi.Update> void addCommandHandler(
String commandName,
CommandHandler handler
)
public <T extends TdApi.Update> void addUpdateHandler(
Class<T> updateType,
GenericUpdateHandler<T> handler
)
public void addUpdatesHandler(GenericUpdateHandler<TdApi.Update> handler)
Optional handler to handle errors received from TDLib
public void addUpdateExceptionHandler(ExceptionHandler updateExceptionHandler) {
Optional handler to handle uncaught errors (when using send without an appropriate error handler)
public void addDefaultExceptionHandler(ExceptionHandler defaultExceptionHandlers
Start the client
public void start(AuthenticationData authenticationData)
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
)
-
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 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 the close signal but don't wait
public void sendClose()
Send the close signal and wait for exit
public void closeAndWait()
Wait until TDLight is closed
public void waitForExit()
public User getMe()
public boolean isMainChatsListLoaded()
public boolean isArchivedChatsListLoaded()
public static final Logger LOG = LoggerFactory.getLogger(SimpleTelegramClient.class);
public static ExecutorService blockingExecutor = Executors.newSingleThreadExecutor();
public SimpleTelegramClientInteraction(ExecutorService blockingExecutor) {
this.blockingExecutor = blockingExecutor;
}
@Override
public void onParameterRequest(
InputParameter parameter,
ParameterInfo parameterInfo,
Consumer<String> result
)