Skip to content

Commit 59b35cc

Browse files
authored
Merge pull request #3 from SOBotics/feature/2-send-version
#2: + added bot version
2 parents c31d4d7 + a852087 commit 59b35cc

3 files changed

Lines changed: 22 additions & 4 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ To implement this library in your Java bot, you need to add the Maven-dependency
1212
Right after launching your bot, you should initialize `PingService`. This should happen before your bot fetches anything from the Stack Exchange API.
1313

1414
```
15-
PingService redunda = new PingService("your api-key");
15+
PingService redunda = new PingService("your api-key", "bot version");
1616
redunda.start();
1717
```
1818

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<modelVersion>4.0.0</modelVersion>
33
<groupId>org.sobotics</groupId>
44
<artifactId>redunda-lib</artifactId>
5-
<version>0.1.1-SNAPSHOT</version>
5+
<version>0.2.0-SNAPSHOT</version>
66
<name>Redunda Library</name>
77
<description>Communicates with SOBotic's Redunda</description>
88

src/main/java/org/sobotics/PingService.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ public class PingService {
4242
* */
4343
public static AtomicBoolean standby = new AtomicBoolean(true);
4444

45+
/**
46+
* The version of the bot as string
47+
* */
48+
private String version = null;
49+
4550
/**
4651
* Initialize with default values
4752
* */
@@ -55,10 +60,19 @@ public PingService(String key) {
5560
}
5661

5762
/**
58-
* Initializes the object with a `pingInterval` in seconds and the api key
63+
* Initializes the object with the api key and bot-version
5964
* */
60-
public PingService(String key, int pingInterval) {
65+
public PingService(String key, String botVersion) {
6166
this.apiKey = key;
67+
this.version = botVersion;
68+
}
69+
70+
/**
71+
* Initializes the object with a `pingInterval` in seconds, the bot's verision and the api key
72+
* */
73+
public PingService(String key, String botVersion, int pingInterval) {
74+
this.apiKey = key;
75+
this.version = botVersion;
6276
this.interval = pingInterval;
6377
}
6478

@@ -119,6 +133,10 @@ private void execute() throws Throwable {
119133
con.setRequestProperty("User-Agent", "Redunda Library");
120134

121135
String parameters = "key="+this.apiKey;
136+
137+
//add version parameter if available
138+
if (this.version != null)
139+
parameters = parameters+"&version="+this.version;
122140

123141
// Send post request
124142
con.setDoOutput(true);

0 commit comments

Comments
 (0)