mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-06-17 10:36:37 +00:00
parent
7ea4686d6c
commit
74bced75b4
@ -1,4 +1,5 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
|
import functools
|
||||||
import itertools
|
import itertools
|
||||||
import time
|
import time
|
||||||
|
|
||||||
@ -11,6 +12,16 @@ from ... import helpers, utils, errors
|
|||||||
_EDIT_COLLISION_DELTA = 0.001
|
_EDIT_COLLISION_DELTA = 0.001
|
||||||
|
|
||||||
|
|
||||||
|
def _checks_cancelled(f):
|
||||||
|
@functools.wraps(f)
|
||||||
|
def wrapper(self, *args, **kwargs):
|
||||||
|
if self._cancelled:
|
||||||
|
raise asyncio.CancelledError('The conversation was cancelled before')
|
||||||
|
|
||||||
|
return f(self, *args, **kwargs)
|
||||||
|
return wrapper
|
||||||
|
|
||||||
|
|
||||||
class Conversation(ChatGetter):
|
class Conversation(ChatGetter):
|
||||||
"""
|
"""
|
||||||
Represents a conversation inside an specific chat.
|
Represents a conversation inside an specific chat.
|
||||||
@ -66,6 +77,7 @@ class Conversation(ChatGetter):
|
|||||||
|
|
||||||
self._edit_dates = {}
|
self._edit_dates = {}
|
||||||
|
|
||||||
|
@_checks_cancelled
|
||||||
async def send_message(self, *args, **kwargs):
|
async def send_message(self, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
Sends a message in the context of this conversation. Shorthand
|
Sends a message in the context of this conversation. Shorthand
|
||||||
@ -81,6 +93,7 @@ class Conversation(ChatGetter):
|
|||||||
self._last_outgoing = ms[-1].id
|
self._last_outgoing = ms[-1].id
|
||||||
return sent
|
return sent
|
||||||
|
|
||||||
|
@_checks_cancelled
|
||||||
async def send_file(self, *args, **kwargs):
|
async def send_file(self, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
Sends a file in the context of this conversation. Shorthand
|
Sends a file in the context of this conversation. Shorthand
|
||||||
@ -96,6 +109,7 @@ class Conversation(ChatGetter):
|
|||||||
self._last_outgoing = ms[-1].id
|
self._last_outgoing = ms[-1].id
|
||||||
return sent
|
return sent
|
||||||
|
|
||||||
|
@_checks_cancelled
|
||||||
def mark_read(self, message=None):
|
def mark_read(self, message=None):
|
||||||
"""
|
"""
|
||||||
Marks as read the latest received message if ``message is None``.
|
Marks as read the latest received message if ``message is None``.
|
||||||
@ -379,10 +393,8 @@ class Conversation(ChatGetter):
|
|||||||
else:
|
else:
|
||||||
raise ValueError('No message was sent previously')
|
raise ValueError('No message was sent previously')
|
||||||
|
|
||||||
|
@_checks_cancelled
|
||||||
def _get_result(self, future, start_time, timeout, pending, target_id):
|
def _get_result(self, future, start_time, timeout, pending, target_id):
|
||||||
if self._cancelled:
|
|
||||||
raise asyncio.CancelledError('The conversation was cancelled before')
|
|
||||||
|
|
||||||
due = self._total_due
|
due = self._total_due
|
||||||
if timeout is None:
|
if timeout is None:
|
||||||
timeout = self._timeout
|
timeout = self._timeout
|
||||||
|
Loading…
Reference in New Issue
Block a user