Skip to content

Commit 4ba2191

Browse files
Zabuzardilluminator3
authored andcommitted
Doc improvements suggested by code review
* typos * removal of some obsolete private docs * changed section order in readme due to relevance
1 parent 1ab86b8 commit 4ba2191

5 files changed

Lines changed: 13 additions & 34 deletions

File tree

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111

1212
TJ-Bot is a Discord Bot used on the [Together Java](https://discord.gg/togetherjava) server. It is maintained by the community, anyone can contribute.
1313

14+
# Getting started
15+
16+
* [Documentation](https://github.com/Together-Java/TJ-Bot/wiki): as general entry point to the project
17+
* [Contributing](https://github.com/Together-Java/TJ-Bot/wiki/Contributing): if you want to improve the bot
18+
1419
# Download
1520

1621
## Using a build tool
@@ -29,7 +34,7 @@ dependencies {
2934
implementation 'com.github.Together-Java:TJ-Bot:<tag>'
3035
}
3136
```
32-
You can replace `<tag>` by either a commit hash (the first 10 characters) or by `-SNAPSHOT` to get the latest version
37+
You can replace `<tag>` by either a commit hash (the first 10 characters) or by `-SNAPSHOT` to get the latest version.
3338

3439
### Maven
3540

@@ -48,15 +53,10 @@ Then add the dependency:
4853
<version>[tag]</version>
4954
</dependency>
5055
```
51-
You can replace `[tag]` by either a commit hash (the first 10 characters) or by `-SNAPSHOT` to get the latest version
56+
You can replace `[tag]` by either a commit hash (the first 10 characters) or by `-SNAPSHOT` to get the latest version.
5257

5358
---
5459

5560
## Jar downloads
5661

57-
Jar downloads are available from the [release section](https://github.com/Together-Java/TJ-Bot/releases).
58-
59-
# Getting started
60-
61-
* [Documentation](https://github.com/Together-Java/TJ-Bot/wiki): as general entry point to the project
62-
* [Contributing](https://github.com/Together-Java/TJ-Bot/wiki/Contributing): if you want to improve the bot
62+
Jar downloads are available from the [release section](https://github.com/Together-Java/TJ-Bot/releases).

application/src/main/java/org/togetherjava/tjbot/Application.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ public enum Application {
2424
* @param args command line arguments - [the token of the bot, the path to the database]
2525
*/
2626
public static void main(final String[] args) {
27-
// Parse arguments
2827
if (args.length != 2) {
2928
throw new IllegalArgumentException("Expected two arguments but " + args.length
3029
+ " arguments were provided. The first argument must be the token of the bot"
@@ -33,7 +32,6 @@ public static void main(final String[] args) {
3332
String token = args[0];
3433
String databasePath = args[1];
3534

36-
// Start
3735
try {
3836
runBot(token, Path.of(databasePath));
3937
} catch (Exception t) {

application/src/main/java/org/togetherjava/tjbot/DatabaseListener.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,13 @@
3131
* </pre>
3232
*/
3333
public final class DatabaseListener extends ListenerAdapter {
34-
/**
35-
* Logger for this class.
36-
*/
34+
3735
private static final Logger logger = LoggerFactory.getLogger(DatabaseListener.class);
3836

39-
/**
40-
* The database instance used by this command.
41-
*/
4237
private final Database database;
4338

4439
/**
45-
* Creates a new command listener, using the given database
40+
* Creates a new command listener, using the given database.
4641
*
4742
* @param database the database to store the key-value pairs in
4843
*/
@@ -78,7 +73,6 @@ public void onMessageReceived(MessageReceivedEvent event) {
7873
*/
7974
private void handlePutMessage(String message, MessageReceivedEvent event) {
8075
// !dbput hello Hello World!
81-
// Parse message
8276
logger.info("#{}: Received '!dbput' command", event.getResponseNumber());
8377
String[] data = message.split(" ", 3);
8478
if (data.length != 3) {
@@ -90,7 +84,6 @@ private void handlePutMessage(String message, MessageReceivedEvent event) {
9084
String key = data[1];
9185
String value = data[2];
9286

93-
// Save the value in the database
9487
try {
9588
database.writeTransaction(ctx -> {
9689
StorageRecord storageRecord =
@@ -118,7 +111,6 @@ private void handlePutMessage(String message, MessageReceivedEvent event) {
118111
*/
119112
private void handleGetMessage(String message, MessageReceivedEvent event) {
120113
// !dbget hello
121-
// Parse message
122114
logger.info("#{}: Received '!dbget' command", event.getResponseNumber());
123115
String[] data = message.split(" ", 2);
124116
if (data.length != 2) {
@@ -129,7 +121,6 @@ private void handleGetMessage(String message, MessageReceivedEvent event) {
129121
}
130122
String key = data[1];
131123

132-
// Retrieve the value from the database
133124
try {
134125
Optional<StorageRecord> foundValue = database.read(context -> {
135126
return Optional.ofNullable(context.selectFrom(Storage.STORAGE)

application/src/main/java/org/togetherjava/tjbot/PingPongListener.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@
2121
* </pre>
2222
*/
2323
public final class PingPongListener extends ListenerAdapter {
24-
/**
25-
* Logger for this class
26-
*/
24+
2725
private static final Logger logger = LoggerFactory.getLogger(PingPongListener.class);
2826

2927
/**

application/src/main/java/org/togetherjava/tjbot/db/Database.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,9 @@
2525
*/
2626
public final class Database {
2727

28-
/**
29-
* The DSL context for this database.
30-
*/
3128
private final DSLContext dslContext;
3229
/**
33-
* Lock used to implement thread-safety across this class. Any database modifying method should
30+
* Lock used to implement thread-safety across this class. Any database modifying method must
3431
* use this lock.
3532
*/
3633
private final Lock writeLock = new ReentrantLock();
@@ -44,7 +41,7 @@ public final class Database {
4441
public Database(String jdbcUrl) throws SQLException {
4542
SQLiteConfig sqliteConfig = new SQLiteConfig();
4643
sqliteConfig.enforceForeignKeys(true);
47-
// In WAL mode only concurrent writes pose a problem, so we synchronize on those
44+
// In WAL mode only concurrent writes pose a problem, so we synchronize those
4845
sqliteConfig.setJournalMode(SQLiteConfig.JournalMode.WAL);
4946

5047
SQLiteDataSource dataSource = new SQLiteDataSource(sqliteConfig);
@@ -196,11 +193,6 @@ public void writeTransaction(
196193
});
197194
}
198195

199-
/**
200-
* Gets the DSL context for this database.
201-
*
202-
* @return the DSL context
203-
*/
204196
private DSLContext getDslContext() {
205197
return dslContext;
206198
}

0 commit comments

Comments
 (0)