This library allows you to make rpc calls to Telegram.
Depends on tl-core and mtproto libraries.
Now it used in our production-ready product Telegram S.
This project depends on java MTProto implementation and tl-core library
Download latest distribution at releases page and include jars from it to your project.
Project definded and gradle and expected to use IntelliJ IDEA 13 (now it is Beta) as IDE.
- Checkout this repository to
telegram-apifolder - Checkout mtproto java implementation to
mtprotofolder - Checkout tl core library to
tl-corefolder - Execute
gradle buildattelegram-apifolder
You might to implement storage class for working with api. This storage used for saving state of telegram api across execution instances.
Extend class org.telegram.api.engine.storage.AbsApiState and implement suitable methods.
In your storage might be information about keys in current datacenter.
Keys might be generated manualy by using org.telegram.mtproto.pq.Authorizer class.
Now you have proper key for accessing telegram api.
TelegramApiapi = newTelegramApi(newMyApiStorage(), newAppInfo(... putapplicationinformationhere...), newApiCallback()
{
@OverridepublicvoidonApiDies(TelegramApiapi) {
// When auth key or user authorization dies
}
@OverridepublicvoidonUpdatesInvalidated(TelegramApiapi) {
// When api engine expects that update sequence might be broken
}
});
// Syncronized call// All request objects are in org.telegram.api.requests packageTLConfigconfig = api.doRpcCall(newTLRequestHelpGetConfig());
// Standart async callapi.doRpcCall(newTLRequestHelpGetConfig(), newRpcCallback<TLConfig>()
{
publicvoidonResult(TLConfigresult)
{
}
publicvoidonError(interrorCode, Stringmessage)
{
// errorCode == 0 if request timeouted
}
});
// Priority async call// Such rpc call executed with high pripory and sends to server as fast as possible this may improve message delivery speedapi.doRpcCall(newTLRequestHelpGetConfig(), newRpcCallbackEx<TLConfig>()
{
publicvoidonConfirmed()
{
// when message was received by server
}
publicvoidonResult(TLConfigresult)
{
}
publicvoidonError(interrorCode, Stringmessage)
{
// errorCode == 0 if request timeouted
}
});
// File operations// Method that downloads file part. Automaticaly managed connections for file operations, automaticaly create keys for dc if there is no one.api.doGetFile(...)
// Uploads file partapi.doSaveFilePart(...)####Telegram project
English: http://core.telegram.org/api
Russian: http://dev.stel.com/api
English: http://core.telegram.org/mtproto
Russian: http://dev.stel.com/mtproto
English: http://core.telegram.org/mtproto/TL
Russian: http://dev.stel.com/mtproto/TL
Project uses MIT Licence
