commit
aa4e0d85f1
@ -31,12 +31,14 @@ Just import add the library to your project with one of these options:
|
|||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
2. Using Gradle:
|
||||||
|
|
||||||
```gradle
|
```gradle
|
||||||
compile "org.telegram:telegrambots:5.0.1"
|
implementation 'org.telegram:telegrambots:5.0.1'
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Using Jitpack from [here](https://jitpack.io/#rubenlagus/TelegramBots/5.0.1)
|
3. Using Jitpack from [here](https://jitpack.io/#rubenlagus/TelegramBots/5.0.1)
|
||||||
3. Download the jar(including all dependencies) from [here](https://mvnrepository.com/artifact/org.telegram/telegrambots/5.0.1)
|
4. Download the jar(including all dependencies) from [here](https://mvnrepository.com/artifact/org.telegram/telegrambots/5.0.1)
|
||||||
|
|
||||||
In order to use Long Polling mode, just create your own bot extending `org.telegram.telegrambots.bots.TelegramLongPollingBot`.
|
In order to use Long Polling mode, just create your own bot extending `org.telegram.telegrambots.bots.TelegramLongPollingBot`.
|
||||||
|
|
||||||
|
@ -16,8 +16,8 @@ First you need ot get the library and add it to your project. There are few poss
|
|||||||
```
|
```
|
||||||
* With **Gradle**:
|
* With **Gradle**:
|
||||||
|
|
||||||
```groovy
|
```gradle
|
||||||
compile group: 'org.telegram', name: 'telegrambots', version: '5.0.1'
|
implementation 'org.telegram:telegrambots:5.0.1'
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Don't like **Maven Central Repository**? It can also be taken from [Jitpack](https://jitpack.io/#rubenlagus/TelegramBots).
|
2. Don't like **Maven Central Repository**? It can also be taken from [Jitpack](https://jitpack.io/#rubenlagus/TelegramBots).
|
||||||
|
@ -13,8 +13,8 @@ As with any Java project, you will need to set your dependencies.
|
|||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
* **Gradle**
|
* **Gradle**
|
||||||
```groovy
|
```gradle
|
||||||
implementation group: 'org.telegram', name: 'telegrambots-abilities', version: '5.0.1'
|
implementation 'org.telegram:telegrambots-abilities:5.0.1'
|
||||||
```
|
```
|
||||||
* [JitPack](https://jitpack.io/#rubenlagus/TelegramBots)
|
* [JitPack](https://jitpack.io/#rubenlagus/TelegramBots)
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ Usage
|
|||||||
**Gradle**
|
**Gradle**
|
||||||
|
|
||||||
```gradle
|
```gradle
|
||||||
compile "org.telegram:telegrambots-abilities:5.0.1"
|
implementation 'org.telegram:telegrambots-abilities:5.0.1'
|
||||||
```
|
```
|
||||||
|
|
||||||
**JitPack** - [JitPack](https://jitpack.io/#rubenlagus/TelegramBots/v5.0.1)
|
**JitPack** - [JitPack](https://jitpack.io/#rubenlagus/TelegramBots/v5.0.1)
|
||||||
|
@ -19,6 +19,12 @@ Usage
|
|||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Gradle**
|
||||||
|
|
||||||
|
```gradle
|
||||||
|
implementation 'org.telegram:telegrambots-chat-session-bot:5.0.1'
|
||||||
|
```
|
||||||
|
|
||||||
Motivation
|
Motivation
|
||||||
----------
|
----------
|
||||||
Implementation of bot dialogs require saving some data about current state of conversation.
|
Implementation of bot dialogs require saving some data about current state of conversation.
|
||||||
|
@ -23,5 +23,5 @@ Just import add the library to your project with one of these options:
|
|||||||
2. Using Gradle:
|
2. Using Gradle:
|
||||||
|
|
||||||
```gradle
|
```gradle
|
||||||
compile "org.telegram:telegrambotsextensions:5.0.1"
|
implementation 'org.telegram:telegrambotsextensions:5.0.1'
|
||||||
```
|
```
|
@ -0,0 +1,74 @@
|
|||||||
|
package org.telegram.telegrambots.extensions.bots.commandbot;
|
||||||
|
|
||||||
|
import org.telegram.telegrambots.meta.api.objects.Message;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Varun Singh
|
||||||
|
* This class adds argument functionality to a given message that a user typed, that also counts as a command
|
||||||
|
*/
|
||||||
|
public class CommandMessage {
|
||||||
|
/**
|
||||||
|
* The message associated with the command
|
||||||
|
*/
|
||||||
|
private Message commandMessage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for CommandMessage
|
||||||
|
* @param msg The message that represents the command that the user typed
|
||||||
|
* Preconditions:
|
||||||
|
* msg.isCommand() is true
|
||||||
|
* msg.hasText() is true
|
||||||
|
* Postcondition:
|
||||||
|
* The developer has the ability to determine which command the message is executing
|
||||||
|
*/
|
||||||
|
public CommandMessage(Message msg) {
|
||||||
|
commandMessage = msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Message getCommandMessage() {
|
||||||
|
return commandMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the String representation of the message for ease
|
||||||
|
*/
|
||||||
|
public String getMessageText() {
|
||||||
|
return commandMessage.getText();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Separates the given text after the command into an ordered array of arguments
|
||||||
|
* @return each argument as a String item in an array
|
||||||
|
*/
|
||||||
|
public String[] getArgs() {
|
||||||
|
return getArgsStr().split(" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the text of the command WITHOUT the slash
|
||||||
|
* For example, if /language English
|
||||||
|
*/
|
||||||
|
public String getCommandText() {
|
||||||
|
return getCommandText(false).substring(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The text of the message from and including the '/' to the space,
|
||||||
|
* which assumes the end of the command name and start of the command arguments
|
||||||
|
*/
|
||||||
|
public String getCommandText(boolean includeHandle) {
|
||||||
|
if (includeHandle || commandMessage.isUserMessage()) {
|
||||||
|
return getMessageText().substring(0, getMessageText().indexOf(" "));
|
||||||
|
} else
|
||||||
|
return getMessageText().substring(0, getMessageText().indexOf("@"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Singles out the text of the message after the command
|
||||||
|
* @return all the arguments grouped in one string
|
||||||
|
*/
|
||||||
|
public String getArgsStr() {
|
||||||
|
return getMessageText().substring(getCommandText(true).length() + 1); // Skip space
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -25,7 +25,7 @@ Usage
|
|||||||
**Gradle**
|
**Gradle**
|
||||||
|
|
||||||
```gradle
|
```gradle
|
||||||
compile "org.telegram:telegrambots-spring-boot-starter:5.0.1"
|
implementation 'org.telegram:telegrambots-spring-boot-starter:5.0.1'
|
||||||
```
|
```
|
||||||
|
|
||||||
Motivation
|
Motivation
|
||||||
|
Loading…
x
Reference in New Issue
Block a user