py-tgcalls 2.0.0rc6__py3-none-any.whl → 2.0.1__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.
Files changed (36) hide show
  1. py_tgcalls-2.0.1.dist-info/METADATA +297 -0
  2. {py_tgcalls-2.0.0rc6.dist-info → py_tgcalls-2.0.1.dist-info}/RECORD +33 -34
  3. {py_tgcalls-2.0.0rc6.dist-info → py_tgcalls-2.0.1.dist-info}/WHEEL +1 -1
  4. pytgcalls/__version__.py +1 -1
  5. pytgcalls/ffmpeg.py +6 -7
  6. pytgcalls/filters.py +14 -1
  7. pytgcalls/methods/calls/get_participants.py +1 -1
  8. pytgcalls/methods/calls/leave_call.py +4 -0
  9. pytgcalls/methods/stream/play.py +1 -3
  10. pytgcalls/methods/utilities/call_holder.py +14 -11
  11. pytgcalls/methods/utilities/idle.py +2 -2
  12. pytgcalls/methods/utilities/start.py +28 -17
  13. pytgcalls/mtproto/client_cache.py +1 -1
  14. pytgcalls/mtproto/hydrogram_client.py +9 -7
  15. pytgcalls/mtproto/mtproto_client.py +1 -1
  16. pytgcalls/mtproto/pyrogram_client.py +9 -7
  17. pytgcalls/mtproto/telethon_client.py +9 -7
  18. pytgcalls/mutex.py +2 -29
  19. pytgcalls/pytgcalls.py +1 -0
  20. pytgcalls/scaffold.py +0 -1
  21. pytgcalls/types/__init__.py +3 -7
  22. pytgcalls/types/calls/call.py +0 -1
  23. pytgcalls/types/calls/call_data.py +5 -3
  24. pytgcalls/types/calls/raw_call_update.py +1 -1
  25. pytgcalls/types/{groups → chats}/__init__.py +0 -4
  26. pytgcalls/types/{groups → chats}/group_call_participant.py +14 -2
  27. pytgcalls/types/{groups → chats}/updated_group_call_participant.py +1 -1
  28. pytgcalls/types/dict.py +5 -0
  29. pytgcalls/types/participant_list.py +2 -2
  30. pytgcalls/ytdlp.py +8 -1
  31. py_tgcalls-2.0.0rc6.dist-info/METADATA +0 -128
  32. pytgcalls/types/groups/joined_group_call_participant.py +0 -12
  33. pytgcalls/types/groups/left_group_call_participant.py +0 -12
  34. {py_tgcalls-2.0.0rc6.dist-info → py_tgcalls-2.0.1.dist-info}/LICENSE +0 -0
  35. {py_tgcalls-2.0.0rc6.dist-info → py_tgcalls-2.0.1.dist-info}/top_level.txt +0 -0
  36. /pytgcalls/types/{groups → chats}/chat_update.py +0 -0
@@ -0,0 +1,297 @@
1
+ Metadata-Version: 2.1
2
+ Name: py-tgcalls
3
+ Version: 2.0.1
4
+ Summary: Async client API for the Telegram Calls.
5
+ Author-email: Laky-64 <iraci.matteo@gmail.com>
6
+ License: GNU LESSER GENERAL PUBLIC LICENSE
7
+ Version 3, 29 June 2007
8
+
9
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
10
+ Everyone is permitted to copy and distribute verbatim copies
11
+ of this license document, but changing it is not allowed.
12
+
13
+
14
+ This version of the GNU Lesser General Public License incorporates
15
+ the terms and conditions of version 3 of the GNU General Public
16
+ License, supplemented by the additional permissions listed below.
17
+
18
+ 0. Additional Definitions.
19
+
20
+ As used herein, "this License" refers to version 3 of the GNU Lesser
21
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
22
+ General Public License.
23
+
24
+ "The Library" refers to a covered work governed by this License,
25
+ other than an Application or a Combined Work as defined below.
26
+
27
+ An "Application" is any work that makes use of an interface provided
28
+ by the Library, but which is not otherwise based on the Library.
29
+ Defining a subclass of a class defined by the Library is deemed a mode
30
+ of using an interface provided by the Library.
31
+
32
+ A "Combined Work" is a work produced by combining or linking an
33
+ Application with the Library. The particular version of the Library
34
+ with which the Combined Work was made is also called the "Linked
35
+ Version".
36
+
37
+ The "Minimal Corresponding Source" for a Combined Work means the
38
+ Corresponding Source for the Combined Work, excluding any source code
39
+ for portions of the Combined Work that, considered in isolation, are
40
+ based on the Application, and not on the Linked Version.
41
+
42
+ The "Corresponding Application Code" for a Combined Work means the
43
+ object code and/or source code for the Application, including any data
44
+ and utility programs needed for reproducing the Combined Work from the
45
+ Application, but excluding the System Libraries of the Combined Work.
46
+
47
+ 1. Exception to Section 3 of the GNU GPL.
48
+
49
+ You may convey a covered work under sections 3 and 4 of this License
50
+ without being bound by section 3 of the GNU GPL.
51
+
52
+ 2. Conveying Modified Versions.
53
+
54
+ If you modify a copy of the Library, and, in your modifications, a
55
+ facility refers to a function or data to be supplied by an Application
56
+ that uses the facility (other than as an argument passed when the
57
+ facility is invoked), then you may convey a copy of the modified
58
+ version:
59
+
60
+ a) under this License, provided that you make a good faith effort to
61
+ ensure that, in the event an Application does not supply the
62
+ function or data, the facility still operates, and performs
63
+ whatever part of its purpose remains meaningful, or
64
+
65
+ b) under the GNU GPL, with none of the additional permissions of
66
+ this License applicable to that copy.
67
+
68
+ 3. Object Code Incorporating Material from Library Header Files.
69
+
70
+ The object code form of an Application may incorporate material from
71
+ a header file that is part of the Library. You may convey such object
72
+ code under terms of your choice, provided that, if the incorporated
73
+ material is not limited to numerical parameters, data structure
74
+ layouts and accessors, or small macros, inline functions and templates
75
+ (ten or fewer lines in length), you do both of the following:
76
+
77
+ a) Give prominent notice with each copy of the object code that the
78
+ Library is used in it and that the Library and its use are
79
+ covered by this License.
80
+
81
+ b) Accompany the object code with a copy of the GNU GPL and this license
82
+ document.
83
+
84
+ 4. Combined Works.
85
+
86
+ You may convey a Combined Work under terms of your choice that,
87
+ taken together, effectively do not restrict modification of the
88
+ portions of the Library contained in the Combined Work and reverse
89
+ engineering for debugging such modifications, if you also do each of
90
+ the following:
91
+
92
+ a) Give prominent notice with each copy of the Combined Work that
93
+ the Library is used in it and that the Library and its use are
94
+ covered by this License.
95
+
96
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
97
+ document.
98
+
99
+ c) For a Combined Work that displays copyright notices during
100
+ execution, include the copyright notice for the Library among
101
+ these notices, as well as a reference directing the user to the
102
+ copies of the GNU GPL and this license document.
103
+
104
+ d) Do one of the following:
105
+
106
+ 0) Convey the Minimal Corresponding Source under the terms of this
107
+ License, and the Corresponding Application Code in a form
108
+ suitable for, and under terms that permit, the user to
109
+ recombine or relink the Application with a modified version of
110
+ the Linked Version to produce a modified Combined Work, in the
111
+ manner specified by section 6 of the GNU GPL for conveying
112
+ Corresponding Source.
113
+
114
+ 1) Use a suitable shared library mechanism for linking with the
115
+ Library. A suitable mechanism is one that (a) uses at run time
116
+ a copy of the Library already present on the user's computer
117
+ system, and (b) will operate properly with a modified version
118
+ of the Library that is interface-compatible with the Linked
119
+ Version.
120
+
121
+ e) Provide Installation Information, but only if you would otherwise
122
+ be required to provide such information under section 6 of the
123
+ GNU GPL, and only to the extent that such information is
124
+ necessary to install and execute a modified version of the
125
+ Combined Work produced by recombining or relinking the
126
+ Application with a modified version of the Linked Version. (If
127
+ you use option 4d0, the Installation Information must accompany
128
+ the Minimal Corresponding Source and Corresponding Application
129
+ Code. If you use option 4d1, you must provide the Installation
130
+ Information in the manner specified by section 6 of the GNU GPL
131
+ for conveying Corresponding Source.)
132
+
133
+ 5. Combined Libraries.
134
+
135
+ You may place library facilities that are a work based on the
136
+ Library side by side in a single library together with other library
137
+ facilities that are not Applications and are not covered by this
138
+ License, and convey such a combined library under terms of your
139
+ choice, if you do both of the following:
140
+
141
+ a) Accompany the combined library with a copy of the same work based
142
+ on the Library, uncombined with any other library facilities,
143
+ conveyed under the terms of this License.
144
+
145
+ b) Give prominent notice with the combined library that part of it
146
+ is a work based on the Library, and explaining where to find the
147
+ accompanying uncombined form of the same work.
148
+
149
+ 6. Revised Versions of the GNU Lesser General Public License.
150
+
151
+ The Free Software Foundation may publish revised and/or new versions
152
+ of the GNU Lesser General Public License from time to time. Such new
153
+ versions will be similar in spirit to the present version, but may
154
+ differ in detail to address new problems or concerns.
155
+
156
+ Each version is given a distinguishing version number. If the
157
+ Library as you received it specifies that a certain numbered version
158
+ of the GNU Lesser General Public License "or any later version"
159
+ applies to it, you have the option of following the terms and
160
+ conditions either of that published version or of any later version
161
+ published by the Free Software Foundation. If the Library as you
162
+ received it does not specify a version number of the GNU Lesser
163
+ General Public License, you may choose any version of the GNU Lesser
164
+ General Public License ever published by the Free Software Foundation.
165
+
166
+ If the Library as you received it specifies that a proxy can decide
167
+ whether future versions of the GNU Lesser General Public License shall
168
+ apply, that proxy's public statement of acceptance of any version is
169
+ permanent authorization for you to choose that version for the
170
+ Library.
171
+
172
+ Project-URL: Homepage, https://pytgcalls.github.io/
173
+ Project-URL: Repository, https://github.com/pytgcalls/pytgcalls.git
174
+ Project-URL: Documentation, https://pytgcalls.github.io/PyTgCalls
175
+ Project-URL: Changelog, https://pytgcalls.github.io/PyTgCalls/Changelogs
176
+ Keywords: audio,python,library,video,telegram,stream,ffmpeg,cpp,webrtc,voice-chat,voip,group-chat,video-calls,calls,video-chat,pytgcalls,ntgcalls,tgcalls,py-tgcalls,pyrogram,telethon,hydrogram
177
+ Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)
178
+ Classifier: Operating System :: OS Independent
179
+ Classifier: Programming Language :: Python :: 3
180
+ Classifier: Programming Language :: Python :: 3 :: Only
181
+ Classifier: Programming Language :: Python :: 3.8
182
+ Classifier: Programming Language :: Python :: 3.9
183
+ Classifier: Programming Language :: Python :: 3.10
184
+ Classifier: Programming Language :: Python :: 3.11
185
+ Classifier: Programming Language :: Python :: 3.12
186
+ Requires-Python: >=3.8
187
+ Description-Content-Type: text/markdown
188
+ License-File: LICENSE
189
+ Requires-Dist: aiohttp >=3.9.3
190
+ Requires-Dist: ntgcalls >=1.2.0
191
+ Requires-Dist: psutil
192
+ Requires-Dist: screeninfo
193
+ Requires-Dist: deprecation
194
+ Provides-Extra: hydrogram
195
+ Requires-Dist: hydrogram >=0.1.4 ; extra == 'hydrogram'
196
+ Provides-Extra: pyrogram
197
+ Requires-Dist: pyrogram >=1.2.20 ; extra == 'pyrogram'
198
+ Provides-Extra: telethon
199
+ Requires-Dist: telethon >=1.24.0 ; extra == 'telethon'
200
+
201
+ <img src="https://raw.githubusercontent.com/pytgcalls/pytgcalls/master/.github/images/banner.png" alt="pytgcalls logo" />
202
+ <p align="center">
203
+ <b>A simple and elegant client that allows you to make group voice calls quickly and easily.</b>
204
+ <br>
205
+ <a href="https://github.com/pytgcalls/pytgcalls/tree/master/example">
206
+ Examples
207
+ </a>
208
+
209
+ <a href="https://pytgcalls.github.io/">
210
+ Documentation
211
+ </a>
212
+
213
+ <a href="https://pypi.org/project/py-tgcalls/">
214
+ PyPi
215
+ </a>
216
+
217
+ <a href="https://t.me/pytgcallsnews">
218
+ Channel
219
+ </a>
220
+
221
+ <a href="https://t.me/pytgcallschat">
222
+ Chat
223
+ </a>
224
+ </p>
225
+
226
+ # PyTgCalls [![PyPI](https://img.shields.io/pypi/v/py-tgcalls.svg?logo=python&logoColor=%23959DA5&label=pypi&labelColor=%23282f37)](https://pypi.org/project/py-tgcalls/) [![Downloads](https://pepy.tech/badge/py-tgcalls)](https://pepy.tech/project/py-tgcalls)
227
+ This project allows making Telegram call using MtProto and WebRTC, this is possible thanks to the power of [NTgCalls] library and [@evgeny-nadymov]
228
+
229
+ #### Example Usage
230
+ ```python
231
+ from pytgcalls import PyTgCalls
232
+ from pytgcalls import idle
233
+ from pytgcalls.types import MediaStream
234
+ ...
235
+ chat_id = -1001185324811
236
+ app = PyTgCalls(client)
237
+ app.start()
238
+ app.play(
239
+ chat_id,
240
+ MediaStream(
241
+ 'http://docs.evostream.com/sample_content/assets/sintel1m720p.mp4',
242
+ )
243
+ )
244
+ idle()
245
+ ```
246
+
247
+ ## Features
248
+ - Prebuilt wheels for macOS, Linux and Windows.
249
+ - Supporting all type of MTProto libraries: Pyrogram, Telethon and Hydrogram.
250
+ - Work with voice chats in channels and chats.
251
+ - Join as channels or chats.
252
+ - Mute/unmute, pause/resume, stop/play, volume control and more...
253
+
254
+ ## Requirements
255
+ - Python 3.8 or higher.
256
+ - An MTProto Client
257
+ - A [Telegram API key](https://docs.pyrogram.org/intro/setup#api-keys).
258
+
259
+ ## How to install?
260
+ Here's how to install the PyTgCalls lib, the commands are given below:
261
+
262
+ ``` bash
263
+ # With Git
264
+ pip install git+https://github.com/pytgcalls/pytgcalls -U
265
+
266
+ # With PyPi (Recommended)
267
+ pip install py-tgcalls -U
268
+ ```
269
+
270
+ ## Key Contributors
271
+ * <b><a href="https://github.com/Laky-64">@Laky-64</a> (DevOps Engineer, Software Architect):</b>
272
+ * Played a crucial role in developing PyTgCalls being an ex developer of pyservercall and of tgcallsjs.
273
+ * Automation with GitHub Actions
274
+ * <b><a href="https://github.com/kuogi">@kuogi</a> (Senior UI/UX designer, Documenter):</b>
275
+ * As a Senior UI/UX Designer, Kuogi has significantly improved the user interface of our documentation,
276
+ making it more visually appealing and user-friendly.
277
+ * Played a key role in writing and structuring our documentation, ensuring that it is clear,
278
+ informative, and accessible to all users.
279
+ * <b><a href="https://github.com/vrumger">@vrumger</a> (Senior Node.js Developer, Software Architect):</b>
280
+ * Has made important fixes and enhancements to the WebRTC component of the library,
281
+ improving its stability and performance.
282
+ * Main developer of TgCallsJS
283
+ * <b><a href="https://github.com/alemidev">@alemidev</a> (Senior Python Developer):</b>
284
+ * Has made important fixes and enhancements to the async part of the library
285
+
286
+ ## Junior Developers
287
+ * <b><a href="https://github.com/TuriOG">@TuriOG</a> (Junior Python Developer):</b>
288
+ * Currently working on integrating NTgCalls into <a href="//github.com/pytgcalls/pytgcalls">PyTgCalls</a>, an important step
289
+ in expanding the functionality and usability of the library.
290
+
291
+ ## Special Thanks
292
+ * <b><a href="https://github.com/evgeny-nadymov">@evgeny-nadymov</a>:</b>
293
+ A heartfelt thank you to Evgeny Nadymov for graciously allowing us to use their code from telegram-react.
294
+ His contribution has been pivotal to the success of this project.
295
+
296
+ [NTgCalls]: https://github.com/pytgcalls/ntgcalls
297
+ [@evgeny-nadymov]: https://github.com/evgeny-nadymov/
@@ -1,18 +1,18 @@
1
1
  pytgcalls/__init__.py,sha256=TfZGf1enqqs50mBB406vygB6zYgn3vAjBYFUDO4Pviw,248
2
- pytgcalls/__version__.py,sha256=y0B7ZR3Q3YBruJD1vgqFl1sLUm6_2LUesuwSiUVq0eE,25
2
+ pytgcalls/__version__.py,sha256=HVx0XJJ9OYFWBBPBCUFYb8Nm43ChPg9GZLh_dkxh9qI,22
3
3
  pytgcalls/environment.py,sha256=ctCHACvG6l8SdpPewSBhOvc70kbwpv18maC0TwLvZ08,1924
4
4
  pytgcalls/exceptions.py,sha256=0MmAktc53ajYAc7ThjD2tJ9PDyibUi0iHZMfUy2IoKs,4109
5
- pytgcalls/ffmpeg.py,sha256=1GavkVf562Y_8cT4EZxxj_b7Y0-l8yyGkX0D5eUHeas,8520
6
- pytgcalls/filters.py,sha256=cmFWhRkgjQMk1WQqnd-hOAvM6x3dufJ1xjQAEL1vKLQ,4409
5
+ pytgcalls/ffmpeg.py,sha256=sut7ssGcvprC3NWFpCfyguyNKAXaeM0mv3lXSvDPRpM,8518
6
+ pytgcalls/filters.py,sha256=HFMBBbo_NCw6wqTtseHoDRsspJHQ49BUHBA1cxm7u4g,4852
7
7
  pytgcalls/mtproto_required.py,sha256=6B-31p5qH_6oekUgypV4nK3hqPS6Nr-pA8S81wjnbaY,630
8
- pytgcalls/mutex.py,sha256=fSsAL4NuB7esBG90k4eUX388Knpr1_76Mz5BZlkSC0w,1119
9
- pytgcalls/pytgcalls.py,sha256=VI9aRwPE-Lo1lh18ByOnkFxf1_8tq2ECyz5igPo1r8w,1443
8
+ pytgcalls/mutex.py,sha256=Frjji5Ctzlk4AXEBuBLnDK-7HbtreoV6zuyKpFpMNI4,236
9
+ pytgcalls/pytgcalls.py,sha256=oBcWgBwusnXmjHrLEE99VVXARReVyrXdn9SyeBWHbVo,1479
10
10
  pytgcalls/pytgcalls_session.py,sha256=_BGJWvf7t3mki2DhlEPjh9cypvYuSFkMSxzTsfepwUk,2719
11
- pytgcalls/scaffold.py,sha256=d5NFFm-Ntlu07fpXOE_OI4ULrvNb3Y4WDtM0nsKjqk4,986
11
+ pytgcalls/scaffold.py,sha256=LihXRBl1kSqJSQvEoH5rAXJXrbnnIqSMBYrhXpW5hHs,958
12
12
  pytgcalls/statictypes.py,sha256=CdlqgQNhTZ_uTE8-B8m01fJ7TlD2B42EI2QBPxDdAtA,3842
13
13
  pytgcalls/sync.py,sha256=IsOH3TD7cxUg_-zdGt12HoS8sBlXvcGayPZAoxxKM48,3396
14
14
  pytgcalls/version_manager.py,sha256=egeGgvb66zWlLTMuw2U-b0x8MfnRzMm1xAEVN87HF5c,296
15
- pytgcalls/ytdlp.py,sha256=4Sl0L2uEmBSeRYfpavtAmxv41AOiQ3LotEjrqRbehc0,1961
15
+ pytgcalls/ytdlp.py,sha256=VqeWts_jgPJTmcOM5_rckuKEOA0N2FujaBWvX3CyXE0,2196
16
16
  pytgcalls/custom_api/__init__.py,sha256=ZT8d0lc2YrDuw_YSFAXXHHMewoXGFZ-ANOBIAr0vGFQ,60
17
17
  pytgcalls/custom_api/custom_api.py,sha256=Ko3aS6psrwPmOhRPxvG0fepXt4STrA0StvINSxz4Cj8,1890
18
18
  pytgcalls/handlers/__init__.py,sha256=pubbxI4pLqQpAKf8-toD6ija4cpSvbCJOQFjTiDjX1E,75
@@ -24,56 +24,55 @@ pytgcalls/media_devices/screen_info.py,sha256=ARD5nQoYDUt1rU-kOK8G5O5byGXGeFbZWW
24
24
  pytgcalls/methods/__init__.py,sha256=hk1blAT5u_Isemdrg0nqInLsdRzTTZnak5NdAfkBPAk,217
25
25
  pytgcalls/methods/calls/__init__.py,sha256=xg4DZZClEnxwaj-DAq3e8gSR-g-MiYBdUEBth64lSXA,214
26
26
  pytgcalls/methods/calls/change_volume_call.py,sha256=viA3yHVxPJ421yE1dfFTh-kNEFTxMlaVFxVjC-PeX-0,719
27
- pytgcalls/methods/calls/get_participants.py,sha256=dT725XXn9oiTbWV6mFradIydoQUx_COPButivDhzAxE,568
28
- pytgcalls/methods/calls/leave_call.py,sha256=ZjZbjlQn8KuX3mUjzXfX42EpL9_iU3fsXYdidfqUrUM,1091
27
+ pytgcalls/methods/calls/get_participants.py,sha256=gKUAzvha1RpvbtSI_n-GlBQkOONxzibCaCr4aA17Mag,567
28
+ pytgcalls/methods/calls/leave_call.py,sha256=UQ3H0a5W4OmQF3KTtoaE0qYqRhqRD-npcAzWWGDbGQs,1256
29
29
  pytgcalls/methods/decorators/__init__.py,sha256=TCGaEVZnHjtOwv-3PNfaCVm0kyFhJApUPUNntt6MwyM,78
30
30
  pytgcalls/methods/decorators/on_update.py,sha256=ZTL4YcQk0N4Ru56a5WItUvkSN5SAqr6_RDZvXmZMIHs,316
31
31
  pytgcalls/methods/stream/__init__.py,sha256=_4j-CEby4_2Kadva86tFMC4GSSzhBBjKLXfrgTk4gzo,343
32
32
  pytgcalls/methods/stream/mute_stream.py,sha256=auo2aAazfEC90Ab6MzaiPdddiJ1w4fN_9HaORkAeOBY,570
33
33
  pytgcalls/methods/stream/pause_stream.py,sha256=z_AIWABrQMHmTwvlah_PrH9EjXbro8gKxZni4Km5ICg,573
34
- pytgcalls/methods/stream/play.py,sha256=acuav8C9wEyur8FMAT7zFxkEvNDu45gnodUmGFrfIKA,7376
34
+ pytgcalls/methods/stream/play.py,sha256=wU4WKEp4cMfJPVDW-aug69HrzXrMJHCKkqrv-pCxQkg,7307
35
35
  pytgcalls/methods/stream/played_time.py,sha256=IkUdyHrqpzpRl9uf0uZhg1COo4zsHnQOPu3nipjVatI,570
36
36
  pytgcalls/methods/stream/resume_stream.py,sha256=z_DgP4cDExjEqEeX_ZL--50MXQ9lrATK876SIwE71PQ,576
37
37
  pytgcalls/methods/stream/unmute_stream.py,sha256=KUMhfMbhsPmZsmpF4cGWC1FVW7YwXha2MmQnqrBhM8s,576
38
38
  pytgcalls/methods/utilities/__init__.py,sha256=JcKwqNo6fFXXfuab94fNEraKF1P9fnSSgr0WQDRjF2w,339
39
39
  pytgcalls/methods/utilities/cache_peer.py,sha256=Ylt0wCCJOoNKf1wZEXjfE8aBZKUIIgdRUFOMTGA5DfE,140
40
- pytgcalls/methods/utilities/call_holder.py,sha256=RZ9DFhZO66ghtGqxLbYS86hq2UCjTzTiN_xzL5bgD-M,903
40
+ pytgcalls/methods/utilities/call_holder.py,sha256=MQxAYL3fDDWhf3UFRyLhJD_FVYOeWUNkr8pAII46htQ,972
41
41
  pytgcalls/methods/utilities/compose.py,sha256=Nzdv8orMmka5NIBZ1SW1nsqXRzArZl4m6FdZU7syaR4,334
42
42
  pytgcalls/methods/utilities/cpu_usage.py,sha256=Mbga4MFCIwuh7WC8sqBbv1Pa6ALcp5AIDyfYMH_Bix4,162
43
- pytgcalls/methods/utilities/idle.py,sha256=lkjbYzpU7iz-maE0kS6RVtHJ4h1PsmGqnZmaENGIKeE,768
43
+ pytgcalls/methods/utilities/idle.py,sha256=MDdzHTv1ws2yBhsvhBUnssGdghkZ2KwR0HUCPOwV38o,814
44
44
  pytgcalls/methods/utilities/ping.py,sha256=hhIMSHk2BzMB-IKpwLdZFVrsEvGm2ftJwKLs1k4anh8,244
45
45
  pytgcalls/methods/utilities/resolve_chat_id.py,sha256=92x2LHbUlnJMm-kS3fXOYmzYpY2TZbqtQD2rw3eBXDY,382
46
46
  pytgcalls/methods/utilities/run.py,sha256=cnYQd2xB5Cr_WS0Q2cXJZPGiN6JOCULzj1r4xXVyrlg,152
47
- pytgcalls/methods/utilities/start.py,sha256=qhFiuVdkUnyTNMaoSQGwn5XFZrirKRkBphFeHrzHmo8,8498
47
+ pytgcalls/methods/utilities/start.py,sha256=yPCb8wQ-0I-5HjY_uC0DNqnPOa64hTWP4lkcAqG4rbc,8924
48
48
  pytgcalls/methods/utilities/stream_params.py,sha256=hYcNxx__McmPeHgOUDEuNcN7ThgDjukejQYHrfmWm-A,1519
49
49
  pytgcalls/mtproto/__init__.py,sha256=X4zvzFG7km7qHyE0fdvA550WcOVO_xl_p__gvIfDGmw,130
50
50
  pytgcalls/mtproto/bridged_client.py,sha256=kK22n-CKjtfmtNE6bXCpuL6kWAUK2_Ul7cGgx_HNuHQ,4975
51
- pytgcalls/mtproto/client_cache.py,sha256=LYjmvhgaaEyczoJFZ35vGXFlN4ADwXYvt1bhrVS4ipw,5088
52
- pytgcalls/mtproto/hydrogram_client.py,sha256=TgItS6KKPJna1yIXJ7iXflfRWRpPvMXHoRKzo6q09lE,21014
53
- pytgcalls/mtproto/mtproto_client.py,sha256=rqsUOE7llTXSAru9GfBMhUKufEgWQL65QLHRj4TEfgw,6884
54
- pytgcalls/mtproto/pyrogram_client.py,sha256=cNaQu00rZTFVTj3CE2V_eL5yT1XcGwkgwcGfb6aa53s,21203
55
- pytgcalls/mtproto/telethon_client.py,sha256=GFZ0LM8PXRVXwJfYV_gVVZ_qjEmWCJD_nmqiPE8oCCo,20105
56
- pytgcalls/types/__init__.py,sha256=JTMTa2flwWkBSEjhAAXE0oL4IJFRb12XU0npp9Neypc,1071
51
+ pytgcalls/mtproto/client_cache.py,sha256=1yA5CFAmWZUsWdpqk5vlaN3j1RV1rIN-X7EcqmsnlfY,5087
52
+ pytgcalls/mtproto/hydrogram_client.py,sha256=iSqwvK8yZZCYMmFQOSXpcDwZOFrBGt-3vJUMyxar-Sc,21116
53
+ pytgcalls/mtproto/mtproto_client.py,sha256=LO71RqgxZ3bYxSFb6l9cc4ks6_peyqHN4i_z478c7yw,6883
54
+ pytgcalls/mtproto/pyrogram_client.py,sha256=iyJMJo6iTULfmGh-jdfJgu8DNVFxzOn28A5_E7uH4-Q,21305
55
+ pytgcalls/mtproto/telethon_client.py,sha256=8BkYncXnPUIJRgrhUBnMIlXV2_fm6vLkN8URVaSuow4,20207
56
+ pytgcalls/types/__init__.py,sha256=yJVJZoH9M9u9VgpZGUX-MF4NzE-vKp4KrId21YQbcGE,910
57
57
  pytgcalls/types/browsers.py,sha256=47Kr5q96n4Q4WvVhA6IUlS2egEcA9GRLlDeFcQYyc9M,9545
58
58
  pytgcalls/types/cache.py,sha256=FfsOcmYnsBGPlJoTPIXXYcUSpGE3rhx6cjIH77hyUL0,1059
59
+ pytgcalls/types/dict.py,sha256=lAo9hu4VlVJa9S7P8Y81BYmKtvz0rH7hwpGcH3ynHUw,78
59
60
  pytgcalls/types/list.py,sha256=UjP_XxxMpPkLlu6yEy29JYqOM5VITFwwJcDm0wZni1c,78
60
- pytgcalls/types/participant_list.py,sha256=-thRoLgnsTW9ujPHNEwrWgOY8GRwsl_k99DslsHLDQ0,879
61
+ pytgcalls/types/participant_list.py,sha256=LmGjU63MK1v3SS2_4xNbk04OOjmukNdAXYLRn2L-730,916
61
62
  pytgcalls/types/py_object.py,sha256=VlazuMP0cFpExKimW8BtWR66LDewnNdQSLC7r_t7JIM,842
62
63
  pytgcalls/types/update.py,sha256=wPCzWLhrsScZ3ksRTyt8IuDaaG5YI-ItG_Yw-OqzK2Y,157
63
64
  pytgcalls/types/user_agent.py,sha256=sSfeGqUe0v0wqBgdVszNFK0iOC_0Tdyto9CglBXlY4U,1086
64
65
  pytgcalls/types/calls/__init__.py,sha256=6O2wp7I3d2YGLNeMgXTRyG37Y6BESafneLdr9n37_4s,346
65
- pytgcalls/types/calls/call.py,sha256=On9NXxExNCH9I4YrEuTKQUDT6BlAKKl551dYOIlseeo,761
66
+ pytgcalls/types/calls/call.py,sha256=JX05F5iD0kMuYOugpuCCilqtP-PEJp2MY3a_wWumtls,725
66
67
  pytgcalls/types/calls/call_config.py,sha256=b6P43YTGF2t7E2CyD1mSYPJDUBvYYeHoxB3hSbTVyOY,120
67
- pytgcalls/types/calls/call_data.py,sha256=uKs-tbFdGnwMSw30je6yI7efe2KdXGC7gYKi7q27GtA,530
68
+ pytgcalls/types/calls/call_data.py,sha256=-qPj2QhWv32Xs7LyFQY4hiWDqJ21B8VBvdzREK8bDvY,544
68
69
  pytgcalls/types/calls/call_protocol.py,sha256=OVIQs1VgdY-DWbZbNr41hjLA4pGQvHx8Rgom1_NhJxQ,408
69
70
  pytgcalls/types/calls/group_call_config.py,sha256=auKH-hZJWj8PhTkyeQ_VK2z9NpNvNC7Scl_IhEUMnQM,353
70
- pytgcalls/types/calls/raw_call_update.py,sha256=pRiqpQfZha57SCQADk58WT4UHfp_smK71r05mmgmDbU,795
71
- pytgcalls/types/groups/__init__.py,sha256=S2bwXC6BA-NfCyDOoMqkd6YivFRJcy6hX5-EClpu1ms,463
72
- pytgcalls/types/groups/chat_update.py,sha256=U_8YSMdrx10ARormhwdbnZt-GQ1rjlLOKK4Vog9duCg,738
73
- pytgcalls/types/groups/group_call_participant.py,sha256=9HTC0Bw0AGU_MgThk3ieQSdfJGHDJZ5uU_SpOxvLr9U,757
74
- pytgcalls/types/groups/joined_group_call_participant.py,sha256=FRI0J9FEBacs4JoioXfQtYyKSP_z_lezxNW0p-tWyeA,291
75
- pytgcalls/types/groups/left_group_call_participant.py,sha256=9J-lVyA_u11VFLO3vW7bTWKE6pBkL3BXzqsVWAkVRzM,289
76
- pytgcalls/types/groups/updated_group_call_participant.py,sha256=ZZ-VqFYAvGCF3oBFW2kroCyanvAt6o-iJkizwdwoLe8,292
71
+ pytgcalls/types/calls/raw_call_update.py,sha256=hpNw6HrTW8Z36Lh2HinS-wzprryRtsIxyIFbIfjGgeI,795
72
+ pytgcalls/types/chats/__init__.py,sha256=v8pUp_vbr2kQpyHtAQc80N-YqzmXHe9SbllUsa6njkU,261
73
+ pytgcalls/types/chats/chat_update.py,sha256=U_8YSMdrx10ARormhwdbnZt-GQ1rjlLOKK4Vog9duCg,738
74
+ pytgcalls/types/chats/group_call_participant.py,sha256=G5PEQjemkz8YFXaRuG_Q91QfGGixAKPT75nFDiAbYPY,1018
75
+ pytgcalls/types/chats/updated_group_call_participant.py,sha256=-KID-z-4e43fhYWQp0pNMKPfmZizbJHXyzn6yLtIGNg,291
77
76
  pytgcalls/types/raw/__init__.py,sha256=ROHsKFeUMUtlFbx2rhfrdB-TuVm0zBuvNo29Ccn5614,308
78
77
  pytgcalls/types/raw/audio_parameters.py,sha256=1DsBPwdn_Ukd2Tbkb3whP_ILo9xJY_3XNNmbO4_NO9Q,449
79
78
  pytgcalls/types/raw/audio_stream.py,sha256=wEMa93hHt0VBUSuS6gPJlFIGZp5GdNU94O2C2u4AXnY,476
@@ -86,8 +85,8 @@ pytgcalls/types/stream/media_stream.py,sha256=vH32FrwdMSA9-S54bvessVHewh_l-5WXqu
86
85
  pytgcalls/types/stream/stream_audio_ended.py,sha256=2_EFa98F0vWu0d0jBmLtzp4NH_xBkDO_6yP9UtyKuCs,164
87
86
  pytgcalls/types/stream/stream_video_ended.py,sha256=9YFTTZPMDpB95eb815rGtgDrzBGfTeazJ5mZwP6Hvks,164
88
87
  pytgcalls/types/stream/video_quality.py,sha256=HBfWq005kh-D19MaVE9VzVdnODzrXf4IJUimCfslfiU,231
89
- py_tgcalls-2.0.0rc6.dist-info/LICENSE,sha256=46mU2C5kSwOnkqkw9XQAJlhBL2JAf1_uCD8lVcXyMRg,7652
90
- py_tgcalls-2.0.0rc6.dist-info/METADATA,sha256=0rWEYipuPX9YXcaO_Q2qmINeiYELecuBJAbDrbcYw8A,4886
91
- py_tgcalls-2.0.0rc6.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
92
- py_tgcalls-2.0.0rc6.dist-info/top_level.txt,sha256=IUDUwn0KkcbUYZbCe9R5AUb2Ob-lmllNUGQqyeXXd8A,10
93
- py_tgcalls-2.0.0rc6.dist-info/RECORD,,
88
+ py_tgcalls-2.0.1.dist-info/LICENSE,sha256=46mU2C5kSwOnkqkw9XQAJlhBL2JAf1_uCD8lVcXyMRg,7652
89
+ py_tgcalls-2.0.1.dist-info/METADATA,sha256=i2DwDASj0BIS6txxb8o3zDrnOgZs74v7LTZD4y0qzcU,14357
90
+ py_tgcalls-2.0.1.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
91
+ py_tgcalls-2.0.1.dist-info/top_level.txt,sha256=IUDUwn0KkcbUYZbCe9R5AUb2Ob-lmllNUGQqyeXXd8A,10
92
+ py_tgcalls-2.0.1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.37.1)
2
+ Generator: bdist_wheel (0.43.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
pytgcalls/__version__.py CHANGED
@@ -1 +1 @@
1
- __version__ = '2.0.0rc6'
1
+ __version__ = '2.0.1'
pytgcalls/ffmpeg.py CHANGED
@@ -48,12 +48,10 @@ async def check_stream(
48
48
  except FileNotFoundError:
49
49
  raise FFmpegError('ffprobe not installed')
50
50
 
51
- stream_list = []
52
- format_content = []
53
51
  try:
54
52
  stdout, stderr = await asyncio.wait_for(
55
53
  ffprobe.communicate(),
56
- timeout=30,
54
+ timeout=20,
57
55
  )
58
56
  result = loads(stdout.decode('utf-8')) or {}
59
57
  stream_list = result.get('streams', [])
@@ -61,7 +59,8 @@ async def check_stream(
61
59
  if 'No such file' in stderr.decode('utf-8'):
62
60
  raise FileNotFoundError()
63
61
  except (subprocess.TimeoutExpired, JSONDecodeError):
64
- pass
62
+ ffprobe.terminate()
63
+ raise
65
64
 
66
65
  have_video = False
67
66
  is_image = False
@@ -127,15 +126,15 @@ async def cleanup_commands(
127
126
  stdout=asyncio.subprocess.PIPE,
128
127
  stderr=asyncio.subprocess.PIPE,
129
128
  )
130
- result = ''
131
129
  try:
132
130
  stdout, _ = await asyncio.wait_for(
133
131
  proc_res.communicate(),
134
- timeout=30,
132
+ timeout=20,
135
133
  )
136
134
  result = stdout.decode('utf-8')
137
135
  except (subprocess.TimeoutExpired, JSONDecodeError):
138
- pass
136
+ proc_res.terminate()
137
+ raise
139
138
  supported = re.findall(r'(?m)^ *(-.*?)\s+', result)
140
139
  new_commands = []
141
140
  ignore_next = False
pytgcalls/filters.py CHANGED
@@ -7,6 +7,7 @@ from typing import Union
7
7
  from .mtproto import BridgedClient
8
8
  from .pytgcalls import PyTgCalls
9
9
  from .types import ChatUpdate
10
+ from .types import GroupCallParticipant
10
11
  from .types import StreamAudioEnded
11
12
  from .types import StreamVideoEnded
12
13
  from .types import Update
@@ -138,7 +139,7 @@ async def _stream_filter(_, __, u: Update):
138
139
  return isinstance(u, (StreamVideoEnded, StreamAudioEnded))
139
140
 
140
141
 
141
- stream = create(_stream_filter)
142
+ stream_end = create(_stream_filter)
142
143
 
143
144
 
144
145
  # noinspection PyPep8Naming
@@ -167,3 +168,15 @@ class chat_update(Filter):
167
168
  if isinstance(update, ChatUpdate):
168
169
  return self.flags & update.status
169
170
  return False
171
+
172
+
173
+ class call_participant(Filter):
174
+ def __init__(self, flags: Optional[GroupCallParticipant.Action] = None):
175
+ self.flags = flags
176
+
177
+ async def __call__(self, client: PyTgCalls, update: Update):
178
+ if isinstance(update, UpdatedGroupCallParticipant):
179
+ if self.flags is None:
180
+ return True
181
+ self.flags & update.participant.action
182
+ return False
@@ -5,7 +5,7 @@ from typing import Union
5
5
  from ...mtproto_required import mtproto_required
6
6
  from ...scaffold import Scaffold
7
7
  from ...statictypes import statictypes
8
- from ...types.groups import GroupCallParticipant
8
+ from ...types.chats import GroupCallParticipant
9
9
 
10
10
 
11
11
  class GetParticipants(Scaffold):
@@ -32,6 +32,10 @@ class LeaveCall(Scaffold):
32
32
  )
33
33
  else:
34
34
  await self._app.discard_call(chat_id)
35
+ if chat_id in self._p2p_configs and \
36
+ not self._p2p_configs[chat_id].outgoing:
37
+ self._p2p_configs.pop(chat_id)
38
+ return
35
39
  try:
36
40
  await self._binding.stop(chat_id)
37
41
  except ConnectionNotFound:
@@ -102,9 +102,7 @@ class Play(Scaffold):
102
102
  )
103
103
  data.g_a_or_b = await self._binding.create_p2p_call(
104
104
  chat_id,
105
- data.g,
106
- data.p,
107
- data.random,
105
+ data.dh_config,
108
106
  data.g_a_or_b,
109
107
  media_description,
110
108
  )
@@ -2,7 +2,7 @@ from ntgcalls import StreamStatus
2
2
 
3
3
  from ...scaffold import Scaffold
4
4
  from ...types import Call
5
- from ...types.list import List
5
+ from ...types.dict import Dict
6
6
 
7
7
 
8
8
  class CallHolder(Scaffold):
@@ -16,19 +16,22 @@ class CallHolder(Scaffold):
16
16
 
17
17
  @property
18
18
  async def calls(self):
19
- calls_list: dict = await self._binding.calls() # type: ignore
20
- return List([
21
- Call(x, self._conversions[calls_list[x]]) for x in calls_list
22
- ])
19
+ calls_list = await self._binding.calls()
20
+ return Dict({
21
+ x: Call(x, self._conversions[calls_list[x]])
22
+ for x in calls_list
23
+ })
23
24
 
24
25
  @property
25
26
  async def group_calls(self):
26
- return List([
27
- x for x in await self.calls if x.chat_id < 0
28
- ])
27
+ return Dict({
28
+ chat_id: x
29
+ for chat_id, x in (await self.calls).items() if chat_id < 0
30
+ })
29
31
 
30
32
  @property
31
33
  async def private_calls(self):
32
- return List([
33
- x for x in await self.calls if x.chat_id > 0
34
- ])
34
+ return Dict({
35
+ chat_id: x
36
+ for chat_id, x in (await self.calls).items() if chat_id > 0
37
+ })
@@ -20,8 +20,8 @@ async def idle():
20
20
  task = None
21
21
 
22
22
  def signal_handler(signum, __):
23
- py_logger.info(f"Stop signal received ({signals[signum]}). Exiting...")
24
- task.cancel()
23
+ py_logger.info(f'Stop signal received ({signals[signum]}). Exiting...')
24
+ asyncio.get_event_loop().run_in_executor(None, task.cancel)
25
25
 
26
26
  for s in (SIGINT, SIGTERM, SIGABRT):
27
27
  signal_fn(s, signal_handler)
@@ -1,9 +1,9 @@
1
1
  import asyncio
2
2
  import logging
3
3
 
4
+ from ntgcalls import ConnectionError
4
5
  from ntgcalls import ConnectionNotFound
5
6
  from ntgcalls import ConnectionState
6
- from ntgcalls import ConnectionError
7
7
  from ntgcalls import MediaState
8
8
  from ntgcalls import StreamType
9
9
  from ntgcalls import TelegramServerError
@@ -16,6 +16,7 @@ from ...pytgcalls_session import PyTgCallsSession
16
16
  from ...scaffold import Scaffold
17
17
  from ...types import CallData
18
18
  from ...types import ChatUpdate
19
+ from ...types import GroupCallParticipant
19
20
  from ...types import RawCallUpdate
20
21
  from ...types import StreamAudioEnded
21
22
  from ...types import StreamVideoEnded
@@ -32,15 +33,17 @@ class Start(Scaffold):
32
33
  async def update_handler(update: Update):
33
34
  chat_id = update.chat_id
34
35
  if update.chat_id in self._p2p_configs:
35
- if not self._p2p_configs[chat_id].wait_data.done():
36
+ p2p_config = self._p2p_configs[chat_id]
37
+ if not p2p_config.wait_data.done():
36
38
  if isinstance(update, RawCallUpdate):
37
39
  if update.status & RawCallUpdate.Type.UPDATED_CALL:
38
- self._p2p_configs[chat_id].wait_data.set_result(
40
+ p2p_config.wait_data.set_result(
39
41
  update,
40
42
  )
41
- if isinstance(update, ChatUpdate):
43
+ if isinstance(update, ChatUpdate) and \
44
+ p2p_config.outgoing:
42
45
  if update.status & ChatUpdate.Status.DISCARDED_CALL:
43
- self._p2p_configs[chat_id].wait_data.set_exception(
46
+ p2p_config.wait_data.set_exception(
44
47
  CallDeclined(
45
48
  chat_id,
46
49
  ),
@@ -67,27 +70,32 @@ class Start(Scaffold):
67
70
  )
68
71
  if isinstance(update, RawCallUpdate):
69
72
  if update.status & RawCallUpdate.Type.SIGNALING_DATA:
70
- await self._binding.send_signaling(
71
- update.chat_id,
72
- update.signaling_data,
73
- )
73
+ try:
74
+ await self._binding.send_signaling(
75
+ update.chat_id,
76
+ update.signaling_data,
77
+ )
78
+ except (ConnectionNotFound, ConnectionError):
79
+ pass
74
80
  if isinstance(update, ChatUpdate):
75
81
  if update.status & ChatUpdate.Status.LEFT_CALL:
76
82
  await clear_call(chat_id)
77
83
  if isinstance(update, UpdatedGroupCallParticipant):
78
84
  participant = update.participant
85
+ action = participant.action
79
86
  chat_peer = self._cache_user_peer.get(chat_id)
80
87
  if chat_peer:
81
88
  is_self = BridgedClient.chat_id(
82
89
  chat_peer,
83
90
  ) == participant.user_id if chat_peer else False
84
91
  if is_self:
85
- if participant.left:
92
+ if action == GroupCallParticipant.Action.LEFT:
86
93
  await clear_call(chat_id)
87
- if chat_id in self._need_unmute and \
88
- not participant.joined and \
89
- not participant.left and \
90
- not participant.muted_by_admin:
94
+ if (
95
+ chat_id in self._need_unmute and
96
+ action == GroupCallParticipant.Action.UPDATED and
97
+ not participant.muted_by_admin
98
+ ):
91
99
  try:
92
100
  await update_status(
93
101
  chat_id,
@@ -96,7 +104,10 @@ class Start(Scaffold):
96
104
  except ConnectionNotFound:
97
105
  pass
98
106
 
99
- if participant.muted_by_admin and not participant.left:
107
+ if (
108
+ participant.muted_by_admin and
109
+ action != GroupCallParticipant.Action.LEFT
110
+ ):
100
111
  self._need_unmute.add(chat_id)
101
112
  else:
102
113
  self._need_unmute.discard(chat_id)
@@ -155,12 +166,12 @@ class Start(Scaffold):
155
166
  self._wait_connect[chat_id].set_exception(
156
167
  TelegramServerError(),
157
168
  )
158
- await clear_call(chat_id)
169
+ await clear_cache(chat_id)
159
170
 
160
171
  if state != ConnectionState.CONNECTED:
161
172
  if chat_id > 0:
162
173
  await self._app.discard_call(chat_id)
163
- await clear_call(chat_id)
174
+ await clear_cache(chat_id)
164
175
 
165
176
  async def clear_cache(chat_id: int):
166
177
  self._p2p_configs.pop(chat_id, None)
@@ -5,7 +5,7 @@ from typing import List
5
5
  from typing import Optional
6
6
 
7
7
  from ..types import Cache
8
- from ..types.groups import GroupCallParticipant
8
+ from ..types.chats import GroupCallParticipant
9
9
  from ..types.participant_list import ParticipantList
10
10
  from .bridged_client import BridgedClient
11
11
 
@@ -84,13 +84,15 @@ class HydrogramClient(BridgedClient):
84
84
  update,
85
85
  UpdatePhoneCallSignalingData,
86
86
  ):
87
- await self.propagate(
88
- RawCallUpdate(
89
- self._cache.get_user_id(update.phone_call_id),
90
- RawCallUpdate.Type.SIGNALING_DATA,
91
- signaling_data=update.data,
92
- ),
93
- )
87
+ user_id = self._cache.get_user_id(update.phone_call_id)
88
+ if user_id is not None:
89
+ await self.propagate(
90
+ RawCallUpdate(
91
+ user_id,
92
+ RawCallUpdate.Type.SIGNALING_DATA,
93
+ signaling_data=update.data,
94
+ ),
95
+ )
94
96
 
95
97
  if isinstance(
96
98
  update,
@@ -6,7 +6,7 @@ from typing import Optional
6
6
  from ntgcalls import Protocol
7
7
 
8
8
  from ..exceptions import InvalidMTProtoClient
9
- from ..types.groups import GroupCallParticipant
9
+ from ..types.chats import GroupCallParticipant
10
10
  from .bridged_client import BridgedClient
11
11
 
12
12
 
@@ -92,13 +92,15 @@ class PyrogramClient(BridgedClient):
92
92
  update,
93
93
  UpdatePhoneCallSignalingData,
94
94
  ):
95
- await self.propagate(
96
- RawCallUpdate(
97
- self._cache.get_user_id(update.phone_call_id),
98
- RawCallUpdate.Type.SIGNALING_DATA,
99
- signaling_data=update.data,
100
- ),
101
- )
95
+ user_id = self._cache.get_user_id(update.phone_call_id)
96
+ if user_id is not None:
97
+ await self.propagate(
98
+ RawCallUpdate(
99
+ user_id,
100
+ RawCallUpdate.Type.SIGNALING_DATA,
101
+ signaling_data=update.data,
102
+ ),
103
+ )
102
104
 
103
105
  if isinstance(
104
106
  update,
@@ -82,13 +82,15 @@ class TelethonClient(BridgedClient):
82
82
  update,
83
83
  UpdatePhoneCallSignalingData,
84
84
  ):
85
- await self.propagate(
86
- RawCallUpdate(
87
- self._cache.get_user_id(update.phone_call_id),
88
- RawCallUpdate.Type.SIGNALING_DATA,
89
- signaling_data=update.data,
90
- ),
91
- )
85
+ user_id = self._cache.get_user_id(update.phone_call_id)
86
+ if user_id is not None:
87
+ await self.propagate(
88
+ RawCallUpdate(
89
+ user_id,
90
+ RawCallUpdate.Type.SIGNALING_DATA,
91
+ signaling_data=update.data,
92
+ ),
93
+ )
92
94
 
93
95
  if isinstance(
94
96
  update,
pytgcalls/mutex.py CHANGED
@@ -1,37 +1,10 @@
1
- import asyncio
2
- import logging
3
1
  from functools import wraps
4
- from inspect import signature
5
- from typing import Optional
6
2
 
7
3
 
8
4
  def mutex(func):
9
- sig = signature(func)
10
-
11
5
  @wraps(func)
12
6
  async def async_wrapper(*args, **kwargs):
13
7
  self = args[0]
14
- bound = sig.bind(*args, **kwargs)
15
-
16
- if 'chat_id' in bound.arguments:
17
- chat_id: Optional[int] = None
18
- try:
19
- chat_id = await self.resolve_chat_id(
20
- bound.arguments['chat_id'],
21
- )
22
- except Exception as e:
23
- logging.debug(
24
- 'Error occurred while resolving chat_id. Reason: ' +
25
- str(e),
26
- )
27
- if chat_id is not None:
28
- if chat_id not in self._lock:
29
- self._lock[chat_id] = asyncio.Lock()
30
- async with self._lock[chat_id]:
31
- try:
32
- return await func(*args, **kwargs)
33
- finally:
34
- self._lock.pop(chat_id, None)
35
-
36
- return await func(*args, **kwargs)
8
+ async with self._lock:
9
+ return await func(*args, **kwargs)
37
10
  return async_wrapper
pytgcalls/pytgcalls.py CHANGED
@@ -41,6 +41,7 @@ class PyTgCalls(Methods, Scaffold):
41
41
  self._binding = NTgCalls()
42
42
  self.loop = asyncio.get_event_loop()
43
43
  self.workers = workers
44
+ self._lock = asyncio.Lock()
44
45
  self.executor = ThreadPoolExecutor(
45
46
  self.workers,
46
47
  thread_name_prefix='Handler',
pytgcalls/scaffold.py CHANGED
@@ -21,7 +21,6 @@ class Scaffold(HandlersHolder):
21
21
  self._binding = None
22
22
  self.loop = None
23
23
  self._need_unmute = set()
24
- self._lock = dict()
25
24
  self._p2p_configs = dict()
26
25
  self._wait_connect = dict()
27
26
 
@@ -6,11 +6,9 @@ from .calls import CallData
6
6
  from .calls import CallProtocol
7
7
  from .calls import GroupCallConfig
8
8
  from .calls import RawCallUpdate
9
- from .groups import ChatUpdate
10
- from .groups import GroupCallParticipant
11
- from .groups import JoinedGroupCallParticipant
12
- from .groups import LeftGroupCallParticipant
13
- from .groups import UpdatedGroupCallParticipant
9
+ from .chats import ChatUpdate
10
+ from .chats import GroupCallParticipant
11
+ from .chats import UpdatedGroupCallParticipant
14
12
  from .stream import AudioQuality
15
13
  from .stream import MediaStream
16
14
  from .stream import StreamAudioEnded
@@ -30,8 +28,6 @@ __all__ = (
30
28
  'RawCallUpdate',
31
29
  'GroupCallConfig',
32
30
  'GroupCallParticipant',
33
- 'JoinedGroupCallParticipant',
34
- 'LeftGroupCallParticipant',
35
31
  'MediaStream',
36
32
  'StreamAudioEnded',
37
33
  'StreamVideoEnded',
@@ -27,7 +27,6 @@ class Call(PyObject):
27
27
  chat_id: int,
28
28
  status: Status,
29
29
  ):
30
- self.chat_id: int = chat_id
31
30
  self.call_type = Call.Type.GROUP \
32
31
  if chat_id < 0 else Call.Type.PRIVATE
33
32
  self.status = status
@@ -3,6 +3,8 @@ from asyncio import Future
3
3
  from typing import Any
4
4
  from typing import Optional
5
5
 
6
+ from ntgcalls import DhConfig
7
+
6
8
 
7
9
  class CallData:
8
10
  def __init__(
@@ -11,9 +13,9 @@ class CallData:
11
13
  loop: asyncio.AbstractEventLoop,
12
14
  g_a_hash: Optional[bytes] = None,
13
15
  ):
14
- self.g: bytes = dhc_config.g
15
- self.p: bytes = dhc_config.p
16
- self.random: bytes = dhc_config.random
16
+ self.dh_config = DhConfig(
17
+ dhc_config.g, dhc_config.p, dhc_config.random,
18
+ )
17
19
  self.g_a_or_b: Optional[bytes] = g_a_hash
18
20
  self.outgoing: bool = g_a_hash is None
19
21
  self.wait_data: Future = loop.create_future()
@@ -10,8 +10,8 @@ class RawCallUpdate(Update):
10
10
  ACCEPTED = auto()
11
11
  CONFIRMED = auto()
12
12
  REQUESTED = auto()
13
- UPDATED_CALL = ACCEPTED | CONFIRMED
14
13
  SIGNALING_DATA = auto()
14
+ UPDATED_CALL = ACCEPTED | CONFIRMED
15
15
 
16
16
  def __init__(
17
17
  self,
@@ -1,13 +1,9 @@
1
1
  from .chat_update import ChatUpdate
2
2
  from .group_call_participant import GroupCallParticipant
3
- from .joined_group_call_participant import JoinedGroupCallParticipant
4
- from .left_group_call_participant import LeftGroupCallParticipant
5
3
  from .updated_group_call_participant import UpdatedGroupCallParticipant
6
4
 
7
5
  __all__ = (
8
6
  'ChatUpdate',
9
7
  'GroupCallParticipant',
10
- 'JoinedGroupCallParticipant',
11
- 'LeftGroupCallParticipant',
12
8
  'UpdatedGroupCallParticipant',
13
9
  )
@@ -1,7 +1,15 @@
1
+ from enum import auto
2
+ from enum import Flag
3
+
1
4
  from ...types.py_object import PyObject
2
5
 
3
6
 
4
7
  class GroupCallParticipant(PyObject):
8
+ class Action(Flag):
9
+ JOINED = auto()
10
+ LEFT = auto()
11
+ UPDATED = auto()
12
+
5
13
  def __init__(
6
14
  self,
7
15
  user_id: int,
@@ -23,5 +31,9 @@ class GroupCallParticipant(PyObject):
23
31
  self.video_camera: bool = video_camera
24
32
  self.raised_hand: bool = raised_hand
25
33
  self.volume: int = volume
26
- self.joined: bool = joined
27
- self.left: bool = left
34
+ if joined:
35
+ self.action = self.Action.JOINED
36
+ elif left:
37
+ self.action = self.Action.LEFT
38
+ else:
39
+ self.action = self.Action.UPDATED
@@ -1,4 +1,4 @@
1
- from ..groups import GroupCallParticipant
1
+ from ..chats import GroupCallParticipant
2
2
  from ..update import Update
3
3
 
4
4
 
@@ -0,0 +1,5 @@
1
+ from ..types.py_object import PyObject
2
+
3
+
4
+ class Dict(dict, PyObject):
5
+ pass
@@ -1,6 +1,6 @@
1
1
  from typing import Dict
2
2
 
3
- from ..types.groups import GroupCallParticipant
3
+ from ..types.chats import GroupCallParticipant
4
4
  from ..types.list import List
5
5
 
6
6
 
@@ -17,7 +17,7 @@ class ParticipantList:
17
17
  self,
18
18
  participant: GroupCallParticipant,
19
19
  ):
20
- if participant.left:
20
+ if participant.action == GroupCallParticipant.Action.LEFT:
21
21
  if participant.user_id in self._list_participants:
22
22
  del self._list_participants[participant.user_id]
23
23
  else:
pytgcalls/ytdlp.py CHANGED
@@ -58,7 +58,14 @@ class YtDlp:
58
58
  stdout=asyncio.subprocess.PIPE,
59
59
  stderr=asyncio.subprocess.PIPE,
60
60
  )
61
- stdout, stderr = await proc.communicate()
61
+ try:
62
+ stdout, stderr = await asyncio.wait_for(
63
+ proc.communicate(),
64
+ 20,
65
+ )
66
+ except asyncio.TimeoutError:
67
+ proc.terminate()
68
+ raise YtDlpError('yt-dlp process timeout')
62
69
  if stderr:
63
70
  raise YtDlpError(stderr.decode())
64
71
  data = stdout.decode().strip().split('\n')
@@ -1,128 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: py-tgcalls
3
- Version: 2.0.0rc6
4
- Summary: UNKNOWN
5
- Home-page: https://github.com/pytgcalls/pytgcalls
6
- Author: Laky-64
7
- Author-email: iraci.matteo@gmail.com
8
- License: LGPL-3.0
9
- Platform: UNKNOWN
10
- Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)
11
- Classifier: Operating System :: OS Independent
12
- Classifier: Programming Language :: Python :: 3
13
- Classifier: Programming Language :: Python :: 3 :: Only
14
- Classifier: Programming Language :: Python :: 3.8
15
- Classifier: Programming Language :: Python :: 3.9
16
- Classifier: Programming Language :: Python :: 3.10
17
- Classifier: Programming Language :: Python :: 3.11
18
- Classifier: Programming Language :: Python :: 3.12
19
- Classifier: Programming Language :: Python :: Implementation :: CPython
20
- Requires-Python: >=3.8
21
- Description-Content-Type: text/markdown
22
- License-File: LICENSE
23
- Requires-Dist: aiohttp (>=3.9.3)
24
- Requires-Dist: deprecation
25
- Requires-Dist: ntgcalls (>=1.2.0.b6)
26
- Requires-Dist: psutil
27
- Requires-Dist: screeninfo
28
- Requires-Dist: setuptools
29
-
30
- <img src="https://raw.githubusercontent.com/pytgcalls/pytgcalls/master/.github/images/banner.png" alt="pytgcalls logo" />
31
- <p align="center">
32
- <b>A simple and elegant client that allows you to make group voice calls quickly and easily.</b>
33
- <br>
34
- <a href="https://github.com/pytgcalls/pytgcalls/tree/master/example">
35
- Examples
36
- </a>
37
-
38
- <a href="https://pytgcalls.github.io/">
39
- Documentation
40
- </a>
41
-
42
- <a href="https://pypi.org/project/py-tgcalls/">
43
- PyPi
44
- </a>
45
-
46
- <a href="https://t.me/pytgcallsnews">
47
- Channel
48
- </a>
49
-
50
- <a href="https://t.me/pytgcallschat">
51
- Chat
52
- </a>
53
- </p>
54
-
55
- # PyTgCalls [![PyPI](https://img.shields.io/pypi/v/py-tgcalls.svg?logo=python&logoColor=%23959DA5&label=pypi&labelColor=%23282f37)](https://pypi.org/project/py-tgcalls/) [![Downloads](https://pepy.tech/badge/py-tgcalls)](https://pepy.tech/project/py-tgcalls)
56
- This project allows making Telegram group call using MtProto and WebRTC, this is possible thanks to the power of [NTgCalls] library and [@evgeny-nadymov]
57
-
58
- #### Example Usage
59
- ```python
60
- from pytgcalls import PyTgCalls
61
- from pytgcalls import idle
62
- from pytgcalls.types import MediaStream
63
- ...
64
- chat_id = -1001185324811
65
- app = PyTgCalls(client)
66
- app.start()
67
- app.join_group_call(
68
- chat_id,
69
- MediaStream(
70
- 'http://docs.evostream.com/sample_content/assets/sintel1m720p.mp4',
71
- )
72
- )
73
- idle()
74
- ```
75
-
76
- ## Features
77
- - Prebuilt wheels for macOS, Linux and Windows.
78
- - Supporting all type of MTProto libraries: Pyrogram, Telethon and Hydrogram.
79
- - Work with voice chats in channels and chats.
80
- - Join as channels or chats.
81
- - Mute/unmute, pause/resume, stop/play, volume control and more...
82
-
83
- ## Requirements
84
- - Python 3.7 or higher.
85
- - An MTProto Client
86
- - A [Telegram API key](https://docs.pyrogram.org/intro/setup#api-keys).
87
-
88
- ## How to install?
89
- Here's how to install the PyTgCalls lib, the commands are given below:
90
-
91
- ``` bash
92
- # With Git
93
- pip install git+https://github.com/pytgcalls/pytgcalls -U
94
-
95
- # With PyPi (Recommended)
96
- pip install py-tgcalls -U
97
- ```
98
-
99
- ## Key Contributors
100
- * <b><a href="https://github.com/Laky-64">@Laky-64</a> (DevOps Engineer, Software Architect):</b>
101
- * Played a crucial role in developing PyTgCalls being an ex developer of pyservercall and of tgcallsjs.
102
- * Automation with GitHub Actions
103
- * <b><a href="https://github.com/kuogi">@kuogi</a> (Senior UI/UX designer, Documenter):</b>
104
- * As a Senior UI/UX Designer, Kuogi has significantly improved the user interface of our documentation,
105
- making it more visually appealing and user-friendly.
106
- * Played a key role in writing and structuring our documentation, ensuring that it is clear,
107
- informative, and accessible to all users.
108
- * <b><a href="https://github.com/vrumger">@vrumger</a> (Senior Node.js Developer, Software Architect):</b>
109
- * Has made important fixes and enhancements to the WebRTC component of the library,
110
- improving its stability and performance.
111
- * Main developer of TgCallsJS
112
- * <b><a href="https://github.com/alemidev">@alemidev</a> (Senior Python Developer):</b>
113
- * Has made important fixes and enhancements to the async part of the library
114
-
115
- ## Junior Developers
116
- * <b><a href="https://github.com/TuriOG">@TuriOG</a> (Junior Python Developer):</b>
117
- * Currently working on integrating NTgCalls into <a href="//github.com/pytgcalls/pytgcalls">PyTgCalls</a>, an important step
118
- in expanding the functionality and usability of the library.
119
-
120
- ## Special Thanks
121
- * <b><a href="https://github.com/evgeny-nadymov">@evgeny-nadymov</a>:</b>
122
- A heartfelt thank you to Evgeny Nadymov for graciously allowing us to use their code from telegram-react.
123
- His contribution has been pivotal to the success of this project.
124
-
125
- [NTgCalls]: https://github.com/pytgcalls/ntgcalls
126
- [@evgeny-nadymov]: https://github.com/evgeny-nadymov/
127
-
128
-
@@ -1,12 +0,0 @@
1
- from ..groups import GroupCallParticipant
2
- from ..update import Update
3
-
4
-
5
- class JoinedGroupCallParticipant(Update):
6
- def __init__(
7
- self,
8
- chat_id: int,
9
- participant: GroupCallParticipant,
10
- ):
11
- super().__init__(chat_id)
12
- self.participant = participant
@@ -1,12 +0,0 @@
1
- from ..groups import GroupCallParticipant
2
- from ..update import Update
3
-
4
-
5
- class LeftGroupCallParticipant(Update):
6
- def __init__(
7
- self,
8
- chat_id: int,
9
- participant: GroupCallParticipant,
10
- ):
11
- super().__init__(chat_id)
12
- self.participant = participant
File without changes