Class ATelegramBot
java.lang.Object
host.anzo.commons.socials.telegram.ATelegramBot
- All Implemented Interfaces:
org.telegram.telegrambots.longpolling.interfaces.LongPollingUpdateConsumer,org.telegram.telegrambots.longpolling.util.LongPollingSingleThreadUpdateConsumer
public abstract class ATelegramBot
extends Object
implements org.telegram.telegrambots.longpolling.util.LongPollingSingleThreadUpdateConsumer
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Stringprotected org.telegram.telegrambots.meta.generics.TelegramClientprotected static Fontprotected static Fontprotected static final intprotected static final intprotected StringFields inherited from interface org.telegram.telegrambots.longpolling.util.LongPollingSingleThreadUpdateConsumer
updatesProcessorExecutor -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddResendTask(Runnable runnable, int retryAfterSeconds) Add specified runnable to resend list (a message will be resent after specified seconds passed)voidconsume(org.telegram.telegrambots.meta.api.objects.Update update) Called when bot receives an update messageprotected voiddeleteMessage(String chatId, @NotNull org.telegram.telegrambots.meta.api.objects.message.Message message) Delete a message from channel with specified chatIdprotected abstract Stringprotected abstract org.telegram.telegrambots.meta.api.objects.replykeyboard.InlineKeyboardMarkupgetInlineKeyboardMarkup(org.telegram.telegrambots.meta.api.objects.Update update) Attach keyboard to a specified update messageprotected abstract org.telegram.telegrambots.meta.api.objects.replykeyboard.ReplyKeyboardMarkupabstract booleanprotected abstract voidCalled when server going shutdownvoidonTick()protected voidsendMessage(Long chatId, String title, String messageText, String additionalImagePath) Create image with specified text and additional imageprotected voidsendMessage(Long chatId, String title, String messageText, String caption, String additionalImagePath) Send a message with image to the channel with specified chatIdprotected voidsendMessage(String chatId, String messageText) Send text message to specified chatprotected voidsendMessage(String chatId, String title, String messageText, String caption, String additionalImagePath) Send a message with image to the channel with specified chatIdprotected voidsendMessage(org.telegram.telegrambots.meta.api.methods.send.SendMessage message) Send a message asynchronouslyprotected voidsendMessage(org.telegram.telegrambots.meta.api.objects.Update update, Long chatId, String messageText, boolean withInlineKeyboard) Send a text message to specified chat with the possibility to attach inline keyboardMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.telegram.telegrambots.longpolling.util.LongPollingSingleThreadUpdateConsumer
consume
-
Field Details
-
client
protected org.telegram.telegrambots.meta.generics.TelegramClient client -
botName
-
token
-
FONT_TITLE
-
FONT_CONTENT
-
MAX_MESSAGE_SIZE
protected static final int MAX_MESSAGE_SIZE- See Also:
-
MAX_CAPTION_SIZE
protected static final int MAX_CAPTION_SIZE- See Also:
-
-
Constructor Details
-
ATelegramBot
Telegram bot default constructor- Parameters:
botName- bot nametoken- bot token
-
-
Method Details
-
onTick
public void onTick() -
getInlineKeyboardMarkup
protected abstract org.telegram.telegrambots.meta.api.objects.replykeyboard.InlineKeyboardMarkup getInlineKeyboardMarkup(org.telegram.telegrambots.meta.api.objects.Update update) Attach keyboard to a specified update message- Parameters:
update- update message- Returns:
- inline keyboard markup will be attached to the update message
-
getReplyKeyboardMarkup
protected abstract org.telegram.telegrambots.meta.api.objects.replykeyboard.ReplyKeyboardMarkup getReplyKeyboardMarkup()- Returns:
- inline keyboard markup used for current bot
-
getDefaultBackgroundImagePath
- Returns:
- local path to image will be used as background for photo messages
-
onServerShutdown
protected abstract void onServerShutdown()Called when server going shutdown -
isEnabled
public abstract boolean isEnabled()- Returns:
trueif bot enabled,falseotherwise
-
sendMessage
protected void sendMessage(org.telegram.telegrambots.meta.api.methods.send.SendMessage message) Send a message asynchronously- Parameters:
message- message to send
-
sendMessage
Send text message to specified chat- Parameters:
chatId- symbolical chat namemessageText- message text
-
sendMessage
protected void sendMessage(org.telegram.telegrambots.meta.api.objects.Update update, Long chatId, String messageText, boolean withInlineKeyboard) Send a text message to specified chat with the possibility to attach inline keyboard- Parameters:
update- update objectchatId- channel chat idmessageText- message textwithInlineKeyboard-trueif need attach inline keyboard,falseotherwise
-
sendMessage
protected void sendMessage(Long chatId, String title, String messageText, String additionalImagePath) Create image with specified text and additional image- Parameters:
chatId- chat id where need a post created messagetitle- message titlemessageText- message textadditionalImagePath- additional image displayed on the right side
-
sendMessage
protected void sendMessage(Long chatId, String title, String messageText, String caption, String additionalImagePath) Send a message with image to the channel with specified chatId- Parameters:
chatId- channel chat idtitle- message titlemessageText- message textcaption- image captionadditionalImagePath- local path to image
-
sendMessage
protected void sendMessage(String chatId, String title, String messageText, String caption, String additionalImagePath) Send a message with image to the channel with specified chatId- Parameters:
chatId- channel chat idtitle- message titlemessageText- message textcaption- image captionadditionalImagePath- local path to image
-
deleteMessage
protected void deleteMessage(String chatId, @NotNull @NotNull org.telegram.telegrambots.meta.api.objects.message.Message message) Delete a message from channel with specified chatId- Parameters:
chatId- channel chat idmessage- message to delete
-
addResendTask
Add specified runnable to resend list (a message will be resent after specified seconds passed)- Parameters:
runnable- runnable with a message send taskretryAfterSeconds- seconds to resend
-
consume
public void consume(org.telegram.telegrambots.meta.api.objects.Update update) Called when bot receives an update message- Specified by:
consumein interfaceorg.telegram.telegrambots.longpolling.util.LongPollingSingleThreadUpdateConsumer- Parameters:
update- update message
-