spluspy 1.0.0__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 (156) hide show
  1. spluspy/__init__.py +20 -0
  2. spluspy/_updates/__init__.py +3 -0
  3. spluspy/_updates/entitycache.py +59 -0
  4. spluspy/_updates/messagebox.py +826 -0
  5. spluspy/_updates/session.py +195 -0
  6. spluspy/client/__init__.py +25 -0
  7. spluspy/client/account.py +243 -0
  8. spluspy/client/auth.py +721 -0
  9. spluspy/client/bots.py +72 -0
  10. spluspy/client/buttons.py +101 -0
  11. spluspy/client/chats.py +1336 -0
  12. spluspy/client/dialogs.py +606 -0
  13. spluspy/client/downloads.py +1092 -0
  14. spluspy/client/messageparse.py +233 -0
  15. spluspy/client/messages.py +1524 -0
  16. spluspy/client/soroushclient.py +19 -0
  17. spluspy/client/telegrambaseclient.py +1015 -0
  18. spluspy/client/updates.py +719 -0
  19. spluspy/client/uploads.py +867 -0
  20. spluspy/client/users.py +623 -0
  21. spluspy/crypto/__init__.py +10 -0
  22. spluspy/crypto/aes.py +111 -0
  23. spluspy/crypto/aesctr.py +42 -0
  24. spluspy/crypto/authkey.py +63 -0
  25. spluspy/crypto/cdndecrypter.py +109 -0
  26. spluspy/crypto/factorization.py +67 -0
  27. spluspy/crypto/libssl.py +138 -0
  28. spluspy/crypto/rsa.py +268 -0
  29. spluspy/custom.py +1 -0
  30. spluspy/errors/__init__.py +46 -0
  31. spluspy/errors/common.py +180 -0
  32. spluspy/errors/rpcbaseerrors.py +135 -0
  33. spluspy/errors/rpcerrorlist.py +5356 -0
  34. spluspy/events/__init__.py +140 -0
  35. spluspy/events/album.py +343 -0
  36. spluspy/events/callbackquery.py +345 -0
  37. spluspy/events/chataction.py +458 -0
  38. spluspy/events/common.py +186 -0
  39. spluspy/events/inlinequery.py +247 -0
  40. spluspy/events/messagedeleted.py +57 -0
  41. spluspy/events/messageedited.py +52 -0
  42. spluspy/events/messageread.py +143 -0
  43. spluspy/events/newmessage.py +223 -0
  44. spluspy/events/raw.py +53 -0
  45. spluspy/events/userupdate.py +310 -0
  46. spluspy/extensions/__init__.py +6 -0
  47. spluspy/extensions/binaryreader.py +207 -0
  48. spluspy/extensions/html.py +203 -0
  49. spluspy/extensions/markdown.py +193 -0
  50. spluspy/extensions/messagepacker.py +122 -0
  51. spluspy/functions.py +1 -0
  52. spluspy/helpers.py +434 -0
  53. spluspy/hints.py +72 -0
  54. spluspy/network/__init__.py +14 -0
  55. spluspy/network/authenticator.py +212 -0
  56. spluspy/network/connection/__init__.py +13 -0
  57. spluspy/network/connection/connection.py +455 -0
  58. spluspy/network/connection/http.py +39 -0
  59. spluspy/network/connection/tcpabridged.py +33 -0
  60. spluspy/network/connection/tcpfull.py +58 -0
  61. spluspy/network/connection/tcpintermediate.py +46 -0
  62. spluspy/network/connection/tcpmtproxy.py +165 -0
  63. spluspy/network/connection/tcpobfuscated.py +62 -0
  64. spluspy/network/connection/websocket.py +275 -0
  65. spluspy/network/mtprotoplainsender.py +56 -0
  66. spluspy/network/mtprotosender.py +932 -0
  67. spluspy/network/mtprotostate.py +285 -0
  68. spluspy/network/requeststate.py +19 -0
  69. spluspy/password.py +194 -0
  70. spluspy/requestiter.py +134 -0
  71. spluspy/sessions/__init__.py +4 -0
  72. spluspy/sessions/abstract.py +172 -0
  73. spluspy/sessions/memory.py +263 -0
  74. spluspy/sessions/sqlite.py +388 -0
  75. spluspy/sessions/string.py +75 -0
  76. spluspy/sync.py +74 -0
  77. spluspy/tl/__init__.py +1 -0
  78. spluspy/tl/alltlobjects.py +1696 -0
  79. spluspy/tl/core/__init__.py +26 -0
  80. spluspy/tl/core/gzippacked.py +48 -0
  81. spluspy/tl/core/messagecontainer.py +47 -0
  82. spluspy/tl/core/rpcresult.py +35 -0
  83. spluspy/tl/core/tlmessage.py +34 -0
  84. spluspy/tl/custom/__init__.py +14 -0
  85. spluspy/tl/custom/adminlogevent.py +475 -0
  86. spluspy/tl/custom/button.py +346 -0
  87. spluspy/tl/custom/chatgetter.py +150 -0
  88. spluspy/tl/custom/conversation.py +529 -0
  89. spluspy/tl/custom/dialog.py +161 -0
  90. spluspy/tl/custom/draft.py +191 -0
  91. spluspy/tl/custom/file.py +146 -0
  92. spluspy/tl/custom/forward.py +51 -0
  93. spluspy/tl/custom/inlinebuilder.py +450 -0
  94. spluspy/tl/custom/inlineresult.py +176 -0
  95. spluspy/tl/custom/inlineresults.py +83 -0
  96. spluspy/tl/custom/inputsizedfile.py +9 -0
  97. spluspy/tl/custom/message.py +1243 -0
  98. spluspy/tl/custom/messagebutton.py +154 -0
  99. spluspy/tl/custom/participantpermissions.py +138 -0
  100. spluspy/tl/custom/qrlogin.py +119 -0
  101. spluspy/tl/custom/sendergetter.py +102 -0
  102. spluspy/tl/custom/types.py +38 -0
  103. spluspy/tl/functions/__init__.py +452 -0
  104. spluspy/tl/functions/account.py +1581 -0
  105. spluspy/tl/functions/auth.py +593 -0
  106. spluspy/tl/functions/bots.py +112 -0
  107. spluspy/tl/functions/channels.py +1672 -0
  108. spluspy/tl/functions/chatlists.py +325 -0
  109. spluspy/tl/functions/conference.py +437 -0
  110. spluspy/tl/functions/contacts.py +476 -0
  111. spluspy/tl/functions/folders.py +44 -0
  112. spluspy/tl/functions/help.py +259 -0
  113. spluspy/tl/functions/langpack.py +146 -0
  114. spluspy/tl/functions/messages.py +5469 -0
  115. spluspy/tl/functions/payments.py +292 -0
  116. spluspy/tl/functions/phone.py +809 -0
  117. spluspy/tl/functions/photos.py +282 -0
  118. spluspy/tl/functions/premium.py +152 -0
  119. spluspy/tl/functions/stats.py +300 -0
  120. spluspy/tl/functions/stories.py +765 -0
  121. spluspy/tl/functions/thirdParty.py +67 -0
  122. spluspy/tl/functions/updates.py +139 -0
  123. spluspy/tl/functions/upload.py +168 -0
  124. spluspy/tl/functions/users.py +170 -0
  125. spluspy/tl/patched/__init__.py +20 -0
  126. spluspy/tl/tlobject.py +222 -0
  127. spluspy/tl/types/__init__.py +40015 -0
  128. spluspy/tl/types/account.py +1096 -0
  129. spluspy/tl/types/auth.py +809 -0
  130. spluspy/tl/types/bots.py +43 -0
  131. spluspy/tl/types/channels.py +232 -0
  132. spluspy/tl/types/chatlists.py +273 -0
  133. spluspy/tl/types/conference.py +69 -0
  134. spluspy/tl/types/contacts.py +478 -0
  135. spluspy/tl/types/help.py +1206 -0
  136. spluspy/tl/types/messages.py +3000 -0
  137. spluspy/tl/types/payments.py +633 -0
  138. spluspy/tl/types/phone.py +313 -0
  139. spluspy/tl/types/photos.py +135 -0
  140. spluspy/tl/types/premium.py +209 -0
  141. spluspy/tl/types/stats.py +368 -0
  142. spluspy/tl/types/stickers.py +35 -0
  143. spluspy/tl/types/storage.py +197 -0
  144. spluspy/tl/types/stories.py +317 -0
  145. spluspy/tl/types/thirdParty.py +94 -0
  146. spluspy/tl/types/update.py +39 -0
  147. spluspy/tl/types/updates.py +447 -0
  148. spluspy/tl/types/upload.py +196 -0
  149. spluspy/tl/types/users.py +131 -0
  150. spluspy/types.py +1 -0
  151. spluspy/utils.py +1593 -0
  152. spluspy/version.py +3 -0
  153. spluspy-1.0.0.dist-info/METADATA +86 -0
  154. spluspy-1.0.0.dist-info/RECORD +156 -0
  155. spluspy-1.0.0.dist-info/WHEEL +5 -0
  156. spluspy-1.0.0.dist-info/top_level.txt +1 -0
spluspy/__init__.py ADDED
@@ -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,3 @@
1
+ from .entitycache import EntityCache
2
+ from .messagebox import MessageBox, GapError, PrematureEndReason
3
+ from .session import SessionState, ChannelState, Entity, EntityType
@@ -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)