remove commandbot example from readme
This commit is contained in:
parent
86f6e2785a
commit
01f321d917
57
README.md
57
README.md
@ -44,64 +44,7 @@ Once done, you just need to create a `org.telegram.telegrambots.TelegramBotsApi`
|
||||
}
|
||||
|
||||
```
|
||||
## Command Bot
|
||||
|
||||
In order to make commands work for your bot by using the `org.telegram.telegrambots.bots.TelegramLongPollingCommandBot` you can
|
||||
just make your Bot extend this class instead of the `org.telegram.telegrambots.bots.TelegramLongPollingBot`.
|
||||
|
||||
Since this bot inherits from `org.telegram.telegrambots.bots.commands.ICommandRegistry` it is capable of register- and
|
||||
deregistering commands to your bot.
|
||||
|
||||
Here is an example:
|
||||
|
||||
```java
|
||||
|
||||
public class Main {
|
||||
|
||||
private static final String LOGTAG = "MAIN";
|
||||
|
||||
public static void main(String[] args) {
|
||||
TelegramBotsApi telegramBotsApi = new TelegramBotsApi();
|
||||
try {
|
||||
telegramBotsApi.registerBot(new MySuperSpecialBotHandler());
|
||||
} catch (TelegramApiException e) {
|
||||
BotLogger.error(LOGTAG, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
```java
|
||||
|
||||
public class MySuperSpecialBotHandler extends TelegramLongPollingCommandBot {
|
||||
|
||||
private static final String LOGTAG = "MY_SUPER_SPECIAL_BOT_HANDLER";
|
||||
|
||||
public MySuperSpecialBotHandler() {
|
||||
register(new BotCommand("mycommand", "This command just demonstrates the use of commands") {
|
||||
@Override
|
||||
public void execute(AbsSender absSender, Chat chat, String[] arguments) {
|
||||
SendMessage sendMessage = new SendMessage();
|
||||
sendMessage.setText("Wow you finally used that command " + chat.getUserName());
|
||||
sendMessage.setChatId(chat.getId().toString());
|
||||
try {
|
||||
absSender.sendMessage(sendMessage);
|
||||
} catch (TelegramApiException e) {
|
||||
BotLogger.error(LOGTAG, e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processNonCommandUpdate(Update update) {
|
||||
//All non command updates are passed to this method
|
||||
}
|
||||
|
||||
.
|
||||
.
|
||||
.
|
||||
}
|
||||
```
|
||||
|
||||
## Example bots
|
||||
Open them and send them */help* command to get some information about their capabilities:
|
||||
|
Loading…
Reference in New Issue
Block a user