Skip to content

Commit

Permalink
Merge pull request #196 from SOBotics/hotfix/195-checkuser-threshold
Browse files Browse the repository at this point in the history
Fix #195: Add dynamic threshold to checkuser command
  • Loading branch information
FelixSFD authored Jul 12, 2019
2 parents 405c0ca + 50b4268 commit 78d4a9b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<groupId>de.felixsfd.stackoverflow</groupId>
<artifactId>guttenberg</artifactId>
<version>1.2.4</version>
<version>1.2.5</version>

<dependencies>
<dependency>
Expand Down
12 changes: 10 additions & 2 deletions src/main/java/org/sobotics/guttenberg/commands/CheckInternet.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 SOBotics (https://sobotics.org) and contributors in GitHub
* Copyright (C) 2019 SOBotics (https://sobotics.org) and contributors on GitHub
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -86,6 +86,14 @@ public void execute(Room room, RunnerService instance) {
}

Properties prop = Guttenberg.getLoginProperties();
Properties generalProp = Guttenberg.getGeneralProperties();
double reportThreshold;
try {
reportThreshold = Double.parseDouble(generalProp.getProperty("checkuser_minimumScore", "0.80"));
} catch (NumberFormatException e) {
reportThreshold = 0.8;
}

Post post = null;

LOGGER.info("Executing command on user id: " + postId);
Expand Down Expand Up @@ -135,7 +143,7 @@ public void execute(Room room, RunnerService instance) {
sendChatMessage(room, message);

for (PostMatch postMatch : matches) {
if (postMatch.getTotalScore() > 0.75) {
if (postMatch.getTotalScore() > reportThreshold) {
outputDirectHit(room, postMatch);
}
}
Expand Down
12 changes: 10 additions & 2 deletions src/main/java/org/sobotics/guttenberg/commands/CheckUser.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 SOBotics (https://sobotics.org) and contributors in GitHub
* Copyright (C) 2019 SOBotics (https://sobotics.org) and contributors on GitHub
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -83,6 +83,14 @@ public void execute(Room room, RunnerService instance) {
return;
}
Properties prop = Guttenberg.getLoginProperties();
Properties generalProp = Guttenberg.getGeneralProperties();
double reportThreshold;
try {
reportThreshold = Double.parseDouble(generalProp.getProperty("checkuser_minimumScore", "0.80"));
} catch (NumberFormatException e) {
reportThreshold = 0.8;
}

LOGGER.info("Executing command on user id: " + userId);

boolean log = cmd.contains("-log");
Expand Down Expand Up @@ -158,7 +166,7 @@ public void execute(Room room, RunnerService instance) {
}

for (PostMatch postMatch : matches) {
if (postMatch.getTotalScore() > 0.75) {
if (postMatch.getTotalScore() > reportThreshold) {
outputDirectHit(room, postMatch);
}
}
Expand Down

0 comments on commit 78d4a9b

Please sign in to comment.