🐛 Fixed a bug in the ResponderContext

This commit is contained in:
mathias 2021-10-04 16:35:10 +02:00
parent 0c4beeacd6
commit 0f105cc485
No known key found for this signature in database
GPG Key ID: 8950DF62139C852A

View File

@ -80,9 +80,14 @@ public class ResponderContext extends SimpleHttpHandler {
if (executeUnlockAction(event)) return; if (executeUnlockAction(event)) return;
try {
if (message.startsWith(responder.getPrefix()) if (message.startsWith(responder.getPrefix())
&& runCommand(appPackageName, messengerPackageName, sender, message.substring(responder.getPrefix().length()), isGroup, && runCommand(appPackageName, messengerPackageName, sender, message.substring(responder.getPrefix().length()), isGroup,
groupParticipant, ruleId, controller)) return; groupParticipant, ruleId, controller)) return;
} catch (Exception e) {
e.printStackTrace();
}
triggerEvent(event); triggerEvent(event);
@ -226,7 +231,7 @@ public class ResponderContext extends SimpleHttpHandler {
return null; return null;
} }
for (int i = 0; i < command.getUsageElements().size(); i++) { for (int i = 0; i < providedUsage.size(); i++) {
arguments.put(command.getUsageElements().get(i).getName(), providedUsage.get(i)); arguments.put(command.getUsageElements().get(i).getName(), providedUsage.get(i));
} }
} }
@ -317,8 +322,14 @@ public class ResponderContext extends SimpleHttpHandler {
try { try {
if (usageElement.getType() == UsageType.INTEGER) { if (usageElement.getType() == UsageType.INTEGER) {
createdUsage.set(i, Integer.parseInt(object.toString())); createdUsage.set(i, Integer.parseInt(object.toString()));
} else if (usageElement.getType() == UsageType.BOOLEAN && object.equals("true") || object.equals("false")) { } else if (usageElement.getType() == UsageType.BOOLEAN) {
throw new Exception("Could not parse the integer value"); object = object.equals("yes") ? "true" : object;
object = object.equals("no") ? "false" : object;
if (object.equals("true") || object.equals("false")) {
createdUsage.set(i, Boolean.parseBoolean(object.toString()));
} else
throw new Exception("Could not parse the boolean value");
} }
} catch (Exception e) { } catch (Exception e) {
throw new UsageException(USAGE_TYPE_MISMATCH, String.format("The usage element %s must have the type %s", usageElement.getName(), throw new UsageException(USAGE_TYPE_MISMATCH, String.format("The usage element %s must have the type %s", usageElement.getName(),