From 5e5bbe4f77f973c371b2c5e114f6dd9d511a5f69 Mon Sep 17 00:00:00 2001 From: xDrake Date: Fri, 9 Jun 2017 11:25:58 +0300 Subject: [PATCH 1/2] new constructor in TelegramLongPollingCommandBot, to be able to set a botname in subclasses --- .../bots/TelegramLongPollingCommandBot.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/telegrambots/src/main/java/org/telegram/telegrambots/bots/TelegramLongPollingCommandBot.java b/telegrambots/src/main/java/org/telegram/telegrambots/bots/TelegramLongPollingCommandBot.java index 3cf4edea..1992bbff 100644 --- a/telegrambots/src/main/java/org/telegram/telegrambots/bots/TelegramLongPollingCommandBot.java +++ b/telegrambots/src/main/java/org/telegram/telegrambots/bots/TelegramLongPollingCommandBot.java @@ -44,12 +44,28 @@ public abstract class TelegramLongPollingCommandBot extends TelegramLongPollingB * @param options Bot options * @param allowCommandsWithUsername true to allow commands with parameters (default), * false otherwise + * + * @deprecated When calling this constructor, method getUsername() is not yet initialized in a subclass */ + @Deprecated public TelegramLongPollingCommandBot(DefaultBotOptions options, boolean allowCommandsWithUsername) { super(options); 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 public final void onUpdateReceived(Update update) { if (update.hasMessage()) { From 799949e80fca491077e1c7c3429622e169b88f72 Mon Sep 17 00:00:00 2001 From: xDrake Date: Sat, 10 Jun 2017 09:08:23 +0300 Subject: [PATCH 2/2] constructor correction --- .../telegrambots/bots/TelegramLongPollingCommandBot.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/telegrambots/src/main/java/org/telegram/telegrambots/bots/TelegramLongPollingCommandBot.java b/telegrambots/src/main/java/org/telegram/telegrambots/bots/TelegramLongPollingCommandBot.java index 1992bbff..a0e1e9a4 100644 --- a/telegrambots/src/main/java/org/telegram/telegrambots/bots/TelegramLongPollingCommandBot.java +++ b/telegrambots/src/main/java/org/telegram/telegrambots/bots/TelegramLongPollingCommandBot.java @@ -44,10 +44,7 @@ public abstract class TelegramLongPollingCommandBot extends TelegramLongPollingB * @param options Bot options * @param allowCommandsWithUsername true to allow commands with parameters (default), * false otherwise - * - * @deprecated When calling this constructor, method getUsername() is not yet initialized in a subclass */ - @Deprecated public TelegramLongPollingCommandBot(DefaultBotOptions options, boolean allowCommandsWithUsername) { super(options); this.commandRegistry = new CommandRegistry(allowCommandsWithUsername, getBotUsername()); @@ -57,11 +54,11 @@ public abstract class TelegramLongPollingCommandBot extends TelegramLongPollingB * 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 + * @param botUsername bot username of this bot */ - public TelegramLongPollingCommandBot(DefaultBotOptions options, String botUsername, boolean allowCommandsWithUsername) { + public TelegramLongPollingCommandBot(DefaultBotOptions options, boolean allowCommandsWithUsername, String botUsername) { super(options); this.commandRegistry = new CommandRegistry(allowCommandsWithUsername, botUsername); }