openhab / openhab-addons

Add-ons for openHAB
https://www.openhab.org/
Eclipse Public License 2.0
1.88k stars 3.58k forks source link

[telegram] support for Markdownv2 #13723

Open mitch-geht-ab opened 1 year ago

mitch-geht-ab commented 1 year ago

Hello,

please add support for MarkdownV2. Telegram Binding does not allow "MarkdownV2" as parseMode.

Error

2022-11-15 09:23:52.321 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'telegram:telegramBot:homebot' changed from ONLINE to UNINITIALIZED
2022-11-15 09:23:52.337 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'telegram:telegramBot:homebot' changed from ONLINE to UNINITIALIZED (HANDLER_CONFIGURATION_PENDING): {parseMode=The value MarkdownV2 does not match allowed parameter options. Allowed options are: [ParameterOption [value="", label="No Formatting"], ParameterOption [value="HTML", label="HTML"], ParameterOption [value="Markdown", label="Markdown"]]}

Ref. to Telegram documentation: https://core.telegram.org/bots/api#markdownv2-style

Your Environment

$ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

$ openhab-cli info

Version:     3.3.0 (Build)

User:        openhab (Active Process 419)
User Groups: openhab tty dialout audio

Directories: Folder Name      | Path                        | User:Group
             -----------      | ----                        | ----------
             OPENHAB_HOME     | /usr/share/openhab          | openhab:openhab
             OPENHAB_RUNTIME  | /usr/share/openhab/runtime  | openhab:openhab
             OPENHAB_USERDATA | /var/lib/openhab            | openhab:openhab
             OPENHAB_CONF     | /etc/openhab                | openhab:openhab
             OPENHAB_LOGDIR   | /var/log/openhab            | openhab:openhab
ZzetT commented 1 year ago

Hi @mitch-geht-ab,

by looking at the code, this shouldn't be too difficult to add. The telegram binding internally uses the java-telegram-bot-api which supports MarkdownV2 already. So, in the best case we just have to update the thing-types.xml (with the documentation) to add that value to the parseMode.