It is a light weight framework to manage your Telegram Bot
You can download the library using Gradle or Maven
compile 'com.ajts.library.telegrambot:telegrambotlibrary:1.0.0'
<dependency>
<groupId>com.ajts.library.telegrambot</groupId>
<artifactId>telegrambotlibrary</artifactId>
<version>1.0.0</version>
<type>pom</type>
</dependency>
Telegram telegram = new Telegram("<bot-token>");
telegram.getMe(new TelegramCallback<GetMe>() {
@Override
public void onResponse(Call call, final GetMe getMe) {
Log.v("response.body()", getMe.isOk() + "");
}
@Override
public void onFailure(Call call, Exception e) {
}
});
telegram.sendMessage("<Channel-Name or Chat-ID>", "TelegramBotLibrary", new TelegramCallback<Message>() {
@Override
public void onResponse(Call call, Message response) {
Log.v("response.body()", response.isOk() + "");
}
@Override
public void onFailure(Call call, Exception e) {
}
});
telegram.sendMessage("<Channel-Name or Chat-ID>",
"<i>TelegramBotLibrary</i>",
Telegram.ParseMode.HTML,
new TelegramCallback<Message>() {
@Override
public void onResponse(Call call, Message response) {
Toast.makeText(MainActivity.this, response.isOk() + "", Toast.LENGTH_SHORT).show();
}
@Override
public void onFailure(Call call, Exception e) {
}
});
telegram.sendMessage("<Channel-Name or Chat-ID>",
"*TelegramBotLibrary*",
Telegram.ParseMode.Markdown,
new TelegramCallback<Message>() {
@Override
public void onResponse(Call call, Message response) {
Toast.makeText(MainActivity.this, response.isOk() + "", Toast.LENGTH_SHORT).show();
}
@Override
public void onFailure(Call call, Exception e) {
}
});
telegram.sendPhoto("<Channel-Name or Chat-ID>",
TelegramMediaType.Image.png,
new File(imagePickedPath),
"telegram photo",
new TelegramCallback<Message>() {
@Override
public void onResponse(Call call, Message response) {
Toast.makeText(MainActivity.this, response.isOk() + "", Toast.LENGTH_SHORT).show();
}
@Override
public void onFailure(Call call, Exception e) {
}
});
telegram.sendVideo("<Channel-Name or Chat-ID>",
TelegramMediaType.Video.mp4,
new File(videoPickedPath),
"telegram video",
new TelegramCallback<Message>() {
@Override
public void onResponse(Call call, Message response) {
Toast.makeText(MainActivity.this, response.isOk() + "", Toast.LENGTH_SHORT).show();
}
@Override
public void onFailure(Call call, Exception e) {
}
});
telegram.sendAudio("<Channel-Name or Chat-ID>",
TelegramMediaType.Audio.mp3,
new File(audioPickedPath),
"telegram audio",
new TelegramCallback<Message>() {
@Override
public void onResponse(Call call, Message response) {
Toast.makeText(MainActivity.this, response.isOk() + "", Toast.LENGTH_SHORT).show();
}
@Override
public void onFailure(Call call, Exception e) {
}
});
telegram.sendDocument("<Channel-Name or Chat-ID>",
TelegramMediaType.Document.file,
new File(documentPickedPath),
"telegram document",
new TelegramCallback<Message>() {
@Override
public void onResponse(Call call, Message response) {
Toast.makeText(MainActivity.this, response.isOk() + "", Toast.LENGTH_SHORT).show();
}
@Override
public void onFailure(Call call, Exception e) {
}
});
telegram.sendLocation("<Channel-Name or Chat-ID>",
"<Latitude>",
"<Longitude>",
new TelegramCallback<Message>() {
@Override
public void onResponse(Call call, Message response) {
Toast.makeText(MainActivity.this, response.isOk() + "", Toast.LENGTH_SHORT).show();
}
@Override
public void onFailure(Call call, Exception e) {
}
});
telegram.sendVenue("<Channel-Name or Chat-ID>",
"<Latitude>",
"<Longitude>",
"<Address>",
"<Country>",
new TelegramCallback<Message>() {
@Override
public void onResponse(Call call, Message response) {
Toast.makeText(MainActivity.this, response.isOk() + "", Toast.LENGTH_SHORT).show();
}
@Override
public void onFailure(Call call, Exception e) {
}
});