Add default behaviour for some methods in CommandBot interface
This commit is contained in:
parent
54575990bc
commit
db8aa6ac3e
@ -24,7 +24,9 @@ public interface CommandBot {
|
||||
*
|
||||
* @param update Received update from Telegram
|
||||
*/
|
||||
void processInvalidCommandUpdate(Update update);
|
||||
default void processInvalidCommandUpdate(Update update) {
|
||||
processNonCommandUpdate(update);
|
||||
}
|
||||
|
||||
/**
|
||||
* Override this function in your bot implementation to filter messages with commands
|
||||
@ -39,5 +41,7 @@ public interface CommandBot {
|
||||
* false otherwise
|
||||
* @note Default implementation doesn't filter anything
|
||||
*/
|
||||
boolean filter(Message message);
|
||||
default boolean filter(Message message) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -70,16 +70,6 @@ public abstract class TelegramLongPollingCommandBot extends TelegramLongPollingB
|
||||
processNonCommandUpdate(update);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processInvalidCommandUpdate(Update update) {
|
||||
processNonCommandUpdate(update);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean filter(Message message) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean register(IBotCommand botCommand) {
|
||||
return commandRegistry.register(botCommand);
|
||||
|
@ -72,16 +72,6 @@ public abstract class TelegramWebhookCommandBot extends TelegramWebhookBot imple
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processInvalidCommandUpdate(Update update) {
|
||||
processNonCommandUpdate(update);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean filter(Message message) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean register(IBotCommand botCommand) {
|
||||
return commandRegistry.register(botCommand);
|
||||
@ -116,10 +106,4 @@ public abstract class TelegramWebhookCommandBot extends TelegramWebhookBot imple
|
||||
public final IBotCommand getRegisteredCommand(String commandIdentifier) {
|
||||
return commandRegistry.getRegisteredCommand(commandIdentifier);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Bot username
|
||||
*/
|
||||
@Override
|
||||
public abstract String getBotUsername();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user