Skip to content

Commit 78d4a9b

Browse files
authored
Merge pull request #196 from SOBotics/hotfix/195-checkuser-threshold
Fix #195: Add dynamic threshold to checkuser command
2 parents 405c0ca + 50b4268 commit 78d4a9b

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
<groupId>de.felixsfd.stackoverflow</groupId>
2424
<artifactId>guttenberg</artifactId>
25-
<version>1.2.4</version>
25+
<version>1.2.5</version>
2626

2727
<dependencies>
2828
<dependency>

src/main/java/org/sobotics/guttenberg/commands/CheckInternet.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019 SOBotics (https://sobotics.org) and contributors in GitHub
2+
* Copyright (C) 2019 SOBotics (https://sobotics.org) and contributors on GitHub
33
*
44
* This program is free software: you can redistribute it and/or modify
55
* it under the terms of the GNU General Public License as published by
@@ -86,6 +86,14 @@ public void execute(Room room, RunnerService instance) {
8686
}
8787

8888
Properties prop = Guttenberg.getLoginProperties();
89+
Properties generalProp = Guttenberg.getGeneralProperties();
90+
double reportThreshold;
91+
try {
92+
reportThreshold = Double.parseDouble(generalProp.getProperty("checkuser_minimumScore", "0.80"));
93+
} catch (NumberFormatException e) {
94+
reportThreshold = 0.8;
95+
}
96+
8997
Post post = null;
9098

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

137145
for (PostMatch postMatch : matches) {
138-
if (postMatch.getTotalScore() > 0.75) {
146+
if (postMatch.getTotalScore() > reportThreshold) {
139147
outputDirectHit(room, postMatch);
140148
}
141149
}

src/main/java/org/sobotics/guttenberg/commands/CheckUser.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019 SOBotics (https://sobotics.org) and contributors in GitHub
2+
* Copyright (C) 2019 SOBotics (https://sobotics.org) and contributors on GitHub
33
*
44
* This program is free software: you can redistribute it and/or modify
55
* it under the terms of the GNU General Public License as published by
@@ -83,6 +83,14 @@ public void execute(Room room, RunnerService instance) {
8383
return;
8484
}
8585
Properties prop = Guttenberg.getLoginProperties();
86+
Properties generalProp = Guttenberg.getGeneralProperties();
87+
double reportThreshold;
88+
try {
89+
reportThreshold = Double.parseDouble(generalProp.getProperty("checkuser_minimumScore", "0.80"));
90+
} catch (NumberFormatException e) {
91+
reportThreshold = 0.8;
92+
}
93+
8694
LOGGER.info("Executing command on user id: " + userId);
8795

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

160168
for (PostMatch postMatch : matches) {
161-
if (postMatch.getTotalScore() > 0.75) {
169+
if (postMatch.getTotalScore() > reportThreshold) {
162170
outputDirectHit(room, postMatch);
163171
}
164172
}

0 commit comments

Comments
 (0)