public final class TelegramBot extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
API_URL
The API URL endpoint that is constant for all bots
|
static com.google.gson.Gson |
GSON
A GSON instance that is used throughout the project wherever GSON is needed
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
answerCallbackQuery(String callbackQueryId,
CallbackQueryResponse callbackQueryResponse)
This allows you to respond to a callback query with some text as a response.
|
boolean |
answerCallbackQuery(String callbackQueryId,
String text,
boolean showAlert)
Deprecated.
This method is deprecated in favour of the
answerCallbackQuery(String, CallbackQueryResponse)
method, this should be used for all new implementations |
boolean |
answerInlineQuery(String inlineQueryId,
InlineQueryResponse inlineQueryResponse)
This allows you to respond to an inline query with an InlineQueryResponse object
|
boolean |
editInlineCaption(String inlineMessageId,
String caption,
InlineReplyMarkup inlineReplyMarkup)
This allows you to edit the caption of any captionable inline message you have sent previously (The inline
message must have an InlineReplyMarkup object attached in order to be editable)
|
boolean |
editInlineMessageReplyMarkup(String inlineMessageId,
InlineReplyMarkup inlineReplyMarkup)
This allows you to edit the InlineReplyMarkup of any inline message that you have sent previously.
|
boolean |
editInlineMessageText(String inlineMessageId,
String text,
ParseMode parseMode,
boolean disableWebPagePreview,
InlineReplyMarkup inlineReplyMarkup)
This allows you to edit the text of an inline message you have sent previously.
|
Message |
editMessageCaption(Message oldMessage,
String caption,
InlineReplyMarkup inlineReplyMarkup)
This allows you to edit the caption of any captionable message you have sent previously
|
Message |
editMessageCaption(String chatId,
Long messageId,
String caption,
InlineReplyMarkup inlineReplyMarkup)
This allows you to edit the caption of any captionable message you have sent previously
|
Message |
editMessageReplyMarkup(Message oldMessage,
InlineReplyMarkup inlineReplyMarkup)
This allows you to edit the InlineReplyMarkup of any message that you have sent previously.
|
Message |
editMessageReplyMarkup(String chatId,
Long messageId,
InlineReplyMarkup inlineReplyMarkup)
This allows you to edit the InlineReplyMarkup of any message that you have sent previously.
|
Message |
editMessageText(Message oldMessage,
String text,
ParseMode parseMode,
boolean disableWebPagePreview,
InlineReplyMarkup inlineReplyMarkup)
This allows you to edit the text of a message you have already sent previously
|
Message |
editMessageText(String chatId,
Long messageId,
String text,
ParseMode parseMode,
boolean disableWebPagePreview,
InlineReplyMarkup inlineReplyMarkup)
This allows you to edit the text of a message you have already sent previously
|
String |
getBotAPIUrl()
This provides the URL used to make all the API calls to the bot API
|
Chat |
getChat(long chatID)
A method used to get a Chat object via the chats ID
|
Chat |
getChat(String chatID)
A method used to get a Chat object via the chats ID
|
ListenerRegistry |
getEventsManager()
This provides access to the events manager which can be used to register and unregister Listeners
|
List<GameHighScore> |
getGameHighScores(GameScoreRequest gameScoreRequest) |
boolean |
kickChatMember(String chatId,
int userId)
Use this method to kick a user from a group or a supergroup.
|
static TelegramBot |
login(String authToken)
Use this method to get a new TelegramBot instance with the selected auth token
|
Message |
sendMessage(Chat chat,
SendableMessage message)
This will send the provided SendableMessage object to the Chat that the Chat object represents
|
GameScoreEditResponse |
setGameScore(SendableGameScore sendableGameScore) |
boolean |
startUpdates(boolean getPreviousUpdates)
Use this method to start the update thread which will begin retrieving messages from the API and firing the
relevant events for you to process the data
|
void |
stopUpdates()
Calling this method will stop the updater from running and therefore no more events will be fired
|
boolean |
unbanChatMember(String chatId,
int userId)
Use this method to unban a previously kicked user in a supergroup.
|
public static final String API_URL
public static final com.google.gson.Gson GSON
public static TelegramBot login(String authToken)
authToken - The bots auth tokenpublic Chat getChat(long chatID)
chatID - The Chat ID of the chat you want a Chat object ofpublic Chat getChat(String chatID)
chatID - The Chat ID of the chat you want a Chat object ofpublic String getBotAPIUrl()
public Message sendMessage(Chat chat, SendableMessage message)
chat - The chat you want to send the message tomessage - The message you want to send to the chatpublic Message editMessageText(Message oldMessage, String text, ParseMode parseMode, boolean disableWebPagePreview, InlineReplyMarkup inlineReplyMarkup)
oldMessage - The Message object that represents the message you want to edittext - The new text you want to displayparseMode - The ParseMode that should be used with this new textdisableWebPagePreview - Whether any URLs should be displayed with a preview of their contentinlineReplyMarkup - Any InlineReplyMarkup object you want to edit into the messagepublic Message editMessageText(String chatId, Long messageId, String text, ParseMode parseMode, boolean disableWebPagePreview, InlineReplyMarkup inlineReplyMarkup)
chatId - The chat ID of the chat containing the message you want to editmessageId - The message ID of the message you want to edittext - The new text you want to displayparseMode - The ParseMode that should be used with this new textdisableWebPagePreview - Whether any URLs should be displayed with a preview of their contentinlineReplyMarkup - Any InlineReplyMarkup object you want to edit into the messagepublic boolean editInlineMessageText(String inlineMessageId, String text, ParseMode parseMode, boolean disableWebPagePreview, InlineReplyMarkup inlineReplyMarkup)
inlineMessageId - The ID of the inline message you want to edittext - The new text you want to displayparseMode - The ParseMode that should be used with this new textdisableWebPagePreview - Whether any URLs should be displayed with a preview of their contentinlineReplyMarkup - Any InlineReplyMarkup object you want to edit into the messagepublic Message editMessageCaption(Message oldMessage, String caption, InlineReplyMarkup inlineReplyMarkup)
oldMessage - The Message object that represents the message you want to editcaption - The new caption you want to displayinlineReplyMarkup - Any InlineReplyMarkup object you want to edit into the messagepublic Message editMessageCaption(String chatId, Long messageId, String caption, InlineReplyMarkup inlineReplyMarkup)
chatId - The chat ID of the chat containing the message you want to editmessageId - The message ID of the message you want to editcaption - The new caption you want to displayinlineReplyMarkup - Any InlineReplyMarkup object you want to edit into the messagepublic boolean editInlineCaption(String inlineMessageId, String caption, InlineReplyMarkup inlineReplyMarkup)
inlineMessageId - The ID of the inline message you want to editcaption - The new caption you want to displayinlineReplyMarkup - Any InlineReplyMarkup object you want to edit into the messagepublic Message editMessageReplyMarkup(Message oldMessage, InlineReplyMarkup inlineReplyMarkup)
oldMessage - The Message object that represents the message you want to editinlineReplyMarkup - Any InlineReplyMarkup object you want to edit into the messagepublic Message editMessageReplyMarkup(String chatId, Long messageId, InlineReplyMarkup inlineReplyMarkup)
chatId - The chat ID of the chat containing the message you want to editmessageId - The message ID of the message you want to editinlineReplyMarkup - Any InlineReplyMarkup object you want to edit into the messagepublic boolean editInlineMessageReplyMarkup(String inlineMessageId, InlineReplyMarkup inlineReplyMarkup)
inlineMessageId - The ID of the inline message you want to editinlineReplyMarkup - Any InlineReplyMarkup object you want to edit into the messagepublic boolean answerInlineQuery(String inlineQueryId, InlineQueryResponse inlineQueryResponse)
inlineQueryId - The ID of the inline query you are responding toinlineQueryResponse - The InlineQueryResponse object that you want to send to the user@Deprecated public boolean answerCallbackQuery(String callbackQueryId, String text, boolean showAlert)
answerCallbackQuery(String, CallbackQueryResponse)
method, this should be used for all new implementationscallbackQueryId - The ID of the callback query you are responding totext - The text you would like to respond withshowAlert - True will show the text as an alert, false will show it as a toast notificationpublic boolean answerCallbackQuery(String callbackQueryId, CallbackQueryResponse callbackQueryResponse)
callbackQueryId - The ID of the callback query you are responding tocallbackQueryResponse - The response that you would like to send in reply to this callback querypublic boolean kickChatMember(String chatId, int userId)
chatId - The ID of the chat that you want to kick the user fromuserId - The ID of the user that you want to kick from the chatpublic boolean unbanChatMember(String chatId, int userId)
chatId - The ID of the chat that you want to unban the user fromuserId - The ID of the user that you want to unban from the chatpublic GameScoreEditResponse setGameScore(SendableGameScore sendableGameScore)
public List<GameHighScore> getGameHighScores(GameScoreRequest gameScoreRequest)
public boolean startUpdates(boolean getPreviousUpdates)
getPreviousUpdates - Whether you want to retrieve any updates that haven't been processed before, but were
created prior to calling the startUpdates methodpublic void stopUpdates()
public ListenerRegistry getEventsManager()
Copyright © 2017. All rights reserved.