Telegram Notification Script FIX for cmk2.0

With some check strings from snmp devices (checkpoint FW) we had some problems with temperature output, and got this error:

2021-12-01 12:33:38      executing /omd/sites/site/local/share/check_mk/notifications/telegram.py
2021-12-01 12:33:38      Output: Traceback (most recent call last):
2021-12-01 12:33:38      Output:   File "/omd/sites/site/local/share/check_mk/notifications/telegram.py", line 119, in <module>
2021-12-01 12:33:38      Output:     main()
2021-12-01 12:33:38      Output:   File "/omd/sites/site/local/share/check_mk/notifications/telegram.py", line 117, in main
2021-12-01 12:33:38      Output:     send_telegram_message(telegram_bot_token, telegram_chatid, text)
2021-12-01 12:33:38      Output:   File "/omd/sites/site/local/share/check_mk/notifications/telegram.py", line 103, in send_telegram_message
2021-12-01 12:33:38      Output:     data = urllib.parse.urlencode({'chat_id':chat_id, 'text':text, 'parse_mode':'Markdown'}).encode("utf-8")
2021-12-01 12:33:38      Output:   File "/usr/lib/python3.6/urllib/parse.py", line 913, in urlencode
2021-12-01 12:33:38      Output:     v = quote_via(str(v), safe, encoding, errors)
2021-12-01 12:33:38      Output:   File "/usr/lib/python3.6/urllib/parse.py", line 841, in quote_plus
2021-12-01 12:33:38      Output:     string = quote(string, safe + space, encoding, errors)
2021-12-01 12:33:38      Output:   File "/usr/lib/python3.6/urllib/parse.py", line 819, in quote
2021-12-01 12:33:38      Output:     string = string.encode(encoding, errors)
2021-12-01 12:33:38      Output: UnicodeEncodeError: 'utf-8' codec can't encode characters in position 232-233: surrogates not allowed
2021-12-01 12:33:38      Plugin exited with code 1
2021-12-01 12:33:38      Output:   File "/usr/lib/python2.7/os.py", line 473, in __setitem__
2021-12-01 12:33:38      Output:     putenv(key, item)
2021-12-01 12:33:38      Output: UnicodeEncodeError: 'ascii' codec can't encode character u'\xb0' in position 12: ordinal not in range(128)

I fixed this with errors=“ignore” in the encode call in function send_telegram_message:

    data = urllib.parse.urlencode({'chat_id':chat_id, 'text':text, 'parse_mode':'Markdown'}).encode("utf-8", errors="ignore")

The Problem is this character: °
OK - 49.0 °C