spluspy 1.0.0__tar.gz
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.
- spluspy-1.0.0/PKG-INFO +86 -0
- spluspy-1.0.0/README.rst +48 -0
- spluspy-1.0.0/setup.cfg +4 -0
- spluspy-1.0.0/setup.py +264 -0
- spluspy-1.0.0/spluspy/__init__.py +20 -0
- spluspy-1.0.0/spluspy/_updates/__init__.py +3 -0
- spluspy-1.0.0/spluspy/_updates/entitycache.py +59 -0
- spluspy-1.0.0/spluspy/_updates/messagebox.py +826 -0
- spluspy-1.0.0/spluspy/_updates/session.py +195 -0
- spluspy-1.0.0/spluspy/client/__init__.py +25 -0
- spluspy-1.0.0/spluspy/client/account.py +243 -0
- spluspy-1.0.0/spluspy/client/auth.py +721 -0
- spluspy-1.0.0/spluspy/client/bots.py +72 -0
- spluspy-1.0.0/spluspy/client/buttons.py +101 -0
- spluspy-1.0.0/spluspy/client/chats.py +1336 -0
- spluspy-1.0.0/spluspy/client/dialogs.py +606 -0
- spluspy-1.0.0/spluspy/client/downloads.py +1092 -0
- spluspy-1.0.0/spluspy/client/messageparse.py +233 -0
- spluspy-1.0.0/spluspy/client/messages.py +1524 -0
- spluspy-1.0.0/spluspy/client/soroushclient.py +19 -0
- spluspy-1.0.0/spluspy/client/telegrambaseclient.py +1015 -0
- spluspy-1.0.0/spluspy/client/updates.py +719 -0
- spluspy-1.0.0/spluspy/client/uploads.py +867 -0
- spluspy-1.0.0/spluspy/client/users.py +623 -0
- spluspy-1.0.0/spluspy/crypto/__init__.py +10 -0
- spluspy-1.0.0/spluspy/crypto/aes.py +111 -0
- spluspy-1.0.0/spluspy/crypto/aesctr.py +42 -0
- spluspy-1.0.0/spluspy/crypto/authkey.py +63 -0
- spluspy-1.0.0/spluspy/crypto/cdndecrypter.py +109 -0
- spluspy-1.0.0/spluspy/crypto/factorization.py +67 -0
- spluspy-1.0.0/spluspy/crypto/libssl.py +138 -0
- spluspy-1.0.0/spluspy/crypto/rsa.py +268 -0
- spluspy-1.0.0/spluspy/custom.py +1 -0
- spluspy-1.0.0/spluspy/errors/__init__.py +46 -0
- spluspy-1.0.0/spluspy/errors/common.py +180 -0
- spluspy-1.0.0/spluspy/errors/rpcbaseerrors.py +135 -0
- spluspy-1.0.0/spluspy/errors/rpcerrorlist.py +5356 -0
- spluspy-1.0.0/spluspy/events/__init__.py +140 -0
- spluspy-1.0.0/spluspy/events/album.py +343 -0
- spluspy-1.0.0/spluspy/events/callbackquery.py +345 -0
- spluspy-1.0.0/spluspy/events/chataction.py +458 -0
- spluspy-1.0.0/spluspy/events/common.py +186 -0
- spluspy-1.0.0/spluspy/events/inlinequery.py +247 -0
- spluspy-1.0.0/spluspy/events/messagedeleted.py +57 -0
- spluspy-1.0.0/spluspy/events/messageedited.py +52 -0
- spluspy-1.0.0/spluspy/events/messageread.py +143 -0
- spluspy-1.0.0/spluspy/events/newmessage.py +223 -0
- spluspy-1.0.0/spluspy/events/raw.py +53 -0
- spluspy-1.0.0/spluspy/events/userupdate.py +310 -0
- spluspy-1.0.0/spluspy/extensions/__init__.py +6 -0
- spluspy-1.0.0/spluspy/extensions/binaryreader.py +207 -0
- spluspy-1.0.0/spluspy/extensions/html.py +203 -0
- spluspy-1.0.0/spluspy/extensions/markdown.py +193 -0
- spluspy-1.0.0/spluspy/extensions/messagepacker.py +122 -0
- spluspy-1.0.0/spluspy/functions.py +1 -0
- spluspy-1.0.0/spluspy/helpers.py +434 -0
- spluspy-1.0.0/spluspy/hints.py +72 -0
- spluspy-1.0.0/spluspy/network/__init__.py +14 -0
- spluspy-1.0.0/spluspy/network/authenticator.py +212 -0
- spluspy-1.0.0/spluspy/network/connection/__init__.py +13 -0
- spluspy-1.0.0/spluspy/network/connection/connection.py +455 -0
- spluspy-1.0.0/spluspy/network/connection/http.py +39 -0
- spluspy-1.0.0/spluspy/network/connection/tcpabridged.py +33 -0
- spluspy-1.0.0/spluspy/network/connection/tcpfull.py +58 -0
- spluspy-1.0.0/spluspy/network/connection/tcpintermediate.py +46 -0
- spluspy-1.0.0/spluspy/network/connection/tcpmtproxy.py +165 -0
- spluspy-1.0.0/spluspy/network/connection/tcpobfuscated.py +62 -0
- spluspy-1.0.0/spluspy/network/connection/websocket.py +275 -0
- spluspy-1.0.0/spluspy/network/mtprotoplainsender.py +56 -0
- spluspy-1.0.0/spluspy/network/mtprotosender.py +932 -0
- spluspy-1.0.0/spluspy/network/mtprotostate.py +285 -0
- spluspy-1.0.0/spluspy/network/requeststate.py +19 -0
- spluspy-1.0.0/spluspy/password.py +194 -0
- spluspy-1.0.0/spluspy/requestiter.py +134 -0
- spluspy-1.0.0/spluspy/sessions/__init__.py +4 -0
- spluspy-1.0.0/spluspy/sessions/abstract.py +172 -0
- spluspy-1.0.0/spluspy/sessions/memory.py +263 -0
- spluspy-1.0.0/spluspy/sessions/sqlite.py +388 -0
- spluspy-1.0.0/spluspy/sessions/string.py +75 -0
- spluspy-1.0.0/spluspy/sync.py +74 -0
- spluspy-1.0.0/spluspy/tl/__init__.py +1 -0
- spluspy-1.0.0/spluspy/tl/alltlobjects.py +1696 -0
- spluspy-1.0.0/spluspy/tl/core/__init__.py +26 -0
- spluspy-1.0.0/spluspy/tl/core/gzippacked.py +48 -0
- spluspy-1.0.0/spluspy/tl/core/messagecontainer.py +47 -0
- spluspy-1.0.0/spluspy/tl/core/rpcresult.py +35 -0
- spluspy-1.0.0/spluspy/tl/core/tlmessage.py +34 -0
- spluspy-1.0.0/spluspy/tl/custom/__init__.py +14 -0
- spluspy-1.0.0/spluspy/tl/custom/adminlogevent.py +475 -0
- spluspy-1.0.0/spluspy/tl/custom/button.py +346 -0
- spluspy-1.0.0/spluspy/tl/custom/chatgetter.py +150 -0
- spluspy-1.0.0/spluspy/tl/custom/conversation.py +529 -0
- spluspy-1.0.0/spluspy/tl/custom/dialog.py +161 -0
- spluspy-1.0.0/spluspy/tl/custom/draft.py +191 -0
- spluspy-1.0.0/spluspy/tl/custom/file.py +146 -0
- spluspy-1.0.0/spluspy/tl/custom/forward.py +51 -0
- spluspy-1.0.0/spluspy/tl/custom/inlinebuilder.py +450 -0
- spluspy-1.0.0/spluspy/tl/custom/inlineresult.py +176 -0
- spluspy-1.0.0/spluspy/tl/custom/inlineresults.py +83 -0
- spluspy-1.0.0/spluspy/tl/custom/inputsizedfile.py +9 -0
- spluspy-1.0.0/spluspy/tl/custom/message.py +1243 -0
- spluspy-1.0.0/spluspy/tl/custom/messagebutton.py +154 -0
- spluspy-1.0.0/spluspy/tl/custom/participantpermissions.py +138 -0
- spluspy-1.0.0/spluspy/tl/custom/qrlogin.py +119 -0
- spluspy-1.0.0/spluspy/tl/custom/sendergetter.py +102 -0
- spluspy-1.0.0/spluspy/tl/custom/types.py +38 -0
- spluspy-1.0.0/spluspy/tl/functions/__init__.py +452 -0
- spluspy-1.0.0/spluspy/tl/functions/account.py +1581 -0
- spluspy-1.0.0/spluspy/tl/functions/auth.py +593 -0
- spluspy-1.0.0/spluspy/tl/functions/bots.py +112 -0
- spluspy-1.0.0/spluspy/tl/functions/channels.py +1672 -0
- spluspy-1.0.0/spluspy/tl/functions/chatlists.py +325 -0
- spluspy-1.0.0/spluspy/tl/functions/conference.py +437 -0
- spluspy-1.0.0/spluspy/tl/functions/contacts.py +476 -0
- spluspy-1.0.0/spluspy/tl/functions/folders.py +44 -0
- spluspy-1.0.0/spluspy/tl/functions/help.py +259 -0
- spluspy-1.0.0/spluspy/tl/functions/langpack.py +146 -0
- spluspy-1.0.0/spluspy/tl/functions/messages.py +5469 -0
- spluspy-1.0.0/spluspy/tl/functions/payments.py +292 -0
- spluspy-1.0.0/spluspy/tl/functions/phone.py +809 -0
- spluspy-1.0.0/spluspy/tl/functions/photos.py +282 -0
- spluspy-1.0.0/spluspy/tl/functions/premium.py +152 -0
- spluspy-1.0.0/spluspy/tl/functions/stats.py +300 -0
- spluspy-1.0.0/spluspy/tl/functions/stories.py +765 -0
- spluspy-1.0.0/spluspy/tl/functions/thirdParty.py +67 -0
- spluspy-1.0.0/spluspy/tl/functions/updates.py +139 -0
- spluspy-1.0.0/spluspy/tl/functions/upload.py +168 -0
- spluspy-1.0.0/spluspy/tl/functions/users.py +170 -0
- spluspy-1.0.0/spluspy/tl/patched/__init__.py +20 -0
- spluspy-1.0.0/spluspy/tl/tlobject.py +222 -0
- spluspy-1.0.0/spluspy/tl/types/__init__.py +40015 -0
- spluspy-1.0.0/spluspy/tl/types/account.py +1096 -0
- spluspy-1.0.0/spluspy/tl/types/auth.py +809 -0
- spluspy-1.0.0/spluspy/tl/types/bots.py +43 -0
- spluspy-1.0.0/spluspy/tl/types/channels.py +232 -0
- spluspy-1.0.0/spluspy/tl/types/chatlists.py +273 -0
- spluspy-1.0.0/spluspy/tl/types/conference.py +69 -0
- spluspy-1.0.0/spluspy/tl/types/contacts.py +478 -0
- spluspy-1.0.0/spluspy/tl/types/help.py +1206 -0
- spluspy-1.0.0/spluspy/tl/types/messages.py +3000 -0
- spluspy-1.0.0/spluspy/tl/types/payments.py +633 -0
- spluspy-1.0.0/spluspy/tl/types/phone.py +313 -0
- spluspy-1.0.0/spluspy/tl/types/photos.py +135 -0
- spluspy-1.0.0/spluspy/tl/types/premium.py +209 -0
- spluspy-1.0.0/spluspy/tl/types/stats.py +368 -0
- spluspy-1.0.0/spluspy/tl/types/stickers.py +35 -0
- spluspy-1.0.0/spluspy/tl/types/storage.py +197 -0
- spluspy-1.0.0/spluspy/tl/types/stories.py +317 -0
- spluspy-1.0.0/spluspy/tl/types/thirdParty.py +94 -0
- spluspy-1.0.0/spluspy/tl/types/update.py +39 -0
- spluspy-1.0.0/spluspy/tl/types/updates.py +447 -0
- spluspy-1.0.0/spluspy/tl/types/upload.py +196 -0
- spluspy-1.0.0/spluspy/tl/types/users.py +131 -0
- spluspy-1.0.0/spluspy/types.py +1 -0
- spluspy-1.0.0/spluspy/utils.py +1593 -0
- spluspy-1.0.0/spluspy/version.py +3 -0
- spluspy-1.0.0/spluspy.egg-info/PKG-INFO +86 -0
- spluspy-1.0.0/spluspy.egg-info/SOURCES.txt +159 -0
- spluspy-1.0.0/spluspy.egg-info/dependency_links.txt +1 -0
- spluspy-1.0.0/spluspy.egg-info/requires.txt +6 -0
- spluspy-1.0.0/spluspy.egg-info/top_level.txt +1 -0
spluspy-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: spluspy
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Soroush Plus library for Python
|
|
5
|
+
Home-page: https://github.com/Itskillmaster/spluspy
|
|
6
|
+
Download-URL: https://github.com/Itskillmaster/spluspy/releases
|
|
7
|
+
Author: AliMirshekari And Soroush Fathi
|
|
8
|
+
Author-email: dramff1@gmail.com
|
|
9
|
+
License: GPL-3.0
|
|
10
|
+
Keywords: telegram api chat client library messaging mtproto
|
|
11
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Topic :: Communications :: Chat
|
|
14
|
+
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.5
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.6
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
20
|
+
Requires-Python: >=3.5
|
|
21
|
+
Requires-Dist: pyaes
|
|
22
|
+
Requires-Dist: rsa
|
|
23
|
+
Requires-Dist: websockets
|
|
24
|
+
Provides-Extra: cryptg
|
|
25
|
+
Requires-Dist: cryptg; extra == "cryptg"
|
|
26
|
+
Dynamic: author
|
|
27
|
+
Dynamic: author-email
|
|
28
|
+
Dynamic: classifier
|
|
29
|
+
Dynamic: description
|
|
30
|
+
Dynamic: download-url
|
|
31
|
+
Dynamic: home-page
|
|
32
|
+
Dynamic: keywords
|
|
33
|
+
Dynamic: license
|
|
34
|
+
Dynamic: provides-extra
|
|
35
|
+
Dynamic: requires-dist
|
|
36
|
+
Dynamic: requires-python
|
|
37
|
+
Dynamic: summary
|
|
38
|
+
|
|
39
|
+
SPlusPy
|
|
40
|
+
=========
|
|
41
|
+
|
|
42
|
+
**SPlusPy** is an asyncio Python 3 MTProto library to interact with
|
|
43
|
+
`Soroush Plus <https://web.splus.ir>`_'s API as a user or through a
|
|
44
|
+
bot account (bot API alternative).
|
|
45
|
+
|
|
46
|
+
SPlusthon is a fork of Telethon adapted to work with the Soroush Plus
|
|
47
|
+
messenger. It uses Soroush-specific TL schema (layer 182), DC routing,
|
|
48
|
+
RSA keys, and WebSocket transport.
|
|
49
|
+
|
|
50
|
+
.. note::
|
|
51
|
+
|
|
52
|
+
As with any third-party library for Soroush Plus, be careful not to
|
|
53
|
+
break Soroush Plus's Terms of Service or risk an account ban.
|
|
54
|
+
|
|
55
|
+
What is this?
|
|
56
|
+
-------------
|
|
57
|
+
|
|
58
|
+
Soroush Plus is a popular messaging application. This library is meant
|
|
59
|
+
to make it easy for you to write Python programs that can interact
|
|
60
|
+
with Soroush Plus. Think of it as a wrapper that has already done the
|
|
61
|
+
heavy job for you, so you can focus on developing an application.
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
Installing
|
|
65
|
+
----------
|
|
66
|
+
|
|
67
|
+
.. code-block:: sh
|
|
68
|
+
|
|
69
|
+
pip3 install splusthon
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
Creating a client
|
|
73
|
+
-----------------
|
|
74
|
+
|
|
75
|
+
SPlusthon includes default API credentials for Soroush Plus, so you
|
|
76
|
+
can create a client without obtaining your own keys:
|
|
77
|
+
|
|
78
|
+
.. code-block:: python
|
|
79
|
+
|
|
80
|
+
from splusthon import SoroushClient, events, sync
|
|
81
|
+
from splusthon.sessions import StringSession
|
|
82
|
+
|
|
83
|
+
# No api_id or api_hash needed - defaults are included
|
|
84
|
+
client = SoroushClient(StringSession())
|
|
85
|
+
client.start()
|
|
86
|
+
|
spluspy-1.0.0/README.rst
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
SPlusPy
|
|
2
|
+
=========
|
|
3
|
+
|
|
4
|
+
**SPlusPy** is an asyncio Python 3 MTProto library to interact with
|
|
5
|
+
`Soroush Plus <https://web.splus.ir>`_'s API as a user or through a
|
|
6
|
+
bot account (bot API alternative).
|
|
7
|
+
|
|
8
|
+
SPlusthon is a fork of Telethon adapted to work with the Soroush Plus
|
|
9
|
+
messenger. It uses Soroush-specific TL schema (layer 182), DC routing,
|
|
10
|
+
RSA keys, and WebSocket transport.
|
|
11
|
+
|
|
12
|
+
.. note::
|
|
13
|
+
|
|
14
|
+
As with any third-party library for Soroush Plus, be careful not to
|
|
15
|
+
break Soroush Plus's Terms of Service or risk an account ban.
|
|
16
|
+
|
|
17
|
+
What is this?
|
|
18
|
+
-------------
|
|
19
|
+
|
|
20
|
+
Soroush Plus is a popular messaging application. This library is meant
|
|
21
|
+
to make it easy for you to write Python programs that can interact
|
|
22
|
+
with Soroush Plus. Think of it as a wrapper that has already done the
|
|
23
|
+
heavy job for you, so you can focus on developing an application.
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
Installing
|
|
27
|
+
----------
|
|
28
|
+
|
|
29
|
+
.. code-block:: sh
|
|
30
|
+
|
|
31
|
+
pip3 install splusthon
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
Creating a client
|
|
35
|
+
-----------------
|
|
36
|
+
|
|
37
|
+
SPlusthon includes default API credentials for Soroush Plus, so you
|
|
38
|
+
can create a client without obtaining your own keys:
|
|
39
|
+
|
|
40
|
+
.. code-block:: python
|
|
41
|
+
|
|
42
|
+
from splusthon import SoroushClient, events, sync
|
|
43
|
+
from splusthon.sessions import StringSession
|
|
44
|
+
|
|
45
|
+
# No api_id or api_hash needed - defaults are included
|
|
46
|
+
client = SoroushClient(StringSession())
|
|
47
|
+
client.start()
|
|
48
|
+
|
spluspy-1.0.0/setup.cfg
ADDED
spluspy-1.0.0/setup.py
ADDED
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""A setuptools based setup module.
|
|
3
|
+
|
|
4
|
+
See:
|
|
5
|
+
https://packaging.python.org/en/latest/distributing.html
|
|
6
|
+
https://github.com/pypa/sampleproject
|
|
7
|
+
|
|
8
|
+
Extra supported commands are:
|
|
9
|
+
* gen, to generate the classes required for spluspy to run or docs
|
|
10
|
+
* pypi, to generate sdist, bdist_wheel, and push to PyPi
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
import itertools
|
|
14
|
+
import json
|
|
15
|
+
import os
|
|
16
|
+
import re
|
|
17
|
+
import shutil
|
|
18
|
+
import sys
|
|
19
|
+
import urllib.request
|
|
20
|
+
from pathlib import Path
|
|
21
|
+
from subprocess import run
|
|
22
|
+
|
|
23
|
+
from setuptools import find_packages, setup
|
|
24
|
+
|
|
25
|
+
# Needed since we're importing local files
|
|
26
|
+
sys.path.insert(0, os.path.dirname(__file__))
|
|
27
|
+
|
|
28
|
+
class TempWorkDir:
|
|
29
|
+
"""Switches the working directory to be the one on which this file lives,
|
|
30
|
+
while within the 'with' block.
|
|
31
|
+
"""
|
|
32
|
+
def __init__(self, new=None):
|
|
33
|
+
self.original = None
|
|
34
|
+
self.new = new or str(Path(__file__).parent.resolve())
|
|
35
|
+
|
|
36
|
+
def __enter__(self):
|
|
37
|
+
# os.chdir does not work with Path in Python 3.5.x
|
|
38
|
+
self.original = str(Path('.').resolve())
|
|
39
|
+
os.makedirs(self.new, exist_ok=True)
|
|
40
|
+
os.chdir(self.new)
|
|
41
|
+
return self
|
|
42
|
+
|
|
43
|
+
def __exit__(self, *args):
|
|
44
|
+
os.chdir(self.original)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
API_REF_URL = 'https://tl.spluspy.dev/'
|
|
48
|
+
|
|
49
|
+
GENERATOR_DIR = Path('spluspy_generator')
|
|
50
|
+
LIBRARY_DIR = Path('spluspy')
|
|
51
|
+
|
|
52
|
+
ERRORS_IN = GENERATOR_DIR / 'data/errors.csv'
|
|
53
|
+
ERRORS_OUT = LIBRARY_DIR / 'errors/rpcerrorlist.py'
|
|
54
|
+
|
|
55
|
+
METHODS_IN = GENERATOR_DIR / 'data/methods.csv'
|
|
56
|
+
|
|
57
|
+
# Which raw API methods are covered by *friendly* methods in the client?
|
|
58
|
+
FRIENDLY_IN = GENERATOR_DIR / 'data/friendly.csv'
|
|
59
|
+
|
|
60
|
+
TLOBJECT_IN_TLS = [Path(x) for x in GENERATOR_DIR.glob('data/*.tl')]
|
|
61
|
+
TLOBJECT_OUT = LIBRARY_DIR / 'tl'
|
|
62
|
+
IMPORT_DEPTH = 2
|
|
63
|
+
|
|
64
|
+
DOCS_IN_RES = GENERATOR_DIR / 'data/html'
|
|
65
|
+
DOCS_OUT = Path('docs')
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def generate(which, action='gen'):
|
|
69
|
+
from spluspy_generator.parsers import\
|
|
70
|
+
parse_errors, parse_methods, parse_tl, find_layer
|
|
71
|
+
|
|
72
|
+
from spluspy_generator.generators import\
|
|
73
|
+
generate_errors, generate_tlobjects, generate_docs, clean_tlobjects
|
|
74
|
+
|
|
75
|
+
layer = next(filter(None, map(find_layer, TLOBJECT_IN_TLS)))
|
|
76
|
+
errors = list(parse_errors(ERRORS_IN))
|
|
77
|
+
methods = list(parse_methods(METHODS_IN, FRIENDLY_IN, {e.str_code: e for e in errors}))
|
|
78
|
+
|
|
79
|
+
tlobjects = list(itertools.chain(*(
|
|
80
|
+
parse_tl(file, layer, methods) for file in TLOBJECT_IN_TLS)))
|
|
81
|
+
|
|
82
|
+
if not which:
|
|
83
|
+
which.extend(('tl', 'errors'))
|
|
84
|
+
|
|
85
|
+
clean = action == 'clean'
|
|
86
|
+
action = 'Cleaning' if clean else 'Generating'
|
|
87
|
+
|
|
88
|
+
if 'all' in which:
|
|
89
|
+
which.remove('all')
|
|
90
|
+
for x in ('tl', 'errors', 'docs'):
|
|
91
|
+
if x not in which:
|
|
92
|
+
which.append(x)
|
|
93
|
+
|
|
94
|
+
if 'tl' in which:
|
|
95
|
+
which.remove('tl')
|
|
96
|
+
print(action, 'TLObjects...')
|
|
97
|
+
if clean:
|
|
98
|
+
clean_tlobjects(TLOBJECT_OUT)
|
|
99
|
+
else:
|
|
100
|
+
generate_tlobjects(tlobjects, layer, IMPORT_DEPTH, TLOBJECT_OUT)
|
|
101
|
+
|
|
102
|
+
if 'errors' in which:
|
|
103
|
+
which.remove('errors')
|
|
104
|
+
print(action, 'RPCErrors...')
|
|
105
|
+
if clean:
|
|
106
|
+
if ERRORS_OUT.is_file():
|
|
107
|
+
ERRORS_OUT.unlink()
|
|
108
|
+
else:
|
|
109
|
+
with ERRORS_OUT.open('w') as file:
|
|
110
|
+
generate_errors(errors, file)
|
|
111
|
+
|
|
112
|
+
if 'docs' in which:
|
|
113
|
+
which.remove('docs')
|
|
114
|
+
print(action, 'documentation...')
|
|
115
|
+
if clean:
|
|
116
|
+
if DOCS_OUT.is_dir():
|
|
117
|
+
shutil.rmtree(str(DOCS_OUT))
|
|
118
|
+
else:
|
|
119
|
+
in_path = DOCS_IN_RES.resolve()
|
|
120
|
+
with TempWorkDir(DOCS_OUT):
|
|
121
|
+
generate_docs(tlobjects, methods, layer, in_path)
|
|
122
|
+
|
|
123
|
+
if 'json' in which:
|
|
124
|
+
which.remove('json')
|
|
125
|
+
print(action, 'JSON schema...')
|
|
126
|
+
json_files = [x.with_suffix('.json') for x in TLOBJECT_IN_TLS]
|
|
127
|
+
if clean:
|
|
128
|
+
for file in json_files:
|
|
129
|
+
if file.is_file():
|
|
130
|
+
file.unlink()
|
|
131
|
+
else:
|
|
132
|
+
def gen_json(fin, fout):
|
|
133
|
+
meths = []
|
|
134
|
+
constructors = []
|
|
135
|
+
for tl in parse_tl(fin, layer):
|
|
136
|
+
if tl.is_function:
|
|
137
|
+
meths.append(tl.to_dict())
|
|
138
|
+
else:
|
|
139
|
+
constructors.append(tl.to_dict())
|
|
140
|
+
what = {'constructors': constructors, 'methods': meths}
|
|
141
|
+
with open(fout, 'w') as f:
|
|
142
|
+
json.dump(what, f, indent=2)
|
|
143
|
+
|
|
144
|
+
for fs in zip(TLOBJECT_IN_TLS, json_files):
|
|
145
|
+
gen_json(*fs)
|
|
146
|
+
|
|
147
|
+
if which:
|
|
148
|
+
print(
|
|
149
|
+
'The following items were not understood:', which,
|
|
150
|
+
'\n Consider using only "tl", "errors" and/or "docs".'
|
|
151
|
+
'\n Using only "clean" will clean them. "all" to act on all.'
|
|
152
|
+
'\n For instance "gen tl errors".'
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
def main(argv):
|
|
157
|
+
if len(argv) >= 2 and argv[1] in ('gen', 'clean'):
|
|
158
|
+
generate(argv[2:], argv[1])
|
|
159
|
+
|
|
160
|
+
elif len(argv) >= 2 and argv[1] == 'pypi':
|
|
161
|
+
# Make sure tl.spluspy.dev is up-to-date first
|
|
162
|
+
with urllib.request.urlopen(API_REF_URL) as resp:
|
|
163
|
+
html = resp.read()
|
|
164
|
+
m = re.search(br'layer\s+(\d+)', html)
|
|
165
|
+
if not m:
|
|
166
|
+
print('Failed to check that the API reference is up to date:', API_REF_URL)
|
|
167
|
+
return
|
|
168
|
+
|
|
169
|
+
from spluspy_generator.parsers import find_layer
|
|
170
|
+
layer = next(filter(None, map(find_layer, TLOBJECT_IN_TLS)))
|
|
171
|
+
published_layer = int(m[1])
|
|
172
|
+
if published_layer != layer:
|
|
173
|
+
print('Published layer', published_layer, 'does not match current layer', layer, '.')
|
|
174
|
+
print('Make sure to update the API reference site first:', API_REF_URL)
|
|
175
|
+
return
|
|
176
|
+
|
|
177
|
+
# (Re)generate the code to make sure we don't push without it
|
|
178
|
+
generate(['tl', 'errors'])
|
|
179
|
+
|
|
180
|
+
# Try importing the spluspy module to assert it has no errors
|
|
181
|
+
try:
|
|
182
|
+
import spluspy
|
|
183
|
+
except Exception as e:
|
|
184
|
+
print('Packaging for PyPi aborted, importing the module failed.')
|
|
185
|
+
print(e)
|
|
186
|
+
return
|
|
187
|
+
|
|
188
|
+
remove_dirs = ['__pycache__', 'build', 'dist', 'spluspy.egg-info']
|
|
189
|
+
for root, _dirs, _files in os.walk(LIBRARY_DIR, topdown=False):
|
|
190
|
+
# setuptools is including __pycache__ for some reason (#1605)
|
|
191
|
+
if root.endswith('/__pycache__'):
|
|
192
|
+
remove_dirs.append(root)
|
|
193
|
+
for x in remove_dirs:
|
|
194
|
+
shutil.rmtree(x, ignore_errors=True)
|
|
195
|
+
|
|
196
|
+
run('python3 setup.py sdist', shell=True)
|
|
197
|
+
run('python3 setup.py bdist_wheel', shell=True)
|
|
198
|
+
run('twine upload dist/*', shell=True)
|
|
199
|
+
for x in ('build', 'dist', 'spluspy.egg-info'):
|
|
200
|
+
shutil.rmtree(x, ignore_errors=True)
|
|
201
|
+
|
|
202
|
+
else:
|
|
203
|
+
# e.g. install from GitHub
|
|
204
|
+
if GENERATOR_DIR.is_dir():
|
|
205
|
+
generate(['tl', 'errors'])
|
|
206
|
+
|
|
207
|
+
# Get the long description from the README file
|
|
208
|
+
with open('README.rst', 'r', encoding='utf-8') as f:
|
|
209
|
+
long_description = f.read()
|
|
210
|
+
|
|
211
|
+
with open('spluspy/version.py', 'r', encoding='utf-8') as f:
|
|
212
|
+
version = re.search(r"^__version__\s*=\s*'(.*)'.*$",
|
|
213
|
+
f.read(), flags=re.MULTILINE).group(1)
|
|
214
|
+
setup(
|
|
215
|
+
name='spluspy',
|
|
216
|
+
version=version,
|
|
217
|
+
description="Soroush Plus library for Python",
|
|
218
|
+
long_description=long_description,
|
|
219
|
+
|
|
220
|
+
url='https://github.com/Itskillmaster/spluspy',
|
|
221
|
+
download_url='https://github.com/Itskillmaster/spluspy/releases',
|
|
222
|
+
|
|
223
|
+
author='AliMirshekari And Soroush Fathi',
|
|
224
|
+
author_email='dramff1@gmail.com',
|
|
225
|
+
|
|
226
|
+
license='GPL-3.0',
|
|
227
|
+
|
|
228
|
+
# See https://stackoverflow.com/a/40300957/4759433
|
|
229
|
+
# -> https://www.python.org/dev/peps/pep-0345/#requires-python
|
|
230
|
+
# -> http://setuptools.readthedocs.io/en/latest/setuptools.html
|
|
231
|
+
python_requires='>=3.5',
|
|
232
|
+
|
|
233
|
+
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
|
|
234
|
+
classifiers=[
|
|
235
|
+
# 3 - Alpha
|
|
236
|
+
# 4 - Beta
|
|
237
|
+
# 5 - Production/Stable
|
|
238
|
+
'Development Status :: 5 - Production/Stable',
|
|
239
|
+
|
|
240
|
+
'Intended Audience :: Developers',
|
|
241
|
+
'Topic :: Communications :: Chat',
|
|
242
|
+
|
|
243
|
+
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
|
|
244
|
+
|
|
245
|
+
'Programming Language :: Python :: 3',
|
|
246
|
+
'Programming Language :: Python :: 3.5',
|
|
247
|
+
'Programming Language :: Python :: 3.6',
|
|
248
|
+
'Programming Language :: Python :: 3.7',
|
|
249
|
+
'Programming Language :: Python :: 3.8',
|
|
250
|
+
],
|
|
251
|
+
keywords='telegram api chat client library messaging mtproto',
|
|
252
|
+
packages=find_packages(exclude=[
|
|
253
|
+
'spluspy_*', 'tests*'
|
|
254
|
+
]),
|
|
255
|
+
install_requires=['pyaes', 'rsa', 'websockets'],
|
|
256
|
+
extras_require={
|
|
257
|
+
'cryptg': ['cryptg']
|
|
258
|
+
}
|
|
259
|
+
)
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
if __name__ == '__main__':
|
|
263
|
+
with TempWorkDir():
|
|
264
|
+
main(sys.argv)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from .client.soroushclient import SoroushClient
|
|
2
|
+
from .network import connection
|
|
3
|
+
from .tl.custom import Button
|
|
4
|
+
from .tl import patched as _ # import for its side-effects
|
|
5
|
+
from . import version, events, utils, errors, types, functions, custom
|
|
6
|
+
from .sessions import Session, MemorySession, SQLiteSession, StringSession
|
|
7
|
+
from .tl.custom import Conversation, Message, Dialog, Forward, Draft
|
|
8
|
+
|
|
9
|
+
__version__ = version.__version__
|
|
10
|
+
|
|
11
|
+
# Convenience alias
|
|
12
|
+
Client = SoroushClient
|
|
13
|
+
|
|
14
|
+
__all__ = [
|
|
15
|
+
'Client', 'SoroushClient', 'Button',
|
|
16
|
+
'Session', 'MemorySession', 'SQLiteSession', 'StringSession',
|
|
17
|
+
'Conversation', 'Message', 'Dialog', 'Forward', 'Draft',
|
|
18
|
+
'types', 'functions', 'custom', 'errors',
|
|
19
|
+
'events', 'utils', 'connection'
|
|
20
|
+
]
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
from .session import EntityType, Entity
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
_sentinel = object()
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class EntityCache:
|
|
8
|
+
def __init__(
|
|
9
|
+
self,
|
|
10
|
+
hash_map: dict = _sentinel,
|
|
11
|
+
self_id: int = None,
|
|
12
|
+
self_bot: bool = None
|
|
13
|
+
):
|
|
14
|
+
self.hash_map = {} if hash_map is _sentinel else hash_map
|
|
15
|
+
self.self_id = self_id
|
|
16
|
+
self.self_bot = self_bot
|
|
17
|
+
|
|
18
|
+
def set_self_user(self, id, bot, hash):
|
|
19
|
+
self.self_id = id
|
|
20
|
+
self.self_bot = bot
|
|
21
|
+
if hash:
|
|
22
|
+
self.hash_map[id] = (hash, EntityType.BOT if bot else EntityType.USER)
|
|
23
|
+
|
|
24
|
+
def get(self, id):
|
|
25
|
+
try:
|
|
26
|
+
hash, ty = self.hash_map[id]
|
|
27
|
+
return Entity(ty, id, hash)
|
|
28
|
+
except KeyError:
|
|
29
|
+
return None
|
|
30
|
+
|
|
31
|
+
def extend(self, users, chats):
|
|
32
|
+
# See https://core.telegram.org/api/min for "issues" with "min constructors".
|
|
33
|
+
self.hash_map.update(
|
|
34
|
+
(u.id, (
|
|
35
|
+
u.access_hash,
|
|
36
|
+
EntityType.BOT if u.bot else EntityType.USER,
|
|
37
|
+
))
|
|
38
|
+
for u in users
|
|
39
|
+
if getattr(u, 'access_hash', None) and not u.min
|
|
40
|
+
)
|
|
41
|
+
self.hash_map.update(
|
|
42
|
+
(c.id, (
|
|
43
|
+
c.access_hash,
|
|
44
|
+
EntityType.MEGAGROUP if c.megagroup else (
|
|
45
|
+
EntityType.GIGAGROUP if getattr(c, 'gigagroup', None) else EntityType.CHANNEL
|
|
46
|
+
),
|
|
47
|
+
))
|
|
48
|
+
for c in chats
|
|
49
|
+
if getattr(c, 'access_hash', None) and not getattr(c, 'min', None)
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
def put(self, entity):
|
|
53
|
+
self.hash_map[entity.id] = (entity.hash, entity.ty)
|
|
54
|
+
|
|
55
|
+
def retain(self, filter):
|
|
56
|
+
self.hash_map = {k: v for k, v in self.hash_map.items() if filter(k)}
|
|
57
|
+
|
|
58
|
+
def __len__(self):
|
|
59
|
+
return len(self.hash_map)
|