fixed Command Parsing

This commit is contained in:
mrbesen 2021-05-28 11:23:00 +02:00
rodzic 6bf1eb8387
commit e5495bc833
Podpisane przez: MrBesen
ID klucza GPG: 596B2350DCD67504
1 zmienionych plików z 1 dodań i 19 usunięć

Wyświetl plik

@ -563,7 +563,6 @@ public class TelegramAPI implements Runnable {
protected class TelegramAPIUpdate {
protected int update_id = 0;
private TMessage msg = null;
private boolean isCommand = false;
protected TelegramAPIUpdate(JSONObject json, TelegramAPI api) {
update_id = json.getInt("update_id");
@ -573,9 +572,8 @@ public class TelegramAPI implements Runnable {
String text = msg.getText();
if(text != null) {
if(text.matches("^\\/(\\w*)(@(\\w*))?")) { //is a command
if(text.matches("^\\/(\\w+)(@(\\w+))?(\\s.*)?")) { //is a command
text = text.substring(1);//remove '/'
isCommand = true;
if(text.contains("@")) {//check name
int at = text.indexOf('@');
int end = text.indexOf(' ', at+1);
@ -642,22 +640,6 @@ public class TelegramAPI implements Runnable {
}
}
}
protected int getUpdate_id() {
return update_id;
}
protected TMessage getMsg() {
return msg;
}
protected TUser getUser() {
return msg.getFrom();
}
protected boolean isCommand() {
return isCommand;
}
}
public enum JSONObjectType {