new constructor in TelegramLongPollingCommandBot, to be able to set a botname in subclasses

This commit is contained in:
xDrake 2017-06-09 11:25:58 +03:00
parent 0312a3bcb1
commit 5e5bbe4f77

View File

@ -44,12 +44,28 @@ public abstract class TelegramLongPollingCommandBot extends TelegramLongPollingB
* @param options Bot options * @param options Bot options
* @param allowCommandsWithUsername true to allow commands with parameters (default), * @param allowCommandsWithUsername true to allow commands with parameters (default),
* false otherwise * false otherwise
*
* @deprecated When calling this constructor, method getUsername() is not yet initialized in a subclass
*/ */
@Deprecated
public TelegramLongPollingCommandBot(DefaultBotOptions options, boolean allowCommandsWithUsername) { public TelegramLongPollingCommandBot(DefaultBotOptions options, boolean allowCommandsWithUsername) {
super(options); super(options);
this.commandRegistry = new CommandRegistry(allowCommandsWithUsername, getBotUsername()); this.commandRegistry = new CommandRegistry(allowCommandsWithUsername, getBotUsername());
} }
/**
* Creates a TelegramLongPollingCommandBot
* Use ICommandRegistry's methods on this bot to register commands
* @param options Bot options
* @param botUsername bot username of this bot
* @param allowCommandsWithUsername true to allow commands with parameters (default),
* false otherwise
*/
public TelegramLongPollingCommandBot(DefaultBotOptions options, String botUsername, boolean allowCommandsWithUsername) {
super(options);
this.commandRegistry = new CommandRegistry(allowCommandsWithUsername, botUsername);
}
@Override @Override
public final void onUpdateReceived(Update update) { public final void onUpdateReceived(Update update) {
if (update.hasMessage()) { if (update.hasMessage()) {