Package org.telegram.telegrambots.bots
Class DefaultAbsSender
- java.lang.Object
-
- org.telegram.telegrambots.meta.bots.AbsSender
-
- org.telegram.telegrambots.bots.DefaultAbsSender
-
- Direct Known Subclasses:
TelegramLongPollingBot,TelegramWebhookBot
public abstract class DefaultAbsSender extends AbsSender
- Version:
- 1.0 Implementation of all the methods needed to interact with Telegram Servers
- Author:
- Ruben Bermudez
-
-
Field Summary
Fields Modifier and Type Field Description protected ExecutorServiceexe
-
Constructor Summary
Constructors Modifier Constructor Description protectedDefaultAbsSender(DefaultBotOptions options)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description FiledownloadFile(String filePath)FiledownloadFile(String filePath, File outputFile)FiledownloadFile(File file)FiledownloadFile(File file, File outputFile)InputStreamdownloadFileAsStream(String filePath)InputStreamdownloadFileAsStream(File file)voiddownloadFileAsync(String filePath, DownloadFileCallback<String> callback)voiddownloadFileAsync(File file, DownloadFileCallback<File> callback)Booleanexecute(SetChatPhoto setChatPhoto)Messageexecute(SendAnimation sendAnimation)Messageexecute(SendAudio sendAudio)Sends a file using Send Audio method (https://core.telegram.org/bots/api#sendaudio)Messageexecute(SendDocument sendDocument)List<Message>execute(SendMediaGroup sendMediaGroup)Messageexecute(SendPhoto sendPhoto)Messageexecute(SendSticker sendSticker)Messageexecute(SendVideo sendVideo)Messageexecute(SendVideoNote sendVideoNote)Messageexecute(SendVoice sendVoice)Sends a voice note using Send Voice method (https://core.telegram.org/bots/api#sendvoice) For this to work, your audio must be in an .ogg file encoded with OPUSBooleanexecute(AddStickerToSet addStickerToSet)Booleanexecute(CreateNewStickerSet createNewStickerSet)Booleanexecute(SetStickerSetThumb setStickerSetThumb)Fileexecute(UploadStickerFile uploadStickerFile)Serializableexecute(EditMessageMedia editMessageMedia)StringgetBaseUrl()abstract StringgetBotToken()Returns the token of the bot to be able to perform Telegram Api RequestsDefaultBotOptionsgetOptions()protected <T extends Serializable,Method extends BotApiMethod<T>>
TsendApiMethod(Method method)protected <T extends Serializable,Method extends BotApiMethod<T>,Callback extends SentCallback<T>>
voidsendApiMethodAsync(Method method, Callback callback)-
Methods inherited from class org.telegram.telegrambots.meta.bots.AbsSender
execute, executeAsync, getMe, getMeAsync, getWebhookInfo, getWebhookInfoAsync
-
-
-
-
Field Detail
-
exe
protected final ExecutorService exe
-
-
Constructor Detail
-
DefaultAbsSender
protected DefaultAbsSender(DefaultBotOptions options)
-
-
Method Detail
-
getBotToken
public abstract String getBotToken()
Returns the token of the bot to be able to perform Telegram Api Requests- Returns:
- Token of the bot
-
getOptions
public final DefaultBotOptions getOptions()
-
downloadFile
public final File downloadFile(String filePath) throws TelegramApiException
- Throws:
TelegramApiException
-
downloadFile
public final File downloadFile(File file) throws TelegramApiException
- Throws:
TelegramApiException
-
downloadFile
public final File downloadFile(File file, File outputFile) throws TelegramApiException
- Throws:
TelegramApiException
-
downloadFile
public final File downloadFile(String filePath, File outputFile) throws TelegramApiException
- Throws:
TelegramApiException
-
downloadFileAsync
public final void downloadFileAsync(String filePath, DownloadFileCallback<String> callback) throws TelegramApiException
- Throws:
TelegramApiException
-
downloadFileAsync
public final void downloadFileAsync(File file, DownloadFileCallback<File> callback) throws TelegramApiException
- Throws:
TelegramApiException
-
downloadFileAsStream
public final InputStream downloadFileAsStream(String filePath) throws TelegramApiException
- Throws:
TelegramApiException
-
downloadFileAsStream
public final InputStream downloadFileAsStream(File file) throws TelegramApiException
- Throws:
TelegramApiException
-
execute
public final Message execute(SendDocument sendDocument) throws TelegramApiException
- Specified by:
executein classAbsSender- Throws:
TelegramApiException
-
execute
public final Message execute(SendPhoto sendPhoto) throws TelegramApiException
- Specified by:
executein classAbsSender- Throws:
TelegramApiException
-
execute
public final Message execute(SendVideo sendVideo) throws TelegramApiException
- Specified by:
executein classAbsSender- Throws:
TelegramApiException
-
execute
public final Message execute(SendVideoNote sendVideoNote) throws TelegramApiException
- Specified by:
executein classAbsSender- Throws:
TelegramApiException
-
execute
public final Message execute(SendSticker sendSticker) throws TelegramApiException
- Specified by:
executein classAbsSender- Throws:
TelegramApiException
-
execute
public final Message execute(SendAudio sendAudio) throws TelegramApiException
Sends a file using Send Audio method (https://core.telegram.org/bots/api#sendaudio)- Specified by:
executein classAbsSender- Parameters:
sendAudio- Information to send- Returns:
- If success, the sent Message is returned
- Throws:
TelegramApiException- If there is any error sending the audio
-
execute
public final Message execute(SendVoice sendVoice) throws TelegramApiException
Sends a voice note using Send Voice method (https://core.telegram.org/bots/api#sendvoice) For this to work, your audio must be in an .ogg file encoded with OPUS- Specified by:
executein classAbsSender- Parameters:
sendVoice- Information to send- Returns:
- If success, the sent Message is returned
- Throws:
TelegramApiException- If there is any error sending the audio
-
execute
public Boolean execute(SetChatPhoto setChatPhoto) throws TelegramApiException
- Specified by:
executein classAbsSender- Throws:
TelegramApiException
-
execute
public List<Message> execute(SendMediaGroup sendMediaGroup) throws TelegramApiException
- Specified by:
executein classAbsSender- Throws:
TelegramApiException
-
execute
public Boolean execute(AddStickerToSet addStickerToSet) throws TelegramApiException
- Specified by:
executein classAbsSender- Throws:
TelegramApiException
-
execute
public Boolean execute(SetStickerSetThumb setStickerSetThumb) throws TelegramApiException
- Specified by:
executein classAbsSender- Throws:
TelegramApiException
-
execute
public Boolean execute(CreateNewStickerSet createNewStickerSet) throws TelegramApiException
- Specified by:
executein classAbsSender- Throws:
TelegramApiException
-
execute
public File execute(UploadStickerFile uploadStickerFile) throws TelegramApiException
- Specified by:
executein classAbsSender- Throws:
TelegramApiException
-
execute
public Serializable execute(EditMessageMedia editMessageMedia) throws TelegramApiException
- Specified by:
executein classAbsSender- Throws:
TelegramApiException
-
execute
public Message execute(SendAnimation sendAnimation) throws TelegramApiException
- Specified by:
executein classAbsSender- Throws:
TelegramApiException
-
sendApiMethodAsync
protected final <T extends Serializable,Method extends BotApiMethod<T>,Callback extends SentCallback<T>> void sendApiMethodAsync(Method method, Callback callback)
- Specified by:
sendApiMethodAsyncin classAbsSender
-
sendApiMethod
protected final <T extends Serializable,Method extends BotApiMethod<T>> T sendApiMethod(Method method) throws TelegramApiException
- Specified by:
sendApiMethodin classAbsSender- Throws:
TelegramApiException
-
getBaseUrl
public String getBaseUrl()
-
-