Merges #249
This commit is contained in:
parent
4dd8205974
commit
082942ac9a
@ -63,5 +63,7 @@
|
||||
### <a id="3.0.2"></a>3.0.2 ###
|
||||
1. Bug Fixing: #250
|
||||
2. Added new module `telegrambots-extensions` that should contains any extensions of the API such as CommandBot or TimedBot.
|
||||
3. `TelegramLongPollingCommandBot` receives now the bot username as constructor parameters, all deprecated constructors will be removed in next mayor release.
|
||||
4. `getUsername` method from `TelegramLongPollingCommandBot` can be considered `final` and will be so in next mayor release.
|
||||
|
||||
**[[How to update to version 3.0.2|How-To-Update#3.0.2]]**
|
||||
|
@ -26,4 +26,5 @@
|
||||
1. In `Message` object, field `new_chat_member` was replaced by `new_chat_members` that is now an array of users.
|
||||
|
||||
### <a id="3.0.2"></a>To version 3.0.2 ###
|
||||
1. If you were using `TelegramLongPollingCommandBot`, add the new [extensions dependency](https://github.com/rubenlagus/TelegramBots/tree/master/telegrambots-extensions) to your maven and fix import statements in your project.
|
||||
1. If you were using `TelegramLongPollingCommandBot`, add the new [extensions dependency](https://github.com/rubenlagus/TelegramBots/tree/master/telegrambots-extensions) to your maven and fix import statements in your project.
|
||||
2. If you were using `TelegramLongPollingCommandBot`, make sure you start using constructors with username and prevent overriding `getUsername` method.
|
@ -22,32 +22,63 @@ import java.util.function.BiConsumer;
|
||||
*/
|
||||
public abstract class TelegramLongPollingCommandBot extends TelegramLongPollingBot implements ICommandRegistry {
|
||||
private final CommandRegistry commandRegistry;
|
||||
private String botUsername;
|
||||
|
||||
/**
|
||||
* Creates a TelegramLongPollingCommandBot using default options
|
||||
* Use ICommandRegistry's methods on this bot to register commands
|
||||
*
|
||||
* @deprecated Uses {@link #TelegramLongPollingCommandBot(String)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public TelegramLongPollingCommandBot() {
|
||||
this(ApiContext.getInstance(DefaultBotOptions.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a TelegramLongPollingCommandBot using default options
|
||||
* Use ICommandRegistry's methods on this bot to register commands
|
||||
*
|
||||
* @param botUsername Username of the bot
|
||||
*/
|
||||
public TelegramLongPollingCommandBot(String botUsername) {
|
||||
this(ApiContext.getInstance(DefaultBotOptions.class), botUsername);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a TelegramLongPollingCommandBot with custom options and allowing commands with
|
||||
* usernames
|
||||
* Use ICommandRegistry's methods on this bot to register commands
|
||||
* @param options Bot options
|
||||
*
|
||||
* @deprecated Use {@link #TelegramLongPollingCommandBot(DefaultBotOptions, String)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public TelegramLongPollingCommandBot(DefaultBotOptions options) {
|
||||
this(options, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a TelegramLongPollingCommandBot with custom options and allowing commands with
|
||||
* usernames
|
||||
* Use ICommandRegistry's methods on this bot to register commands
|
||||
* @param options Bot options
|
||||
* @param botUsername Username of the bot
|
||||
*/
|
||||
public TelegramLongPollingCommandBot(DefaultBotOptions options, String botUsername) {
|
||||
this(options, true, botUsername);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a TelegramLongPollingCommandBot
|
||||
* Use ICommandRegistry's methods on this bot to register commands
|
||||
* @param options Bot options
|
||||
* @param allowCommandsWithUsername true to allow commands with parameters (default),
|
||||
* false otherwise
|
||||
*
|
||||
* @deprecated Use {@link #TelegramLongPollingCommandBot(DefaultBotOptions, boolean, String)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public TelegramLongPollingCommandBot(DefaultBotOptions options, boolean allowCommandsWithUsername) {
|
||||
super(options);
|
||||
this.commandRegistry = new CommandRegistry(allowCommandsWithUsername, getBotUsername());
|
||||
@ -63,6 +94,7 @@ public abstract class TelegramLongPollingCommandBot extends TelegramLongPollingB
|
||||
*/
|
||||
public TelegramLongPollingCommandBot(DefaultBotOptions options, boolean allowCommandsWithUsername, String botUsername) {
|
||||
super(options);
|
||||
this.botUsername = botUsername;
|
||||
this.commandRegistry = new CommandRegistry(allowCommandsWithUsername, botUsername);
|
||||
}
|
||||
|
||||
@ -131,6 +163,15 @@ public abstract class TelegramLongPollingCommandBot extends TelegramLongPollingB
|
||||
return commandRegistry.getRegisteredCommand(commandIdentifier);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO This method will become final in next mayor release, avoid overriding it
|
||||
* @return Bot username
|
||||
*/
|
||||
@Override
|
||||
public String getBotUsername() {
|
||||
return botUsername;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process all updates, that are not commands.
|
||||
* @warning Commands that have valid syntax but are not registered on this bot,
|
||||
|
Loading…
Reference in New Issue
Block a user