public final class Bot
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
java.io.InputStream |
downloadFile(java.lang.String fileId)
Returns the file with the specified id.
|
<T extends java.io.Serializable> |
execute(TelegramMethod<T> method)
Invokes a method of the Telegram Bot API.
|
static Bot |
fromApiUrl(java.lang.String apiUrl,
java.lang.String apiFileUrl)
Constructs and returns a Telegram Bot with the API url
and ensures that it is a valid bot.
|
static Bot |
fromToken(java.lang.String token)
Constructs and returns a Telegram Bot with a
token and ensures that it is a valid bot.
|
long |
getId()
Returns the id of the bot.
|
java.lang.String |
getUsername()
Returns the username of the bot.
|
public static Bot fromToken(java.lang.String token) throws java.io.IOException
token - the token used for the connection to the Telegram APIjava.io.IOException - if an I/O Exception occursTelegramException - if the token is invalidpublic static Bot fromApiUrl(java.lang.String apiUrl, java.lang.String apiFileUrl) throws java.io.IOException
apiUrl - the API urlapiFileUrl - the API file urljava.io.IOException - if an I/O Exception occursTelegramException - if the token is invalidpublic <T extends java.io.Serializable> T execute(TelegramMethod<T> method) throws java.io.IOException
T - the return type of the methodmethod - the method to executejava.io.IOException - if an I/O error occursTelegramException - if the method invocation returns an errorpublic java.io.InputStream downloadFile(java.lang.String fileId)
throws java.io.IOException
fileId - the id of the file to downloadjava.io.IOException - when an I/O Exception occurspublic java.lang.String getUsername()
public long getId()