2022-01-28 13:34:16 +03:00
|
|
|
from .base import EventBuilder
|
2021-09-12 13:16:02 +03:00
|
|
|
from .. import _tl
|
2018-04-05 21:14:22 +03:00
|
|
|
|
|
|
|
|
2022-01-28 13:34:16 +03:00
|
|
|
class MessageEdited(EventBuilder):
|
2018-04-05 21:14:22 +03:00
|
|
|
"""
|
2019-06-11 12:09:22 +03:00
|
|
|
Occurs whenever a message is edited. Just like `NewMessage
|
|
|
|
<telethon.events.newmessage.NewMessage>`, you should treat
|
|
|
|
this event as a `Message <telethon.tl.custom.message.Message>`.
|
2019-04-02 09:39:19 +03:00
|
|
|
|
|
|
|
.. warning::
|
|
|
|
|
|
|
|
On channels, `Message.out <telethon.tl.custom.message.Message>`
|
2019-07-06 13:10:25 +03:00
|
|
|
will be `True` if you sent the message originally, **not if
|
2019-04-02 09:39:19 +03:00
|
|
|
you edited it**! This can be dangerous if you run outgoing
|
|
|
|
commands on edits.
|
|
|
|
|
|
|
|
Some examples follow:
|
|
|
|
|
|
|
|
* You send a message "A", ``out is True``.
|
|
|
|
* You edit "A" to "B", ``out is True``.
|
|
|
|
* Someone else edits "B" to "C", ``out is True`` (**be careful!**).
|
|
|
|
* Someone sends "X", ``out is False``.
|
|
|
|
* Someone edits "X" to "Y", ``out is False``.
|
|
|
|
* You edit "Y" to "Z", ``out is False``.
|
|
|
|
|
|
|
|
Since there are useful cases where you need the right ``out``
|
|
|
|
value, the library cannot do anything automatically to help you.
|
|
|
|
Instead, consider using ``from_users='me'`` (it won't work in
|
|
|
|
broadcast channels at all since the sender is the channel and
|
|
|
|
not you).
|
2020-02-20 12:18:26 +03:00
|
|
|
|
|
|
|
Example
|
|
|
|
.. code-block:: python
|
|
|
|
|
|
|
|
from telethon import events
|
|
|
|
|
|
|
|
@client.on(events.MessageEdited)
|
|
|
|
async def handler(event):
|
|
|
|
# Log the date of new edits
|
|
|
|
print('Message', event.id, 'changed at', event.date)
|
2018-04-05 21:14:22 +03:00
|
|
|
"""
|
2018-07-19 02:47:32 +03:00
|
|
|
@classmethod
|
2022-02-15 13:57:55 +03:00
|
|
|
def _build(cls, client, update, entities):
|
2021-09-12 13:16:02 +03:00
|
|
|
if isinstance(update, (_tl.UpdateEditMessage,
|
|
|
|
_tl.UpdateEditChannelMessage)):
|
2022-02-04 13:46:57 +03:00
|
|
|
return cls._new(client, update.message, entities, None)
|