core icon indicating copy to clipboard operation
core copied to clipboard

Telegram topics/threads support

Open jgresty opened this issue 1 year ago • 7 comments

Proposed change

Allow sending messages to telegram topics and threads; 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 needed an update to the existing python-telegram-bot dependency, however there are no relevant breaking changes: https://docs.python-telegram-bot.org/en/v20.6/changelog.html

Type of change

  • [x] Dependency upgrade
  • [ ] Bugfix (non-breaking change which fixes an issue)
  • [ ] New integration (thank you!)
  • [x] New feature (which adds functionality to an existing integration)
  • [ ] Deprecation (breaking change to happen in the future)
  • [ ] Breaking change (fix/feature causing existing functionality to break)
  • [ ] Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #81888 #91750
  • This PR is related to issue:
  • Link to documentation pull request: https://github.com/home-assistant/home-assistant.io/pull/29857

Checklist

  • [x] The code change is tested and works locally.
  • [x] Local tests pass. Your PR cannot be merged unless tests pass
  • [x] There is no commented out code in this PR.
  • [x] I have followed the development checklist
  • [x] I have followed the perfect PR recommendations
  • [x] The code has been formatted using Black (black --fast homeassistant tests)
  • [ ] Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • [ ] The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • [ ] New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • [x] For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • [ ] Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

jgresty avatar Nov 16 '23 01:11 jgresty

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks :+1:

Learn more about our pull request process.

home-assistant[bot] avatar Nov 16 '23 01:11 home-assistant[bot]

Hey @jgresty,

do you still want to implent this feature? I really would like to use it in home assistant! :-) There are some suggestions of @tofuSCHNITZEL to improve your code.

timoei avatar Jan 15 '24 12:01 timoei

@tofuSCHNITZEL The PR is almost complete but seems stalled since a couple of months. I would be happy to step-in to add the required changes for getting it approved, so we do not loose @jgresty's work. Would it be possible to get write access to this branch or shall I just fork jgresty:telegram-threads-support and re-submit a new PR? Thanks

r-xyz avatar Feb 04 '24 18:02 r-xyz

Would it be possible to get write access to this branch

Only OP can give you write access to their branch and then they might as well finish this PR ;)

So yeah I also thought about what to do and maybe forking their branch and then submit a new PR might be the (only) best option

tofuSCHNITZEL avatar Feb 04 '24 18:02 tofuSCHNITZEL

I am drafting the PR as there are merge conflicts. Please resolve them and mark the PR as ready for review.

edenhaus avatar Feb 05 '24 08:02 edenhaus

I was trying to re-open this PR with updated codebase, but the current requirements on httpx library broke this.

python-telegram-bot 20.6 depends on httpx~=0.25.0
  The user requested (constraint) httpx==0.26.0

Unless there is a chance to loosen the constrain on httpx, we will need to wait for a new release of python-telegram-bot library (updated in December but unreleased yet).

r-xyz avatar Feb 05 '24 15:02 r-xyz

@r-xyz I've just seen that a new version of the python-telegram-bot has been released with upgraded httpx, good timing for your efforts 👍

malkstar avatar Feb 08 '24 19:02 malkstar

Tested this after the changes in https://github.com/home-assistant/core/pull/110297 in my local environment. It works ok. The General topic has id 0 although its link has id 1. The other topics respect the number in their links.

luca-angemi avatar Feb 13 '24 22:02 luca-angemi

Since the telegram package update has been merged is it possible to reopen this PR? I've been running this as a custom component for a month without any issue.

luca-angemi avatar Mar 08 '24 09:03 luca-angemi

Hi @luca-angemi , I am sending a new PR for this later on updated codebase.

r-xyz avatar Mar 08 '24 12:03 r-xyz

Successor to this PR is available at https://github.com/home-assistant/core/pull/112715 and has suggestions from code review applied, thank you @r-xyz

malkstar avatar Mar 25 '24 18:03 malkstar

Successor to this PR is available at #112715 and has suggestions from code review applied, thank you @r-xyz

Thanks for picking this up, sorry I did not follow up. I have no motivation to work on home-assistant so please use this newer PR instead.

jgresty avatar Apr 02 '24 12:04 jgresty