Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Telegram Topic Thread ID Support #854

Merged
merged 3 commits into from
May 12, 2023

Conversation

caronc
Copy link
Owner

@caronc caronc commented Mar 18, 2023

Description:

Related issue (if applicable): #852

Added support for Telegram Thread ID's

Parameter Breakdown

Variable Required Description
topic No The Topic Thread ID you wish your message to be posted to. Here is a StackOverflow post on acquiring the Topic Thread ID

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • No lint errors (use flake8)
  • 100% test coverage

Testing

Anyone can help test this source code as follows:

# Create a virtual environment to work in as follows:
python3 -m venv apprise

# Change into our new directory
cd apprise

# Activate our virtual environment
source bin/activate

# Install the branch
pip install git+https://github.com/caronc/apprise.git@852-telegram-topic-thread-support

# Test out the changes with the following command:
apprise -t "Test Title" -b "Test Message" \
  'tgram://credentials?topic=12345'

@caronc
Copy link
Owner Author

caronc commented Mar 18, 2023

@achlyss-8 would you be willing to test this out for me?

@codecov-commenter
Copy link

codecov-commenter commented Mar 18, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (00ddb09) 100.00% compared to head (17b6593) 100.00%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #854   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          118       118           
  Lines        15377     15405   +28     
  Branches      3154      3162    +8     
=========================================
+ Hits         15377     15405   +28     
Impacted Files Coverage Δ
apprise/plugins/NotifyTelegram.py 100.00% <100.00%> (ø)

... and 2 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@achlyss-8
Copy link

@achlyss-8 would you be willing to test this out for me?

I can't send a message, but I have no error.

Here is the command I do:

learn -t "Test Title" -b "Test Message" \
  'tgram://bottoken/ChatID?topic=TopicID'

@caronc
Copy link
Owner Author

caronc commented Mar 25, 2023

do you get an error/notice if you add more verbosity (-vvvv)?

Also, what is learn, Are you using this branch (the tool should be apprise)?

bin/apprise -vvvv "Test Title" -b "Test Message" \
  'tgram://bottoken/ChatID?topic=TopicID'

@achlyss-8
Copy link

achlyss-8 commented Mar 25, 2023

Sorry pour le learn copy and paste error.

Here are the logs, however I am sure of my bottoken and the ChatId, the topic ID I found thanks to this https://stackoverflow.com/questions/74773675/how-to-get-topic-id-for-telegram-group-chat

bin/apprise -vvvv "Test Title" -b "Test Message" \                         
  'tgram://bottoken/ChatID?topic=3'

2023-03-25 19:39:35,644 - ERROR - Unsupported URL: http://Test
2023-03-25 19:39:35,644 - ERROR - Unsupported URL: http://Title
2023-03-25 19:39:35,645 - TRACE - Telegram URL tgram://bottoken/ChatID?topic=TopicID unpacked as:
user="None"
password="None"
port="None"
host="1104640420"
fullpath="/AAF6CwduoZuunccGQT8WE-5s5L12yywSToU/ChatID"
path="/AAF6CwduoZuunccGQT8WE-5s5L12yywSToU/"
query="ChatID"
schema="tgram"
url="tgram://1104640420/AAF6CwduoZuunccGQT8WE-5s5L12yywSToU/ChatID"
qsd="{'topic': 'TopicID'}"
qsd+="{}"
qsd-="{}"
qsd:="{}"
secure="False"
verify="True"
targets="['ChatID']"
bot_token="bottoken"
silent="False"
preview="False"
include_image="False"
detect_owner="True"
2023-03-25 19:39:35,645 - DEBUG - Loaded Telegram URL: tgram://1...U/%401936855955/?image=False&detect=yes&silent=no&preview=no&format=html&overflow=upstream&rto=4.0&cto=4.0&verify=yes
2023-03-25 19:39:35,645 - DEBUG - Telegram POST URL: https://api.telegram.org/botbottoken/sendMessage (cert_verify=True)
2023-03-25 19:39:35,645 - DEBUG - Telegram Payload: {'disable_notification': False, 'disable_web_page_preview': True, 'parse_mode': 'HTML', 'text': 'Test Message', 'chat_id': ChatID}
2023-03-25 19:39:35,785 - WARNING - Failed to send Telegram notification to ChatID: Bad Request: chat not found, error=400.
2023-03-25 19:39:35,785 - DEBUG - Response Details:
b'{"ok":false,"error_code":400,"description":"Bad Request: chat not found"}'

@caronc
Copy link
Owner Author

caronc commented Apr 20, 2023

I'm confused, based on the output, the thread id you specified in your test didn't exist. Can you try with one that does?

@achlyss-8
Copy link

Indeed I had an error in the ChatID
But everything is sent to the general topic, the TopicID does not seem to be included.
It is good because Sonarr has just implemented the feature and I have the same credentials

@caronc caronc force-pushed the 852-telegram-topic-thread-support branch from ef9e2fa to ec983be Compare May 12, 2023 22:26
@caronc
Copy link
Owner Author

caronc commented May 12, 2023

Found my mistake, i created a thread= in the source code and documented it as topic= in this channel.

I just renamed the variable to actually be topic=. This should fix you up. I had a look at how Sonarr handled their change, and it's no different then what i did here.

We should be good to go now.

@caronc caronc merged commit e83cba6 into master May 12, 2023
16 checks passed
@caronc caronc deleted the 852-telegram-topic-thread-support branch May 13, 2023 02:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants