Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bundles/org.openhab.binding.telegram/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ In order to send a message, an action must be used instead.
| `proxyHost` | None | No | Proxy host for telegram binding. |
| `proxyPort` | None | No | Proxy port for telegram binding. |
| `proxyType` | SOCKS5 | No | Type of proxy server for telegram binding (SOCKS5 or HTTP). |
| `longPollingTime` | 25 | No | Timespan in seconds for long polling the telegram API. |
| `longPollingTime` | 25 | No | Timespan in seconds for long polling the telegram API. (0 to disable) |

By default chat ids are bi-directionally, i.e. they can send and receive messages.
They can be prefixed with an access modifier:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,11 @@ public void initialize() {
updateStatus(ThingStatus.UNKNOWN);
delayThingOnlineStatus();
TelegramBot localBot = bot = new TelegramBot.Builder(botToken).okHttpClient(botLibClient).build();
localBot.setUpdatesListener(this::handleUpdates, this::handleExceptions,
getGetUpdatesRequest(config.getLongPollingTime()));
int longPollingTime = config.getLongPollingTime();
if (longPollingTime > 0) {
localBot.setUpdatesListener(this::handleUpdates, this::handleExceptions,
getGetUpdatesRequest(longPollingTime));
}
}

private void createReceiverChatIdsAndAuthorizedSenderChatIds(List<String> chatIds) {
Expand Down Expand Up @@ -470,7 +473,10 @@ public void dispose() {
OkHttpClient localClient = botLibClient;
TelegramBot localBot = bot;
if (localClient != null && localBot != null) {
localBot.removeGetUpdatesListener();
TelegramConfiguration config = this.getConfig().as(TelegramConfiguration.class);
if (config.getLongPollingTime() > 0) {
localBot.removeGetUpdatesListener();
}
localClient.dispatcher().executorService().shutdown();
localClient.connectionPool().evictAll();
logger.debug("Telegram client closed");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ thing-type.config.telegram.telegramBot.botToken.description = Enter the bot toke
thing-type.config.telegram.telegramBot.chatIds.label = Chat Id(s)
thing-type.config.telegram.telegramBot.chatIds.description = One or more chat id(s). Access modifiers ("<" for inbound only, ">" for outbound only) can be used as prefix (optional).
thing-type.config.telegram.telegramBot.longPollingTime.label = Long Polling Time
thing-type.config.telegram.telegramBot.longPollingTime.description = Enter the long polling time in seconds.
thing-type.config.telegram.telegramBot.longPollingTime.description = Enter the long polling time in seconds. Set 0 to disable.
thing-type.config.telegram.telegramBot.parseMode.label = Parse Mode
thing-type.config.telegram.telegramBot.parseMode.description = Support for formatted messages, values: Markdown or HTML. Default: no formatting is used.
thing-type.config.telegram.telegramBot.parseMode.option. = No Formatting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
</parameter>
<parameter name="longPollingTime" type="integer" min="0" max="50" unit="s">
<label>Long Polling Time</label>
<description>Enter the long polling time in seconds.</description>
<description>Enter the long polling time in seconds. Set 0 to disable.</description>
<default>25</default>
</parameter>
</config-description>
Expand Down