py-tgcalls 1.2.4__py3-none-any.whl → 1.2.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: py-tgcalls
3
- Version: 1.2.4
3
+ Version: 1.2.5
4
4
  Summary: UNKNOWN
5
5
  Home-page: https://github.com/pytgcalls/pytgcalls
6
6
  Author: Laky-64
@@ -22,7 +22,7 @@ Description-Content-Type: text/markdown
22
22
  License-File: LICENSE
23
23
  Requires-Dist: aiohttp (>=3.9.3)
24
24
  Requires-Dist: deprecation
25
- Requires-Dist: ntgcalls (>=1.0.7)
25
+ Requires-Dist: ntgcalls (>=1.0.8)
26
26
  Requires-Dist: psutil
27
27
  Requires-Dist: screeninfo
28
28
 
@@ -1,8 +1,9 @@
1
1
  pytgcalls/__init__.py,sha256=MRF45fC5EHvNRJgMHKZEiytlfOidmShTvi5loWD9GPw,261
2
- pytgcalls/__version__.py,sha256=LFwOR3EuDursHzyAOQiEFL0J7fChODo00O4EXW-vnCM,22
2
+ pytgcalls/__version__.py,sha256=zYFagPOovJPb43qC1fS2PSkBzcNqQNX29Git8XU53OQ,22
3
3
  pytgcalls/environment.py,sha256=ctCHACvG6l8SdpPewSBhOvc70kbwpv18maC0TwLvZ08,1924
4
4
  pytgcalls/exceptions.py,sha256=7BBRRD_lejYE8bcppkef8I1kiKPnx-O7G6IGDKg0R3Y,3532
5
5
  pytgcalls/ffmpeg.py,sha256=-y2Ce-qR8U4vgRD116aWSLFHggRZqxwrjyYb_7s3W8s,8442
6
+ pytgcalls/mtproto_required.py,sha256=04outJTCtqW4B0200NPlO83S4KLheveCxw-cWyh1i74,781
6
7
  pytgcalls/pytgcalls.py,sha256=GUKpl3UN0JsvahbJW9oOgUdtMx0-Q_gNSLdV9fdvzRs,930
7
8
  pytgcalls/pytgcalls_session.py,sha256=hWcMHEENSfl6AIogyIClinGDYibFS1MQjMfdT6-F8XA,2870
8
9
  pytgcalls/scaffold.py,sha256=fjoz6YK4M0UoBlm6se-P83RlBgDnBQncjyHsyRko5wg,794
@@ -29,17 +30,17 @@ pytgcalls/methods/decorators/on_left.py,sha256=Wz9J9mypJEMBcfQm5wFCekpsMJwbbeYDk
29
30
  pytgcalls/methods/decorators/on_participants_change.py,sha256=z-9ptd1iUiD4bSZJu4e9scETVPiRjiOicGWcDwQu67E,446
30
31
  pytgcalls/methods/decorators/on_stream_end.py,sha256=IHsGgrWXWS6kg2K6x6u2aZMpo2ahk76NHMERuH7MXv8,429
31
32
  pytgcalls/methods/groups/__init__.py,sha256=GX1LPgUKEZOrSz7zWD9pR0OPWHO_4jcMdqXTDGQf5JA,293
32
- pytgcalls/methods/groups/change_volume_call.py,sha256=GGvRlOBPAv5qzDPxzjtub2Jg0mxLea5CpQ7lkmOrzW4,878
33
- pytgcalls/methods/groups/get_participants.py,sha256=dcwZY8ypB7wWH8RSMTiy6GCkqJOZKeCuZL3FBJOu4tM,560
34
- pytgcalls/methods/groups/join_group_call.py,sha256=FLo7YCSeuCNr_zh5efSQWsoJpwASnHPvNWI8WoisGzc,3392
35
- pytgcalls/methods/groups/leave_group_call.py,sha256=VKMQ28UYVXkyPLGdV4u-WuvtL_3JpWR81gN1kyci8QM,1187
33
+ pytgcalls/methods/groups/change_volume_call.py,sha256=1qciR48hRdDwERomOPEUGcQ43Q2zRtNdBgF2JDs-w6c,720
34
+ pytgcalls/methods/groups/get_participants.py,sha256=Tjpb9ZWRJGJZioZ7Z7dpOcmEexwEqfgUfvcsqxMNW2Y,631
35
+ pytgcalls/methods/groups/join_group_call.py,sha256=tn2uEaXs47EBSe8n2ALKSPi9Oqrl39_WO1jbnsGlNHs,3234
36
+ pytgcalls/methods/groups/leave_group_call.py,sha256=rWcbHgiP8-GieWhhoR3hAfRjE8UHqE0tDx4_9usM45A,1029
36
37
  pytgcalls/methods/stream/__init__.py,sha256=Go0xKnzPLfB8c3lwCqyifk496E7jkcIZBmzYO0XbH0A,368
37
- pytgcalls/methods/stream/change_stream.py,sha256=j7hSqvBAt-w58orksS_0DEzK3koFsknGiqluTyjoCmk,1149
38
- pytgcalls/methods/stream/mute_stream.py,sha256=a4Wf2E_n65I7ewhhJI9IKPj28aSnZyNp3-Xm_ciTQ3g,827
39
- pytgcalls/methods/stream/pause_stream.py,sha256=01BL42JbjaSkoRx75BBkbTf-zfnZp2m9xDFMS7RNT0g,858
40
- pytgcalls/methods/stream/played_time.py,sha256=MFooVq3H6oMIwqXSm91wVUZF89VpGSNCtbeQDlnIQXI,827
41
- pytgcalls/methods/stream/resume_stream.py,sha256=mUP8XHWVYpMRqescSh3AVZSCiKTh5eu-ABiRIqEynRQ,861
42
- pytgcalls/methods/stream/unmute_stream.py,sha256=6gPTMNRqMAkyBGElRJlfeZCm_10HPUKzpBllc_dB4J4,833
38
+ pytgcalls/methods/stream/change_stream.py,sha256=8NnM2mTEwu4o6e9_WY1v10kXn3VeQs6HZAAkxdREZTE,991
39
+ pytgcalls/methods/stream/mute_stream.py,sha256=9R8ctu8zeMmqkdrbUq01Ni7tm0cM6Y8bM6auP8NIXqI,669
40
+ pytgcalls/methods/stream/pause_stream.py,sha256=9a-P3HZOkxbnesi4f-pPIeUQaGhlFlJIPN7pqZljo2g,672
41
+ pytgcalls/methods/stream/played_time.py,sha256=zkuGgEg8DmovnIf-vddv3A0m5fMv_goX6n8N2RP-fyk,669
42
+ pytgcalls/methods/stream/resume_stream.py,sha256=SHdldw5x3TA-R0il_OFnQ8Y1T1t1_L1Xru4ULtk4Al8,675
43
+ pytgcalls/methods/stream/unmute_stream.py,sha256=WJtyOOExr_xSVEfIWC3_4sdLzS7f3eblvX5hGpxQf0g,675
43
44
  pytgcalls/methods/utilities/__init__.py,sha256=tac73Bp0nfJefmmw3I-BPmRbyjvQPTCZBW9mXfzxs8s,426
44
45
  pytgcalls/methods/utilities/cache_peer.py,sha256=Ylt0wCCJOoNKf1wZEXjfE8aBZKUIIgdRUFOMTGA5DfE,140
45
46
  pytgcalls/methods/utilities/call_holder.py,sha256=F0AY86rq0Q8weo3yu2Tn3m7tEYd2DPXDR1x4WxE4FnI,1849
@@ -47,17 +48,17 @@ pytgcalls/methods/utilities/get_max_voice_chat.py,sha256=NbNivrr3kVguIkuTx8rUApx
47
48
  pytgcalls/methods/utilities/idle.py,sha256=khG0AGmLwgglKwToab29X5Em1tz2r4wRHTX0APrza_k,727
48
49
  pytgcalls/methods/utilities/mtproto_handler.py,sha256=pdX29BJDPsdB9xFLRZt41Lc1OXercsDhuRMZuOPgTy8,2473
49
50
  pytgcalls/methods/utilities/ping.py,sha256=pIraQyVd-fJDAdEnuD5MHBgFhXxN8-6yl2TV68aw6AA,295
50
- pytgcalls/methods/utilities/resolve_chat_id.py,sha256=GiCU2AVidY5dTK7Rf-77MBse8mizMQwdRdxCLHrq6Lc,413
51
+ pytgcalls/methods/utilities/resolve_chat_id.py,sha256=6m-oXfJy1_iHz_7UWsmRYgDLK6IFoO1-I2I7CC9ytks,383
51
52
  pytgcalls/methods/utilities/run.py,sha256=cnYQd2xB5Cr_WS0Q2cXJZPGiN6JOCULzj1r4xXVyrlg,152
52
- pytgcalls/methods/utilities/start.py,sha256=pOBtJOVwQ5WdjN2pfDmipPydKyax7ICRs-_nZfeKaKo,4067
53
+ pytgcalls/methods/utilities/start.py,sha256=jnlyn38UyAxFUCxtvX_xPLXqt3tqT6LAwTBTqwFSBSY,4803
53
54
  pytgcalls/methods/utilities/stream_params.py,sha256=hYcNxx__McmPeHgOUDEuNcN7ThgDjukejQYHrfmWm-A,1519
54
55
  pytgcalls/mtproto/__init__.py,sha256=X4zvzFG7km7qHyE0fdvA550WcOVO_xl_p__gvIfDGmw,130
55
- pytgcalls/mtproto/bridged_client.py,sha256=XKGgBdSmkeQRYRWUwH3qqz8mGCyWEoHMkkuThZEJV_s,3556
56
+ pytgcalls/mtproto/bridged_client.py,sha256=EW379VjMadbMm7gle35OWIfXdpPrF0ZszMc8r5YZi5k,4746
56
57
  pytgcalls/mtproto/client_cache.py,sha256=DISVVHvqIVtr-xU44Jkx1ArOzW6lAvUtH4iepSo4Cec,4306
57
- pytgcalls/mtproto/hydrogram_client.py,sha256=vrHGt87nVt3LdHJIMo1uxWFsjCiaZZHa6BBxJAKfzCc,15564
58
+ pytgcalls/mtproto/hydrogram_client.py,sha256=wS7NWLpdLstd_Osb4OA7l8__LiN1rKD9sCGnJX0G0jg,14111
58
59
  pytgcalls/mtproto/mtproto_client.py,sha256=Pu8YlAZMopdlwCYLhJZWwwT6X26YRb_ge3Lodv6tecc,5527
59
- pytgcalls/mtproto/pyrogram_client.py,sha256=7eRGSm2b5zmMeoHrJjezmhZ9LlZ8nngPRzkmQVjwNJc,15757
60
- pytgcalls/mtproto/telethon_client.py,sha256=Pgu89PS-OofYWT8Y7rbLmLqEvArOgWewbQX1y4qZ50M,14343
60
+ pytgcalls/mtproto/pyrogram_client.py,sha256=6zWmuWlZJE4yPsPR2qK_CCt8VMMWCMp4fTjMTVoyPAQ,14304
61
+ pytgcalls/mtproto/telethon_client.py,sha256=IhzZE4Kd07vVZtmxnmu_xQONZ4C9llDYztpS_Q3gt4w,12894
61
62
  pytgcalls/types/__init__.py,sha256=8uaM3lOM-7SjzNabH3fzC3Nz8W4sSAVBPoazmCuCA78,1775
62
63
  pytgcalls/types/browsers.py,sha256=47Kr5q96n4Q4WvVhA6IUlS2egEcA9GRLlDeFcQYyc9M,9545
63
64
  pytgcalls/types/cache.py,sha256=S9_VQdR5fEKCGBZ9LsMfRPvEMBq_0mya0CTMxbw_4L8,1073
@@ -103,8 +104,8 @@ pytgcalls/types/stream/legacy/quality/low_quality_audio.py,sha256=sa7SpkDa17SIql
103
104
  pytgcalls/types/stream/legacy/quality/low_quality_video.py,sha256=87_c1ULPqkrafNxD1YOSlQZFJSty6PqkuT0arFRgXAo,342
104
105
  pytgcalls/types/stream/legacy/quality/medium_quality_audio.py,sha256=vcMX4c4MA0t56Ch89lIFEeLe4nlFtI6_DllYlZAVbwM,344
105
106
  pytgcalls/types/stream/legacy/quality/medium_quality_video.py,sha256=xUZf2Uclipd1IWgX0rE82kNt5vBqoVwqRdoxQiTL7yA,345
106
- py_tgcalls-1.2.4.dist-info/LICENSE,sha256=46mU2C5kSwOnkqkw9XQAJlhBL2JAf1_uCD8lVcXyMRg,7652
107
- py_tgcalls-1.2.4.dist-info/METADATA,sha256=Hg8Fd8nbTJebZEGLONdBNf-9rBe0IwO2WSiI51PsVBI,4854
108
- py_tgcalls-1.2.4.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
109
- py_tgcalls-1.2.4.dist-info/top_level.txt,sha256=IUDUwn0KkcbUYZbCe9R5AUb2Ob-lmllNUGQqyeXXd8A,10
110
- py_tgcalls-1.2.4.dist-info/RECORD,,
107
+ py_tgcalls-1.2.5.dist-info/LICENSE,sha256=46mU2C5kSwOnkqkw9XQAJlhBL2JAf1_uCD8lVcXyMRg,7652
108
+ py_tgcalls-1.2.5.dist-info/METADATA,sha256=yjOhZtcqTzzze4wTkCWTQztR5UMj6PW_DPmo-bkZMUk,4854
109
+ py_tgcalls-1.2.5.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
110
+ py_tgcalls-1.2.5.dist-info/top_level.txt,sha256=IUDUwn0KkcbUYZbCe9R5AUb2Ob-lmllNUGQqyeXXd8A,10
111
+ py_tgcalls-1.2.5.dist-info/RECORD,,
pytgcalls/__version__.py CHANGED
@@ -1 +1 @@
1
- __version__ = '1.2.4'
1
+ __version__ = '1.2.5'
@@ -1,25 +1,19 @@
1
1
  from typing import Union
2
2
 
3
- from ...exceptions import ClientNotStarted
4
3
  from ...exceptions import NoActiveGroupCall
5
- from ...exceptions import NoMTProtoClientSet
4
+ from ...mtproto_required import mtproto_required
6
5
  from ...scaffold import Scaffold
7
6
  from ...statictypes import statictypes
8
7
 
9
8
 
10
9
  class ChangeVolumeCall(Scaffold):
11
10
  @statictypes
11
+ @mtproto_required
12
12
  async def change_volume_call(
13
13
  self,
14
14
  chat_id: Union[int, str],
15
15
  volume: int,
16
16
  ):
17
- if self._app is None:
18
- raise NoMTProtoClientSet()
19
-
20
- if not self._is_running:
21
- raise ClientNotStarted()
22
-
23
17
  chat_id = await self._resolve_chat_id(chat_id)
24
18
  chat_call = await self._app.get_full_chat(
25
19
  chat_id,
@@ -2,6 +2,7 @@ from typing import List
2
2
  from typing import Optional
3
3
  from typing import Union
4
4
 
5
+ from ...mtproto_required import mtproto_required
5
6
  from ...scaffold import Scaffold
6
7
  from ...statictypes import statictypes
7
8
  from ...types.groups import GroupCallParticipant
@@ -9,6 +10,7 @@ from ...types.groups import GroupCallParticipant
9
10
 
10
11
  class GetParticipants(Scaffold):
11
12
  @statictypes
13
+ @mtproto_required
12
14
  async def get_participants(
13
15
  self,
14
16
  chat_id: Union[int, str],
@@ -9,11 +9,10 @@ from ntgcalls import InvalidParams
9
9
  from ntgcalls import TelegramServerError
10
10
 
11
11
  from ...exceptions import AlreadyJoinedError
12
- from ...exceptions import ClientNotStarted
13
12
  from ...exceptions import NoActiveGroupCall
14
- from ...exceptions import NoMTProtoClientSet
15
13
  from ...exceptions import UnMuteNeeded
16
14
  from ...mtproto import BridgedClient
15
+ from ...mtproto_required import mtproto_required
17
16
  from ...scaffold import Scaffold
18
17
  from ...statictypes import statictypes
19
18
  from ...to_async import ToAsync
@@ -25,6 +24,7 @@ py_logger = logging.getLogger('pytgcalls')
25
24
 
26
25
  class JoinGroupCall(Scaffold):
27
26
  @statictypes
27
+ @mtproto_required
28
28
  async def join_group_call(
29
29
  self,
30
30
  chat_id: Union[int, str],
@@ -39,12 +39,6 @@ class JoinGroupCall(Scaffold):
39
39
  chat_id = await self._resolve_chat_id(chat_id)
40
40
  self._cache_user_peer.put(chat_id, join_as)
41
41
 
42
- if self._app is None:
43
- raise NoMTProtoClientSet()
44
-
45
- if not self._is_running:
46
- raise ClientNotStarted()
47
-
48
42
  chat_call = await self._app.get_full_chat(
49
43
  chat_id,
50
44
  )
@@ -2,10 +2,9 @@ from typing import Union
2
2
 
3
3
  from ntgcalls import ConnectionNotFound
4
4
 
5
- from ...exceptions import ClientNotStarted
6
5
  from ...exceptions import NoActiveGroupCall
7
- from ...exceptions import NoMTProtoClientSet
8
6
  from ...exceptions import NotInGroupCallError
7
+ from ...mtproto_required import mtproto_required
9
8
  from ...scaffold import Scaffold
10
9
  from ...statictypes import statictypes
11
10
  from ...to_async import ToAsync
@@ -13,16 +12,11 @@ from ...to_async import ToAsync
13
12
 
14
13
  class LeaveGroupCall(Scaffold):
15
14
  @statictypes
15
+ @mtproto_required
16
16
  async def leave_group_call(
17
17
  self,
18
18
  chat_id: Union[int, str],
19
19
  ):
20
- if self._app is None:
21
- raise NoMTProtoClientSet()
22
-
23
- if not self._is_running:
24
- raise ClientNotStarted()
25
-
26
20
  chat_id = await self._resolve_chat_id(chat_id)
27
21
  chat_call = await self._app.get_full_chat(
28
22
  chat_id,
@@ -4,9 +4,8 @@ from typing import Union
4
4
  from ntgcalls import ConnectionNotFound
5
5
  from ntgcalls import FileError
6
6
 
7
- from ...exceptions import ClientNotStarted
8
- from ...exceptions import NoMTProtoClientSet
9
7
  from ...exceptions import NotInGroupCallError
8
+ from ...mtproto_required import mtproto_required
10
9
  from ...scaffold import Scaffold
11
10
  from ...statictypes import statictypes
12
11
  from ...to_async import ToAsync
@@ -16,17 +15,12 @@ from ..utilities.stream_params import StreamParams
16
15
 
17
16
  class ChangeStream(Scaffold):
18
17
  @statictypes
18
+ @mtproto_required
19
19
  async def change_stream(
20
20
  self,
21
21
  chat_id: Union[int, str],
22
22
  stream: Optional[Stream] = None,
23
23
  ):
24
- if self._app is None:
25
- raise NoMTProtoClientSet()
26
-
27
- if not self._is_running:
28
- raise ClientNotStarted()
29
-
30
24
  chat_id = await self._resolve_chat_id(chat_id)
31
25
  try:
32
26
  await ToAsync(
@@ -2,9 +2,8 @@ from typing import Union
2
2
 
3
3
  from ntgcalls import ConnectionNotFound
4
4
 
5
- from ...exceptions import ClientNotStarted
6
- from ...exceptions import NoMTProtoClientSet
7
5
  from ...exceptions import NotInGroupCallError
6
+ from ...mtproto_required import mtproto_required
8
7
  from ...scaffold import Scaffold
9
8
  from ...statictypes import statictypes
10
9
  from ...to_async import ToAsync
@@ -12,16 +11,11 @@ from ...to_async import ToAsync
12
11
 
13
12
  class MuteStream(Scaffold):
14
13
  @statictypes
14
+ @mtproto_required
15
15
  async def mute_stream(
16
16
  self,
17
17
  chat_id: Union[int, str],
18
18
  ):
19
- if self._app is None:
20
- raise NoMTProtoClientSet()
21
-
22
- if not self._is_running:
23
- raise ClientNotStarted()
24
-
25
19
  chat_id = await self._resolve_chat_id(chat_id)
26
20
  try:
27
21
  return await ToAsync(
@@ -2,9 +2,8 @@ from typing import Union
2
2
 
3
3
  from ntgcalls import ConnectionNotFound
4
4
 
5
- from ...exceptions import ClientNotStarted
6
- from ...exceptions import NoMTProtoClientSet
7
5
  from ...exceptions import NotInGroupCallError
6
+ from ...mtproto_required import mtproto_required
8
7
  from ...scaffold import Scaffold
9
8
  from ...statictypes import statictypes
10
9
  from ...to_async import ToAsync
@@ -12,22 +11,16 @@ from ...to_async import ToAsync
12
11
 
13
12
  class PauseStream(Scaffold):
14
13
  @statictypes
14
+ @mtproto_required
15
15
  async def pause_stream(
16
16
  self,
17
17
  chat_id: Union[int, str],
18
18
  ):
19
- if self._app is None:
20
- raise NoMTProtoClientSet()
21
-
22
- if not self._is_running:
23
- raise ClientNotStarted()
24
-
25
19
  chat_id = await self._resolve_chat_id(chat_id)
26
20
  try:
27
- status = await ToAsync(
21
+ return await ToAsync(
28
22
  self._binding.pause,
29
23
  chat_id,
30
24
  )
31
- return status
32
25
  except ConnectionNotFound:
33
26
  raise NotInGroupCallError()
@@ -2,9 +2,8 @@ from typing import Union
2
2
 
3
3
  from ntgcalls import ConnectionNotFound
4
4
 
5
- from ...exceptions import ClientNotStarted
6
- from ...exceptions import NoMTProtoClientSet
7
5
  from ...exceptions import NotInGroupCallError
6
+ from ...mtproto_required import mtproto_required
8
7
  from ...scaffold import Scaffold
9
8
  from ...statictypes import statictypes
10
9
  from ...to_async import ToAsync
@@ -12,16 +11,11 @@ from ...to_async import ToAsync
12
11
 
13
12
  class PlayedTime(Scaffold):
14
13
  @statictypes
14
+ @mtproto_required
15
15
  async def played_time(
16
16
  self,
17
17
  chat_id: Union[int, str],
18
18
  ):
19
- if self._app is None:
20
- raise NoMTProtoClientSet()
21
-
22
- if not self._is_running:
23
- raise ClientNotStarted()
24
-
25
19
  chat_id = await self._resolve_chat_id(chat_id)
26
20
  try:
27
21
  return await ToAsync(
@@ -2,9 +2,8 @@ from typing import Union
2
2
 
3
3
  from ntgcalls import ConnectionNotFound
4
4
 
5
- from ...exceptions import ClientNotStarted
6
- from ...exceptions import NoMTProtoClientSet
7
5
  from ...exceptions import NotInGroupCallError
6
+ from ...mtproto_required import mtproto_required
8
7
  from ...scaffold import Scaffold
9
8
  from ...statictypes import statictypes
10
9
  from ...to_async import ToAsync
@@ -12,22 +11,16 @@ from ...to_async import ToAsync
12
11
 
13
12
  class ResumeStream(Scaffold):
14
13
  @statictypes
14
+ @mtproto_required
15
15
  async def resume_stream(
16
16
  self,
17
17
  chat_id: Union[int, str],
18
18
  ):
19
- if self._app is None:
20
- raise NoMTProtoClientSet()
21
-
22
- if not self._is_running:
23
- raise ClientNotStarted()
24
-
25
19
  chat_id = await self._resolve_chat_id(chat_id)
26
20
  try:
27
- status = await ToAsync(
21
+ return await ToAsync(
28
22
  self._binding.resume,
29
23
  chat_id,
30
24
  )
31
- return status
32
25
  except ConnectionNotFound:
33
26
  raise NotInGroupCallError()
@@ -2,9 +2,8 @@ from typing import Union
2
2
 
3
3
  from ntgcalls import ConnectionNotFound
4
4
 
5
- from ...exceptions import ClientNotStarted
6
- from ...exceptions import NoMTProtoClientSet
7
5
  from ...exceptions import NotInGroupCallError
6
+ from ...mtproto_required import mtproto_required
8
7
  from ...scaffold import Scaffold
9
8
  from ...statictypes import statictypes
10
9
  from ...to_async import ToAsync
@@ -12,16 +11,11 @@ from ...to_async import ToAsync
12
11
 
13
12
  class UnMuteStream(Scaffold):
14
13
  @statictypes
14
+ @mtproto_required
15
15
  async def unmute_stream(
16
16
  self,
17
17
  chat_id: Union[int, str],
18
18
  ):
19
- if self._app is None:
20
- raise NoMTProtoClientSet()
21
-
22
- if not self._is_running:
23
- raise ClientNotStarted()
24
-
25
19
  chat_id = await self._resolve_chat_id(chat_id)
26
20
  try:
27
21
  return await ToAsync(
@@ -7,10 +7,8 @@ from ...scaffold import Scaffold
7
7
  class ResolveChatID(Scaffold):
8
8
  async def _resolve_chat_id(self, chat_id: Union[int, str]) -> int:
9
9
  try:
10
- chat_id = int(chat_id)
10
+ return int(chat_id)
11
11
  except ValueError:
12
- chat_id = BridgedClient.chat_id(
12
+ return BridgedClient.chat_id(
13
13
  await self._app.resolve_peer(chat_id),
14
14
  )
15
-
16
- return chat_id
@@ -30,9 +30,19 @@ class Start(Scaffold):
30
30
  just_left: bool,
31
31
  ):
32
32
  chat_peer = self._cache_user_peer.get(chat_id)
33
+ if not chat_peer:
34
+ return
33
35
  is_self = BridgedClient.chat_id(chat_peer) == participant.user_id \
34
36
  if chat_peer else False
35
37
  if is_self:
38
+ if just_left:
39
+ try:
40
+ await ToAsync(
41
+ self._binding.stop,
42
+ chat_id,
43
+ )
44
+ except ConnectionNotFound:
45
+ pass
36
46
  if chat_id in self._need_unmute and \
37
47
  not just_joined and \
38
48
  not just_left and \
@@ -44,7 +54,8 @@ class Start(Scaffold):
44
54
  )
45
55
  except ConnectionNotFound:
46
56
  pass
47
- if participant.muted_by_admin:
57
+
58
+ if participant.muted_by_admin and not just_left:
48
59
  self._need_unmute.add(chat_id)
49
60
  elif chat_id in self._need_unmute:
50
61
  self._need_unmute.remove(chat_id)
@@ -69,6 +80,16 @@ class Start(Scaffold):
69
80
  update_status(chat_id, state), loop,
70
81
  )
71
82
 
83
+ def disconnect_handler(chat_id: int):
84
+ async def async_disconnect_handler():
85
+ if chat_id in self._need_unmute:
86
+ self._need_unmute.remove(chat_id)
87
+
88
+ asyncio.run_coroutine_threadsafe(
89
+ async_disconnect_handler(),
90
+ loop,
91
+ )
92
+
72
93
  async def update_status(chat_id: int, state: MediaState):
73
94
  try:
74
95
  await self._app.set_call_status(
@@ -97,7 +118,7 @@ class Start(Scaffold):
97
118
  self._is_running = True
98
119
  self._env_checker.check_environment()
99
120
  await self._init_mtproto()
100
- if not self._app.no_updates:
121
+ if self._app.no_updates:
101
122
  py_logger.warning(
102
123
  f'Using {self._app.package_name.capitalize()} '
103
124
  'client in no_updates mode is not recommended. '
@@ -109,6 +130,7 @@ class Start(Scaffold):
109
130
 
110
131
  self._binding.on_stream_end(stream_ended)
111
132
  self._binding.on_upgrade(stream_upgrade)
133
+ self._binding.on_disconnect(disconnect_handler)
112
134
  await PyTgCallsSession().start()
113
135
  else:
114
136
  raise PyTgCallsAlreadyRunning()
@@ -1,3 +1,4 @@
1
+ import asyncio
1
2
  import random
2
3
  from typing import Any
3
4
  from typing import Callable
@@ -133,23 +134,52 @@ class BridgedClient:
133
134
  def rnd_id() -> int:
134
135
  return random.randint(0, 2147483647)
135
136
 
136
- def on_closed_voice_chat(self):
137
- pass
137
+ async def _propagate(self, event_name: str, *args, **kwargs):
138
+ for event in self.HANDLERS_LIST[event_name]:
139
+ asyncio.ensure_future(event(*args, **kwargs))
138
140
 
139
- def on_kicked(self):
140
- pass
141
+ def on_closed_voice_chat(self) -> Callable:
142
+ def decorator(func: Callable) -> Callable:
143
+ if self is not None:
144
+ self.HANDLERS_LIST['CLOSED_HANDLER'].append(func)
145
+ return func
141
146
 
142
- def on_receive_invite(self):
143
- pass
147
+ return decorator
148
+
149
+ def on_kicked(self) -> Callable:
150
+ def decorator(func: Callable) -> Callable:
151
+ if self is not None:
152
+ self.HANDLERS_LIST['KICK_HANDLER'].append(func)
153
+ return func
154
+
155
+ return decorator
156
+
157
+ def on_receive_invite(self) -> Callable:
158
+ def decorator(func: Callable) -> Callable:
159
+ if self is not None:
160
+ self.HANDLERS_LIST['INVITE_HANDLER'].append(func)
161
+ return func
162
+
163
+ return decorator
144
164
 
145
165
  async def get_id(self):
146
166
  pass
147
167
 
148
- def on_left_group(self):
149
- pass
168
+ def on_left_group(self) -> Callable:
169
+ def decorator(func: Callable) -> Callable:
170
+ if self is not None:
171
+ self.HANDLERS_LIST['LEFT_HANDLER'].append(func)
172
+ return func
150
173
 
151
- def on_participants_change(self):
152
- pass
174
+ return decorator
175
+
176
+ def on_participants_change(self) -> Callable:
177
+ def decorator(func: Callable) -> Callable:
178
+ if self is not None:
179
+ self.HANDLERS_LIST['PARTICIPANTS_HANDLER'].append(func)
180
+ return func
181
+
182
+ return decorator
153
183
 
154
184
  async def get_full_chat(self, chat_id: int):
155
185
  pass
@@ -1,6 +1,4 @@
1
- import asyncio
2
1
  import json
3
- from typing import Callable
4
2
  from typing import Dict
5
3
  from typing import List
6
4
  from typing import Optional
@@ -194,50 +192,6 @@ class HydrogramClient(BridgedClient):
194
192
  )
195
193
  raise ContinuePropagation()
196
194
 
197
- async def _propagate(self, event_name: str, *args, **kwargs):
198
- for event in self.HANDLERS_LIST[event_name]:
199
- asyncio.ensure_future(event(*args, **kwargs))
200
-
201
- def on_closed_voice_chat(self) -> Callable:
202
- def decorator(func: Callable) -> Callable:
203
- if self is not None:
204
- self.HANDLERS_LIST['CLOSED_HANDLER'].append(func)
205
- return func
206
-
207
- return decorator
208
-
209
- def on_kicked(self) -> Callable:
210
- def decorator(func: Callable) -> Callable:
211
- if self is not None:
212
- self.HANDLERS_LIST['KICK_HANDLER'].append(func)
213
- return func
214
-
215
- return decorator
216
-
217
- def on_receive_invite(self) -> Callable:
218
- def decorator(func: Callable) -> Callable:
219
- if self is not None:
220
- self.HANDLERS_LIST['INVITE_HANDLER'].append(func)
221
- return func
222
-
223
- return decorator
224
-
225
- def on_left_group(self) -> Callable:
226
- def decorator(func: Callable) -> Callable:
227
- if self is not None:
228
- self.HANDLERS_LIST['LEFT_HANDLER'].append(func)
229
- return func
230
-
231
- return decorator
232
-
233
- def on_participants_change(self) -> Callable:
234
- def decorator(func: Callable) -> Callable:
235
- if self is not None:
236
- self.HANDLERS_LIST['PARTICIPANTS_HANDLER'].append(func)
237
- return func
238
-
239
- return decorator
240
-
241
195
  async def get_call(
242
196
  self,
243
197
  chat_id: int,
@@ -433,7 +387,7 @@ class HydrogramClient(BridgedClient):
433
387
  return self._app.is_connected
434
388
 
435
389
  def no_updates(self):
436
- return not self._app.no_updates
390
+ return self._app.no_updates
437
391
 
438
392
  async def start(self):
439
393
  await self._app.start()
@@ -1,6 +1,4 @@
1
- import asyncio
2
1
  import json
3
- from typing import Callable
4
2
  from typing import Dict
5
3
  from typing import List
6
4
  from typing import Optional
@@ -202,50 +200,6 @@ class PyrogramClient(BridgedClient):
202
200
  )
203
201
  raise ContinuePropagation()
204
202
 
205
- async def _propagate(self, event_name: str, *args, **kwargs):
206
- for event in self.HANDLERS_LIST[event_name]:
207
- asyncio.ensure_future(event(*args, **kwargs))
208
-
209
- def on_closed_voice_chat(self) -> Callable:
210
- def decorator(func: Callable) -> Callable:
211
- if self is not None:
212
- self.HANDLERS_LIST['CLOSED_HANDLER'].append(func)
213
- return func
214
-
215
- return decorator
216
-
217
- def on_kicked(self) -> Callable:
218
- def decorator(func: Callable) -> Callable:
219
- if self is not None:
220
- self.HANDLERS_LIST['KICK_HANDLER'].append(func)
221
- return func
222
-
223
- return decorator
224
-
225
- def on_receive_invite(self) -> Callable:
226
- def decorator(func: Callable) -> Callable:
227
- if self is not None:
228
- self.HANDLERS_LIST['INVITE_HANDLER'].append(func)
229
- return func
230
-
231
- return decorator
232
-
233
- def on_left_group(self) -> Callable:
234
- def decorator(func: Callable) -> Callable:
235
- if self is not None:
236
- self.HANDLERS_LIST['LEFT_HANDLER'].append(func)
237
- return func
238
-
239
- return decorator
240
-
241
- def on_participants_change(self) -> Callable:
242
- def decorator(func: Callable) -> Callable:
243
- if self is not None:
244
- self.HANDLERS_LIST['PARTICIPANTS_HANDLER'].append(func)
245
- return func
246
-
247
- return decorator
248
-
249
203
  async def get_call(
250
204
  self,
251
205
  chat_id: int,
@@ -441,7 +395,7 @@ class PyrogramClient(BridgedClient):
441
395
  return self._app.is_connected
442
396
 
443
397
  def no_updates(self):
444
- return not self._app.no_updates
398
+ return self._app.no_updates
445
399
 
446
400
  async def start(self):
447
401
  await self._app.start()
@@ -1,6 +1,4 @@
1
- import asyncio
2
1
  import json
3
- from typing import Callable
4
2
  from typing import List
5
3
  from typing import Optional
6
4
  from typing import Union
@@ -298,45 +296,6 @@ class TelethonClient(BridgedClient):
298
296
  ),
299
297
  )
300
298
 
301
- async def _propagate(self, event_name: str, *args, **kwargs):
302
- for event in self.HANDLERS_LIST[event_name]:
303
- asyncio.ensure_future(event(*args, **kwargs))
304
-
305
- def on_closed_voice_chat(self) -> Callable:
306
- def decorator(func: Callable) -> Callable:
307
- if self is not None:
308
- self.HANDLERS_LIST['CLOSED_HANDLER'].append(func)
309
- return func
310
- return decorator
311
-
312
- def on_kicked(self) -> Callable:
313
- def decorator(func: Callable) -> Callable:
314
- if self is not None:
315
- self.HANDLERS_LIST['KICK_HANDLER'].append(func)
316
- return func
317
- return decorator
318
-
319
- def on_receive_invite(self) -> Callable:
320
- def decorator(func: Callable) -> Callable:
321
- if self is not None:
322
- self.HANDLERS_LIST['INVITE_HANDLER'].append(func)
323
- return func
324
- return decorator
325
-
326
- def on_left_group(self) -> Callable:
327
- def decorator(func: Callable) -> Callable:
328
- if self is not None:
329
- self.HANDLERS_LIST['LEFT_HANDLER'].append(func)
330
- return func
331
- return decorator
332
-
333
- def on_participants_change(self) -> Callable:
334
- def decorator(func: Callable) -> Callable:
335
- if self is not None:
336
- self.HANDLERS_LIST['PARTICIPANTS_HANDLER'].append(func)
337
- return func
338
- return decorator
339
-
340
299
  async def leave_group_call(
341
300
  self,
342
301
  chat_id: int,
@@ -403,7 +362,7 @@ class TelethonClient(BridgedClient):
403
362
  return self._app.is_connected()
404
363
 
405
364
  def no_updates(self):
406
- return True
365
+ return False
407
366
 
408
367
  async def start(self):
409
- await self._app.start()
368
+ self._app.start()
@@ -0,0 +1,31 @@
1
+ import inspect
2
+ from functools import wraps
3
+
4
+ from .exceptions import ClientNotStarted
5
+ from .exceptions import NoMTProtoClientSet
6
+
7
+
8
+ def mtproto_required(func):
9
+ def check_mtproto(*args, **_):
10
+ self = args[0]
11
+ if not self._app:
12
+ raise NoMTProtoClientSet()
13
+
14
+ if not self._is_running:
15
+ raise ClientNotStarted()
16
+
17
+ @wraps(func)
18
+ async def async_wrapper(*args, **kwargs):
19
+ check_mtproto(*args, **kwargs)
20
+ return await func(*args, **kwargs)
21
+
22
+ @wraps(func)
23
+ def wrapper(*args, **kwargs):
24
+ check_mtproto(*args, **kwargs)
25
+ return func(*args, **kwargs)
26
+
27
+ if inspect.iscoroutinefunction(func) or \
28
+ inspect.isasyncgenfunction(func):
29
+ return async_wrapper
30
+ else:
31
+ return wrapper