Skip to content

Commit 357b088

Browse files
committed
Rename telegram configuration property : bot_id -> bot_api_token
1 parent 8bbf6a4 commit 357b088

File tree

6 files changed

+16
-19
lines changed

6 files changed

+16
-19
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ It's channel configuration file.
3737
[channel_name]:
3838
# Telegram
3939
- type: "telegram"
40-
bot_id: ""
40+
bot_api_token: ""
4141
chat_id: ""
4242
display_tags: true
4343
merge_duplicate_message: true

src/main/java/org/code13k/perri/business/message/sender/TelegramSender.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
package org.code13k.perri.business.message.sender;
22

33
import io.vertx.ext.web.client.HttpResponse;
4-
import org.apache.commons.lang3.StringUtils;
5-
import org.code13k.perri.model.Message;
64
import org.code13k.perri.model.MessageOperation;
75
import org.code13k.perri.model.config.channel.TelegramInfo;
86
import org.slf4j.Logger;
97
import org.slf4j.LoggerFactory;
108

119
import java.net.URLEncoder;
12-
import java.util.ArrayList;
1310
import java.util.function.Consumer;
1411

1512
public class TelegramSender extends BasicSender {
@@ -78,10 +75,10 @@ private String makeTelegramUri(MessageOperation messageOperation) {
7875
String urlEncodedText = URLEncoder.encode(text, "UTF-8");
7976

8077
// Make URL
81-
String bot_id = telegramInfo.getBotId();
82-
String chat_id = telegramInfo.getChatId();
78+
String botApiToken = telegramInfo.getBotApiToken();
79+
String chatId = telegramInfo.getChatId();
8380
String uriFormat = "https://api.telegram.org/bot%s/sendMessage?chat_id=%s&text=%s";
84-
String uri = String.format(uriFormat, bot_id, chat_id, urlEncodedText);
81+
String uri = String.format(uriFormat, botApiToken, chatId, urlEncodedText);
8582

8683
// End
8784
mLogger.debug("TelegramSender URI : " + uri);

src/main/java/org/code13k/perri/config/ChannelConfig.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,20 +110,20 @@ protected boolean loadConfig(final String content, final String filePath) {
110110

111111
// Telegram
112112
if (type.equalsIgnoreCase(ChannelType.TELEGRAM)) {
113-
String botId = (String) valueItemObject.getOrDefault("bot_id", "");
113+
String botApiToken = (String) valueItemObject.getOrDefault("bot_api_token", "");
114114
String chatId = (String) valueItemObject.getOrDefault("chat_id", "");
115115

116116
// Set Telegram
117117
TelegramInfo telegramInfo = new TelegramInfo();
118118
telegramInfo.setType(ChannelType.TELEGRAM);
119-
telegramInfo.setBotId(botId);
119+
telegramInfo.setBotApiToken(botApiToken);
120120
telegramInfo.setChatId(chatId);
121121
telegramInfo.setDisplayTags(displayTags);
122122
telegramInfo.setMergeDuplicateMessage(mergeDuplicateMessage);
123123

124124
// Check validation
125-
if (StringUtils.isEmpty(telegramInfo.getBotId()) == true) {
126-
mLogger.error("Invalid telegram channel (bot_id is invalid)");
125+
if (StringUtils.isEmpty(telegramInfo.getBotApiToken()) == true) {
126+
mLogger.error("Invalid telegram channel (bot_api_token is invalid)");
127127
} else if (StringUtils.isEmpty(telegramInfo.getChatId()) == true) {
128128
mLogger.error("Invalid telegram channel (chat_id is invalid)");
129129
} else {

src/main/java/org/code13k/perri/model/config/channel/TelegramInfo.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
package org.code13k.perri.model.config.channel;
22

33
public class TelegramInfo extends ChannelInfo {
4-
private String botId;
4+
private String botApiToken;
55
private String chatId;
66

77
@Override
88
public boolean equals(Object object) {
99
if (super.equals(object) == true) {
1010
if (object instanceof TelegramInfo) {
11-
if (this.getBotId().equals(((TelegramInfo) object).getBotId())) {
11+
if (this.getBotApiToken().equals(((TelegramInfo) object).getBotApiToken())) {
1212
if (this.getChatId().equals(((TelegramInfo) object).getChatId())) {
1313
return true;
1414
}
@@ -18,12 +18,12 @@ public boolean equals(Object object) {
1818
return false;
1919
}
2020

21-
public String getBotId() {
22-
return botId;
21+
public String getBotApiToken() {
22+
return botApiToken;
2323
}
2424

25-
public void setBotId(String botId) {
26-
this.botId = botId;
25+
public void setBotApiToken(String botApiToken) {
26+
this.botApiToken = botApiToken;
2727
}
2828

2929
public String getChatId() {

src/main/resources/config/default_channel_config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
perri_default_channel:
22
- type: "telegram"
3-
bot_id: ""
3+
bot_api_token: ""
44
chat_id: ""
55
display_tags: true
66
merge_duplicate_message: true

src/main/resources/config/default_logback.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
-->
5353

5454
<!-- Mode -->
55-
<logger name="org.code13k.perri" level="TRACE"/>
55+
<logger name="org.code13k.perri" level="INFO"/>
5656
<root level="WARN">
5757
<appender-ref ref="FILE"/>
5858
</root>

0 commit comments

Comments
 (0)