:class:`telegram.Message`: The message included in this update, no matter what kind of update this is. More precisely, this will be the message contained in :attr:`message`, :attr:`edited_message`, :attr:`channel_post`, :attr:`edited_channel_post` or :att
(self)
| 736 | |
| 737 | @property |
| 738 | def effective_message(self) -> Message | None: |
| 739 | """ |
| 740 | :class:`telegram.Message`: The message included in this update, no matter what kind of |
| 741 | update this is. More precisely, this will be the message contained in :attr:`message`, |
| 742 | :attr:`edited_message`, :attr:`channel_post`, :attr:`edited_channel_post` or |
| 743 | :attr:`callback_query` (i.e. :attr:`telegram.CallbackQuery.message`) or :obj:`None`, if |
| 744 | none of those are present. |
| 745 | |
| 746 | .. versionchanged:: 21.1 |
| 747 | This property now also considers :attr:`business_message`, and |
| 748 | :attr:`edited_business_message`. |
| 749 | |
| 750 | .. versionchanged:: 22.8 |
| 751 | This property now also considers :attr:`guest_message`. |
| 752 | |
| 753 | Tip: |
| 754 | This property will only ever return objects of type :class:`telegram.Message` or |
| 755 | :obj:`None`, never :class:`telegram.MaybeInaccessibleMessage` or |
| 756 | :class:`telegram.InaccessibleMessage`. |
| 757 | Currently, this is only relevant for :attr:`callback_query`, as |
| 758 | :attr:`telegram.CallbackQuery.message` is the only attribute considered by this |
| 759 | property that can be an object of these types. |
| 760 | """ |
| 761 | if self._effective_message: |
| 762 | return self._effective_message |
| 763 | |
| 764 | message: Message | None = None |
| 765 | |
| 766 | if self.message: |
| 767 | message = self.message |
| 768 | |
| 769 | elif self.edited_message: |
| 770 | message = self.edited_message |
| 771 | |
| 772 | elif self.callback_query: |
| 773 | if ( |
| 774 | isinstance(cbq_message := self.callback_query.message, Message) |
| 775 | or cbq_message is None |
| 776 | ): |
| 777 | message = cbq_message |
| 778 | else: |
| 779 | warn( |
| 780 | ( |
| 781 | "`update.callback_query` is not `None`, but of type " |
| 782 | f"`{cbq_message.__class__.__name__}`. This is not considered by " |
| 783 | "`Update.effective_message`. Please manually access this attribute " |
| 784 | "if necessary." |
| 785 | ), |
| 786 | stacklevel=2, |
| 787 | ) |
| 788 | |
| 789 | elif self.channel_post: |
| 790 | message = self.channel_post |
| 791 | |
| 792 | elif self.edited_channel_post: |
| 793 | message = self.edited_channel_post |
| 794 | |
| 795 | elif self.business_message: |