Commit graph

158 commits

Author SHA1 Message Date
Erik Montnemery
8edac51401
Remove explicit templating of telegram_bot service data (#128906) 2024-10-21 20:20:29 +02:00
Jan-Philipp Benecke
39e720caed
Use debug/warning instead of info log level in components [t] (#126147) 2024-09-18 12:39:50 +02:00
Martin Hjelmare
687cd32142
Handle telegram polling errors (#124327) 2024-09-02 09:23:24 -10:00
Martin Hjelmare
ae1f53775f
Bump python-telegram-bot to 21.5 (#125025) 2024-09-01 17:51:31 +02:00
Richard Kroegel
fa21613951
Fix telegram_bot blocking on load_default_certs (#125014)
* Fix telegram_bot blocking on load_default_certs

* Use sync variant of create_issue
2024-09-01 17:13:04 +02:00
Erik Montnemery
38ef216894
Update icons.json to new service schema part 4 (#124771) 2024-08-28 13:48:13 +02:00
Erik Montnemery
342ba1b599
Remove unnecessary assignment of Template.hass from telegram_bot (#123693) 2024-08-12 16:06:19 +02:00
Luca Angemi
1973c604b6
Fix telegram bot thread_id key error (#120613) 2024-06-26 23:45:47 +02:00
r-xyz
0487b38ed3
Add support for sending telegram messages to topics (#112715)
* Add support for sending telegram messages to topics
    Based on original PR #104059 by [jgresty](https://github.com/jgresty).
    Did not manage to merge conflicts, so I remade the changes from scratch, including suggestions from previous PR reviews.

    Topics were added to telegram groups in November 2022, and to the
    telegram-bot library in version 20.0. They are a purely additive change
    that is exposed by a single parameter `message_thread_id`. Not passing
    this parameter will not change the behaviour from current.

    This same parameter is used to send messages to threads and messages to
    topics inside groups.

    https://telegram.org/blog/topics-in-groups-collectible-usernames/it?setln=en#topics-in-groups

    Fixes #81888
    Fixes #91750

* telegram_bot: add tests for threads feature.

* telegram_bot: fixed tests for threads.

* telegram_bot: fixed wrong line.

* Update test_telegram_bot.py

---------

Co-authored-by: J. Nick Koston <nick@koston.org>
Co-authored-by: Erik Montnemery <erik@montnemery.com>
2024-06-05 17:41:40 +02:00
Luca Angemi
d67ed42edc
Fix telegram bot send_document (#118616) 2024-06-02 01:32:24 -05:00
Luca Angemi
5ed9d58a7b
Fix telegram doing blocking I/O in the event loop (#118531) 2024-05-31 07:45:52 -05:00
Denis Shulyaka
9add251b0a
Add context to telegram_bot events (#109920)
* Add context for received messages events

* Add context for sent messages events

* ruff

* ruff

* ruff

* Removed user_id mapping

* Add tests
2024-05-14 15:48:59 +02:00
Sid
2cc916db6d
Replace pylint broad-except with Ruff BLE001 (#116250) 2024-05-07 14:00:27 +02:00
Jim
cc9eab4c78
Allow plain text messages in telegram_bot (#110051)
* Add new plain_text parser

Passing None in the parse_mode kwargs on the various bot methods actually means that no parser is used.

* Add new plain text parser option to services.yaml

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2024-04-23 19:32:09 +02:00
Sid
0d66d298ec
Enable Ruff RET504 (#114528)
* Enable Ruff RET504

* fix test

* Use noqa instead of cast

* fix sonos RET504

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2024-04-06 11:07:37 +02:00
Sid
6587ee20db
Enable Ruff TRY300 (#114437)
* Enable Ruff TRY300

* Update validation.py

* Address review comments
2024-03-30 10:37:59 +01:00
Jim
6ceeb1e41f
Telegram bot proxy params deprecation (#112778)
* Add strings for issues to raise in telegram integration startup

* Allow proxy_params to be passed empty

Allows migration away from proxy_params whilst retaining a configured proxy.

* Raise issues for removing proxy_params config option

* Add types to initialize_bot function

* Add PR link for learn more URL

Update issue message to leave a comment on the PR instead

* Apply suggestions from code review

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* hass should always be first argument

* Update issues strings to give domain and better direction.

* Update breaks_in_ha_version to something saner

* Apply strings.json suggestions from code review

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2024-03-25 21:09:34 +01:00
Joost Lekkerkerker
13a2db0348
Add service icons to Telegram bot (#113357) 2024-03-14 13:12:03 +01:00
J. Nick Koston
c122e32d20
Fix telegram_bot doing blocking I/O in the event loop to import platforms (#113383) 2024-03-14 10:45:11 +01:00
Marc Mueller
2c06d4fcb9
Add empty line after module docstring (2) [components] (#112736) 2024-03-08 19:15:59 +01:00
Marc Mueller
062cc4bfce
Add empty line after module docstring [t-v] (#112705) 2024-03-08 10:35:23 -05:00
Jim
d2effd8693
Bump python-telegram-bot package to 21.0.1 (#110297)
* Bump python-telegram-bot package version to the latest.

* PySocks is no longer required as python-telegram-bot doesn't use urllib3 anymore.

* Fix moved ParseMode import

* Update filters import to new structure.

* Refactor removed Request objects to HTTPXRequest objects.

* Update to support asyncc functions

* Update timeout to new kwarg

connect_timeout is the most obvious option based on current param description, but this may need changing.

* Compatibility typo.

* Make methods async and use Bot client async natively

* Type needs to be Optional

That's what the source types are from the library
Also handle new possibility of None value

* Add socks support version of the library

* Refactor load_data function

Update to be async friendly
Refactor to use httpx instead of requests.

* Refactor Dispatcher references to Application

This is the newer model of the same class.

* Make more stuff async-friendly.

* Update tests to refactor Dispatcher usage out.

* Remove import and reference directly

* Refactor typing method

* Use async_fire now we have async support

* Fix some over complicate inheritance.

* Add the polling test telegram_text event fired back in.

* Add extra context to comment

* Handler should also be async

* Use underscores instead of camelCase

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Renamed kwarg.

* Refactor current timeout param to be read timeout

Reading the old version of the library code I believe this matches the existing functionality best

* Combine unload methods into one listener

* Fix test by stopping HA as part of fixture

* Add new fixture to mock stop_polling call

Use this in all polling tests.

* No longer need to check if application is running

It was to stop a test failing.

* Make sure the updater is started in tests

Mock external call methods
Remove stop_polling mock.

* Use cleaner references to patched methods

* Improve test by letting the library create the Update object

* Mock component tear down methods to be async

* Bump mypy cache version

* Update dependency to install from git

Allows use as a custom component in 2024.3
Allows us to track mypy issue resolution.

* Update manifest and requirements for new python-telegram-bot release.

* Remove pytest filterwarnings entry for old version of python-telegram-bot library.

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2024-03-08 08:56:26 +01:00
Marc Mueller
bf8bd5ff21
Use dict.get instead of inline if (#109693) 2024-02-05 13:56:10 +01:00
Tobias Perschon
7424c296b7
Add missing services and strings entries for reply_to_message_id (#105072) 2023-12-06 11:01:05 +01:00
Matthias Dunda
0f3cb9b1b6
Add telegram message timestamp to event data (#87493) 2023-12-04 10:53:59 +01:00
Kalpit
b35afab5ef
Add reply_to_message_id to all telegram_bot message types (#103566) 2023-11-14 16:41:13 +01:00
YuriiMaiboroda
ca7355b2f3
Using the MarkdownV2 parser with the Telegram bot (#101139) 2023-10-06 12:26:20 +02:00
Zehuan Li
41cb8526d1
Add secret_token support to telegram_bot component (#100869)
* Support secret_token for setWebHook api

* Revert configuration YAML changes; generate and store secret token instead

* Reformat codes

* Revert storage of secret token; use ephemeral secret token instead

* Reformat

* Update homeassistant/components/telegram_bot/webhooks.py

* Fix when header is not present

* Check for non-empty token

* Fix tests to support secret token

* Add tests for invalid secret token

* Minor: remove comment

* Revert back to 401

* ... and for tests

* Change patching method for the generation of secret tokens

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2023-10-02 11:44:15 +02:00
Jan Bouwhuis
50da5c3fae
Fix typo in telegram_bot translations (#97793) 2023-08-04 21:35:35 +02:00
Paulus Schoutsen
7859be6481
Add deduplicate translations script (#96384)
* Add deduplicate script

* Fix forecast_solar incorrect key with space

* Fix utf-8

* Do not create references to other arbitrary other integrations

* Add commented code to only allow applying to referencing integrations

* Tweak

* Bug fix

* Add command line arg for limit reference

* never suggest to update common keys

* Output of script

* Apply suggestions from code review

Co-authored-by: Michael <35783820+mib1185@users.noreply.github.com>

---------

Co-authored-by: Michael <35783820+mib1185@users.noreply.github.com>
2023-07-13 11:52:50 -04:00
Franck Nijhof
4edec69637
Migrate integration services (T-V) to support translations (#96379) 2023-07-12 07:37:13 +02:00
Maxim Oei
36b0fc17df
Update Telegram bot to support URLs in inlineKeyboard (#70445)
* Update Telegram bot to support URLs in inlineKeyboard

Update creation of InlineKeyboardButton to support url case, on top of callbacks

* linting

* Apply suggestions from code review

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2023-06-28 12:56:00 +02:00
Vova-SH
f8fdeeabc2
Add resize_keyboard and one_time_keyboard attributes to telegram bot service (#91613)
* Add new params for telegram bot

Add resize_keyboard and one_time_keyboard attributes

* Apply review changes

* Update homeassistant/components/telegram_bot/__init__.py

* Update __init__.py

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2023-05-24 16:07:22 +02:00
Erik Montnemery
b0b1d8143f
Sort manifests 10 (#87031) 2023-02-08 20:41:50 +01:00
Franck Nijhof
ca1a12898c
Enable Ruff D212 (#87347) 2023-02-03 23:08:48 +01:00
Franck Nijhof
3b5fd4bd06
Enable Ruff TRY004 (#86811) 2023-01-30 14:06:52 +01:00
Franck Nijhof
8819634b61
String formatting and max line length - Part 6 (#84525) 2022-12-24 13:19:51 +01:00
epenet
0f33c08dca
Remove telegram_bot from mypy ignore list (#74661) 2022-07-09 19:52:26 +02:00
Lerosen
8b97271c26
Telegram bot map user data for callback query (#74302)
fix(component/telegram-bot): map user data for callback query
2022-07-06 11:21:15 +02:00
Anders Liljekvist
f5d8487768
Add send_poll to telegram bot (#68666) 2022-06-29 07:08:58 -07:00
Paulus Schoutsen
c765e11f55
Fix telegram broadcast (#69452) 2022-04-06 10:44:02 -07:00
Wictor
d7375f1a9c
Refactor telegram_bot polling/webhooks platforms and add tests (#66433)
Co-authored-by: Pär Berge <paer.berge@gmail.com>
2022-04-02 20:39:14 -07:00
Lars
e22f8496c0
Allow sending telegram stickers from sticker packs (#57482) 2022-02-23 10:42:17 -08:00
J. Nick Koston
5b755b74fb
Add loggers to integration manifest.json (#65083) 2022-01-28 13:37:53 -08:00
epenet
18056f3a8a
Add init type hints [t-u] (#63194)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2022-01-01 22:06:11 -08:00
epenet
92ace6c2e8
Ensure service calls are typed [s-u] (#62922)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2021-12-28 14:23:42 +01:00
J. Nick Koston
41bac5ccbb
Fix non-threadsafe call to async_fire in telegram_bot (#61465)
Fixes https://github.com/home-assistant/core/issues/53255#issuecomment-888111478
2021-12-11 11:20:58 +01:00
Marc Mueller
c979e89b70
Use assignment expressions 14 (#57939) 2021-10-21 08:26:01 +02:00
Ville Skyttä
d8d34fdd3b
Prefer HTTPStatus over int in HA view JSON functions (#56504)
* Prefer HTTPStatus over int in HA view JSON functions

* Update zwave tests to not expect a fixed typo
2021-09-22 21:59:52 +03:00
Joakim Sørensen
4f33679255
Fix url lookup in telegram_bot webhook (#55587) 2021-09-02 19:17:33 +02:00