From e5495bc8338ced710915f82ad8ce05aa211e528e Mon Sep 17 00:00:00 2001 From: mrbesen Date: Fri, 28 May 2021 11:23:00 +0200 Subject: [PATCH] fixed Command Parsing --- .../java/de/mrbesen/telegram/TelegramAPI.java | 20 +------------------ 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/src/main/java/de/mrbesen/telegram/TelegramAPI.java b/src/main/java/de/mrbesen/telegram/TelegramAPI.java index b891d8d..6837406 100644 --- a/src/main/java/de/mrbesen/telegram/TelegramAPI.java +++ b/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 {