fixed Command Parsing
This commit is contained in:
parent
6bf1eb8387
commit
e5495bc833
|
@ -563,7 +563,6 @@ public class TelegramAPI implements Runnable {
|
||||||
protected class TelegramAPIUpdate {
|
protected class TelegramAPIUpdate {
|
||||||
protected int update_id = 0;
|
protected int update_id = 0;
|
||||||
private TMessage msg = null;
|
private TMessage msg = null;
|
||||||
private boolean isCommand = false;
|
|
||||||
|
|
||||||
protected TelegramAPIUpdate(JSONObject json, TelegramAPI api) {
|
protected TelegramAPIUpdate(JSONObject json, TelegramAPI api) {
|
||||||
update_id = json.getInt("update_id");
|
update_id = json.getInt("update_id");
|
||||||
|
@ -573,9 +572,8 @@ public class TelegramAPI implements Runnable {
|
||||||
|
|
||||||
String text = msg.getText();
|
String text = msg.getText();
|
||||||
if(text != null) {
|
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 '/'
|
text = text.substring(1);//remove '/'
|
||||||
isCommand = true;
|
|
||||||
if(text.contains("@")) {//check name
|
if(text.contains("@")) {//check name
|
||||||
int at = text.indexOf('@');
|
int at = text.indexOf('@');
|
||||||
int end = text.indexOf(' ', at+1);
|
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 {
|
public enum JSONObjectType {
|
||||||
|
|
Loading…
Reference in New Issue