Skip to content

Commit 759871c

Browse files
committed
Added the ability to get the current bot name in the given language as the class BotName using the method getMyName
1 parent 9cd21c5 commit 759871c

File tree

3 files changed

+80
-0
lines changed

3 files changed

+80
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package com.pengrad.telegrambot.model;
2+
3+
import java.io.Serializable;
4+
import java.util.Objects;
5+
6+
public class BotName implements Serializable {
7+
private final static long serialVersionUID = 0L;
8+
9+
private String name;
10+
11+
BotName() {
12+
}
13+
14+
public String name() {
15+
return name;
16+
}
17+
18+
@Override
19+
public boolean equals(Object o) {
20+
if (this == o) return true;
21+
if (o == null || getClass() != o.getClass()) return false;
22+
23+
BotName that = (BotName) o;
24+
25+
return Objects.equals(name, that.name);
26+
}
27+
28+
@Override
29+
public int hashCode() {
30+
return name != null ? name.hashCode() : 0;
31+
}
32+
33+
@Override
34+
public String toString() {
35+
return "BotName{" +
36+
", name='" + name + '\'' +
37+
'}';
38+
}
39+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.pengrad.telegrambot.request;
2+
3+
import com.pengrad.telegrambot.response.GetMyNameResponse;
4+
5+
public class GetMyName extends BaseRequest<GetMyName, GetMyNameResponse> {
6+
7+
public GetMyName() {
8+
super(GetMyNameResponse.class);
9+
}
10+
11+
/**
12+
*
13+
* @param languageCode A two-letter ISO 639-1 language code or an empty string
14+
* @return
15+
*/
16+
public GetMyName languageCode(String languageCode) {
17+
add("language_code", languageCode);
18+
return this;
19+
}
20+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.pengrad.telegrambot.response;
2+
3+
import java.util.Objects;
4+
5+
import com.pengrad.telegrambot.model.BotName;
6+
7+
public class GetMyNameResponse extends BaseResponse {
8+
9+
private BotName result;
10+
11+
public BotName botName() {
12+
return result;
13+
}
14+
15+
@Override
16+
public String toString() {
17+
return "GetMyNameResponse{" +
18+
"result=" + Objects.toString(result) +
19+
'}';
20+
}
21+
}

0 commit comments

Comments
 (0)