Skip to content

Commit 2727883

Browse files
committed
Cleanup and rebase.
Clarified a line. Ops, my mistake! A few minor tweaks. Cleaned up comments and allowed for prefix search in specific namespaces. Fixed null error. Missed a few edits.
1 parent 03eaece commit 2727883

22 files changed

Lines changed: 146 additions & 70 deletions

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,5 @@ JavaMediawikiBot uses several classes to store data. A few classes that store ge
7272
## Tips
7373

7474
Coding tips:
75-
* To propose an edit, use `proposeEdit(APIcommand command, String editSummary)`. This requires the GUI.
75+
* To queue a command for review, use `proposeEdit(APIcommand command)`. This requires the GUI.
7676
* To automatically push a command, use `APIcommand(APIcommand command)`.

src/main/java/WikiBot/APIcommands/APIcommand.java

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import WikiBot.Utils.ArrayUtils;
1111

1212
/**
13+
* @Description
1314
* This class is a base for making APIcommands.
1415
*
1516
* APIcommands are commands to a wiki's API.
@@ -61,7 +62,7 @@ protected void enforceMWVersion(String introduced) {
6162
protected void enforceMWVersion(String introduced, String removed) {
6263
VersionNumber myVersion = getMWVersion();
6364

64-
if ((myVersion.compareTo(introduced) < 0 || introduced == null) && (myVersion.compareTo(removed) > 0 || removed == null)) {
65+
if ((introduced == null || myVersion.compareTo(introduced) < 0) && (removed == null || myVersion.compareTo(removed) > 0)) {
6566
throw new UnsupportedError("The " + getLanguage() + " wiki does not support this API command. (command name: " + commandName + ")");
6667
}
6768
}
@@ -85,16 +86,6 @@ public void addParameter(String key, String value) {
8586
values.add(value);
8687
}
8788

88-
public boolean setParameter(String key, String value) {
89-
if (keys.contains(key)) {
90-
values.set(keys.indexOf(key), value);
91-
return true;
92-
} else {
93-
addParameter(key, value);
94-
return false;
95-
}
96-
}
97-
9889
public boolean removeParameter(String key) {
9990
if (keys.contains(key)) {
10091
values.remove(keys.indexOf(key));
@@ -159,8 +150,12 @@ public String getSummary() {
159150
temp += "\nPage name: " + pl.getTitle();
160151
temp += "\nEdit type: " + getValue("action");
161152
for (String key : keys) {
162-
if (!(key.equals("action") || key.equals("title") || key.contains("text") || key.equals("filename") || key.equals("from"))) {
163-
temp += "\n" + key.substring(0,1).toUpperCase() + key.substring(1) + ": " + getValue(key);
153+
if (!(key.equals("action") || key.equals("title") || key.contains("text") || key.equals("filename") || key.equals("from") || key.equals("format"))) {
154+
if (getValue(key) == null) {
155+
temp += "\n" + key.substring(0,1).toUpperCase() + key.substring(1);
156+
} else {
157+
temp += "\n" + key.substring(0,1).toUpperCase() + key.substring(1) + ": " + getValue(key);
158+
}
164159
}
165160
}
166161
if (doesKeyExist("text")) {

src/main/java/WikiBot/APIcommands/AppendText.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
import WikiBot.ContentRep.PageLocation;
44

55
/**
6+
* @Description
67
* This command appends text to a page.
78
*
8-
* Rights required:
9+
* @RequiredRights
910
* edit
1011
*
11-
* MW version required:
12+
* @MediawikiSupport
1213
* 1.13+
1314
*/
1415
public class AppendText extends APIcommand {

src/main/java/WikiBot/APIcommands/DeletePage.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
import WikiBot.ContentRep.PageLocation;
44

55
/**
6+
* @Description
67
* This command deletes a page.
78
*
8-
* Rights required:
9+
* @RequiredRights
910
* delete
1011
*
11-
* MW version required:
12+
* @MediawikiSupport
1213
* 1.12+
1314
*/
1415
public class DeletePage extends APIcommand {

src/main/java/WikiBot/APIcommands/EditPage.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
import WikiBot.ContentRep.PageLocation;
44

55
/**
6+
* @Description
67
* This command edits a page, or creates one if the
78
* page location does not exist.
89
*
9-
* Rights required:
10+
* @RequiredRights
1011
* edit
1112
*
12-
* MW version required:
13+
* @MediawikiSupport
1314
* 1.13+
1415
*/
1516
public class EditPage extends APIcommand {

src/main/java/WikiBot/APIcommands/EditSection.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
import WikiBot.ContentRep.PageLocation;
44

55
/**
6+
* @Description
67
* This command edits a page section.
78
*
8-
* Rights required:
9+
* @RequiredRights
910
* edit
1011
*
11-
* MW version required:
12+
* @MediawikiSupport
1213
* 1.13+
1314
*/
1415
public class EditSection extends APIcommand {

src/main/java/WikiBot/APIcommands/MovePage.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@
33
import WikiBot.ContentRep.PageLocation;
44

55
/**
6+
* @Description
67
* This command moves a page.
78
*
8-
* Rights required:
9+
* @RequiredRights
910
* move
1011
* movefile (To move files.)
1112
* move-subpages (To move subpages.)
1213
* suppressredirect (To move a page and leave no redirect behind.)
1314
*
14-
* MW version required:
15+
* @MediawikiSupport
1516
* 1.12+
1617
*/
1718
public class MovePage extends APIcommand {

src/main/java/WikiBot/APIcommands/Query/QueryAllPages.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
package WikiBot.APIcommands.Query;
22

33
/**
4+
* @Description
45
* This command gets a list of all pages on the wiki.
56
*
6-
* Rights required:
7+
* @RequiredRights
78
* none
89
*
9-
* MW version required:
10+
* @MediawikiSupport
1011
* all
1112
*/
1213
public class QueryAllPages extends QueryList {

src/main/java/WikiBot/APIcommands/Query/QueryBackLinks.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
import WikiBot.ContentRep.PageLocation;
44

55
/**
6+
* @Description
67
* This command gets all the pages that link to this page.
78
*
8-
* Rights required:
9+
* @RequiredRights
910
* none
1011
*
11-
* MW version required:
12+
* @MediawikiSupport
1213
* 1.9+
1314
*/
1415
public class QueryBackLinks extends QueryList {

src/main/java/WikiBot/APIcommands/Query/QueryCategoryMembers.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
package WikiBot.APIcommands.Query;
22

33
/**
4+
* @Description
45
* This command gets the members of a category.
56
*
6-
* Rights required:
7+
* @RequiredRights
78
* none
89
*
9-
* MW version required:
10+
* @MediawikiSupport
1011
* 1.11+
1112
*/
1213
public class QueryCategoryMembers extends QueryList {

0 commit comments

Comments
 (0)