Browse Source

fixed Command Parsing

master
mrbesen 2 months ago
parent
commit
e5495bc833
Signed by: MrBesen GPG Key ID: 596B2350DCD67504
  1. 20
      src/main/java/de/mrbesen/telegram/TelegramAPI.java

20
src/main/java/de/mrbesen/telegram/TelegramAPI.java

@ -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 {

Loading…
Cancel
Save