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

message.get_url() in chat with topics -> wrong url #1451

Open
Robotvasya opened this issue Apr 6, 2024 · 2 comments · May be fixed by #1469
Open

message.get_url() in chat with topics -> wrong url #1451

Robotvasya opened this issue Apr 6, 2024 · 2 comments · May be fixed by #1469
Labels
enhancement Make it better!

Comments

@Robotvasya
Copy link
Contributor

aiogram version

3.x

Problem

The method message.get_url() returns wrong url when it call in chat with topics:
Returns https://t.me/username/message_id but should https://t.me/username/message_thread_id/message_id

def get_url(self, force_private: bool = False) -> Optional[str]:

I have not checked whether there is such a problem in other methods of the Message object. And I haven’t checked whether this method is used in other parts of the aiogram framework.

Possible solution

possible patch

--- a/.venv/lib/python3.10/site-packages/aiogram/types/message.py	
+++ b/.venv/lib/python3.10/site-packages/aiogram/types/message.py	(date 1712428103364)
@@ -3765,8 +3765,13 @@
             else self.chat.username
         )
 
+        message_value = (
+            f"{self.message_id}"
+            if not self.message_thread_id
+            else f"{self.message_thread_id}/{self.message_id}"
+        )
 
-        return f"https://t.me/{chat_value}/{self.message_id}"
+        return f"https://t.me/{chat_value}/{message_value}"
 
     def react(
         self,

Alternatives

No response

Code example

No response

Additional information

No response

@Robotvasya Robotvasya added the enhancement Make it better! label Apr 6, 2024
@Robotvasya Robotvasya changed the title message.get_url() in chat with topics message.get_url() in chat with topics -> wrong url Apr 6, 2024
@Olegt0rr
Copy link
Contributor

Olegt0rr commented Apr 7, 2024

Why don't you send a PR?

Looks like it should be able to take both urls: within topic and within all group

@Robotvasya
Copy link
Contributor Author

I'll send PR, no problem. I'm afraid that this behavior not only in this function but also remains somewhere else.

Robotvasya added a commit to Robotvasya/aiogram that referenced this issue Apr 8, 2024
Robotvasya added a commit to Robotvasya/aiogram that referenced this issue Apr 8, 2024
Robotvasya added a commit to Robotvasya/aiogram that referenced this issue Apr 10, 2024
Robotvasya added a commit to Robotvasya/aiogram that referenced this issue Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Make it better!
Projects
None yet
2 participants