PySPlusthon 0.5.3__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 (284) hide show
  1. PySPlusthon/__init__.py +3 -0
  2. PySPlusthon/client/__init__.py +1 -0
  3. PySPlusthon/client/attachments/__init__.py +29 -0
  4. PySPlusthon/client/attachments/get_file.py +22 -0
  5. PySPlusthon/client/attachments/send_animation.py +71 -0
  6. PySPlusthon/client/attachments/send_audio.py +54 -0
  7. PySPlusthon/client/attachments/send_contact.py +47 -0
  8. PySPlusthon/client/attachments/send_document.py +63 -0
  9. PySPlusthon/client/attachments/send_location.py +45 -0
  10. PySPlusthon/client/attachments/send_media_group.py +88 -0
  11. PySPlusthon/client/attachments/send_photo.py +67 -0
  12. PySPlusthon/client/attachments/send_sticker.py +51 -0
  13. PySPlusthon/client/attachments/send_video.py +56 -0
  14. PySPlusthon/client/attachments/send_voice.py +52 -0
  15. PySPlusthon/client/attachments/upload_file.py +82 -0
  16. PySPlusthon/client/chats/__init__.py +43 -0
  17. PySPlusthon/client/chats/ban_chat_member.py +24 -0
  18. PySPlusthon/client/chats/delete_chat_photo.py +32 -0
  19. PySPlusthon/client/chats/get_chat.py +69 -0
  20. PySPlusthon/client/chats/get_chat_administrators.py +18 -0
  21. PySPlusthon/client/chats/get_chat_history.py +39 -0
  22. PySPlusthon/client/chats/get_chat_member.py +16 -0
  23. PySPlusthon/client/chats/get_chat_members.py +29 -0
  24. PySPlusthon/client/chats/get_chat_members_count.py +21 -0
  25. PySPlusthon/client/chats/join_chat.py +31 -0
  26. PySPlusthon/client/chats/leave_chat.py +22 -0
  27. PySPlusthon/client/chats/pin_chat_message.py +31 -0
  28. PySPlusthon/client/chats/promote_chat_member.py +64 -0
  29. PySPlusthon/client/chats/restrict_chat_member.py +25 -0
  30. PySPlusthon/client/chats/set_chat_description.py +23 -0
  31. PySPlusthon/client/chats/set_chat_photo.py +33 -0
  32. PySPlusthon/client/chats/set_chat_title.py +23 -0
  33. PySPlusthon/client/chats/unban_chat_member.py +24 -0
  34. PySPlusthon/client/chats/unpin_all_chat_messages.py +38 -0
  35. PySPlusthon/client/chats/unpin_chat_message.py +33 -0
  36. PySPlusthon/client/client.py +223 -0
  37. PySPlusthon/client/invite_links/__init__.py +7 -0
  38. PySPlusthon/client/invite_links/create_chat_invite_link.py +14 -0
  39. PySPlusthon/client/invite_links/export_chat_invite_link.py +21 -0
  40. PySPlusthon/client/invite_links/revoke_chat_invite_link.py +23 -0
  41. PySPlusthon/client/messages/__init__.py +21 -0
  42. PySPlusthon/client/messages/answer_callback_query.py +12 -0
  43. PySPlusthon/client/messages/copy_message.py +43 -0
  44. PySPlusthon/client/messages/delete_message.py +29 -0
  45. PySPlusthon/client/messages/edit_message_caption.py +40 -0
  46. PySPlusthon/client/messages/edit_message_reply_markup.py +17 -0
  47. PySPlusthon/client/messages/edit_message_text.py +40 -0
  48. PySPlusthon/client/messages/forward_message.py +35 -0
  49. PySPlusthon/client/messages/send_message.py +39 -0
  50. PySPlusthon/client/stickers/__init__.py +9 -0
  51. PySPlusthon/client/stickers/add_sticker_to_set.py +15 -0
  52. PySPlusthon/client/stickers/create_new_sticker_set.py +16 -0
  53. PySPlusthon/client/stickers/delete_sticker_from_set.py +10 -0
  54. PySPlusthon/client/stickers/get_sticker_set.py +11 -0
  55. PySPlusthon/client/stickers/upload_sticker_file.py +16 -0
  56. PySPlusthon/client/updates/__init__.py +8 -0
  57. PySPlusthon/client/updates/delete_webhook.py +9 -0
  58. PySPlusthon/client/updates/get_updates.py +14 -0
  59. PySPlusthon/client/updates/get_webhook_info.py +10 -0
  60. PySPlusthon/client/updates/set_webhook.py +10 -0
  61. PySPlusthon/client/users/__init__.py +6 -0
  62. PySPlusthon/client/users/ask_review.py +14 -0
  63. PySPlusthon/client/users/get_me.py +16 -0
  64. PySPlusthon/conditions/__init__.py +43 -0
  65. PySPlusthon/conditions/all.py +6 -0
  66. PySPlusthon/conditions/animation.py +7 -0
  67. PySPlusthon/conditions/at_state.py +18 -0
  68. PySPlusthon/conditions/audio.py +7 -0
  69. PySPlusthon/conditions/author.py +13 -0
  70. PySPlusthon/conditions/caption.py +7 -0
  71. PySPlusthon/conditions/channel.py +11 -0
  72. PySPlusthon/conditions/channel_chat_created.py +7 -0
  73. PySPlusthon/conditions/chat.py +14 -0
  74. PySPlusthon/conditions/click.py +24 -0
  75. PySPlusthon/conditions/command.py +23 -0
  76. PySPlusthon/conditions/condition.py +88 -0
  77. PySPlusthon/conditions/contact.py +7 -0
  78. PySPlusthon/conditions/content.py +7 -0
  79. PySPlusthon/conditions/delete_chat_photo.py +7 -0
  80. PySPlusthon/conditions/document.py +7 -0
  81. PySPlusthon/conditions/entities.py +7 -0
  82. PySPlusthon/conditions/equals.py +14 -0
  83. PySPlusthon/conditions/forward.py +7 -0
  84. PySPlusthon/conditions/group.py +11 -0
  85. PySPlusthon/conditions/group_chat_created.py +7 -0
  86. PySPlusthon/conditions/is_admin.py +17 -0
  87. PySPlusthon/conditions/is_instance.py +10 -0
  88. PySPlusthon/conditions/is_joined.py +61 -0
  89. PySPlusthon/conditions/left_chat_member.py +7 -0
  90. PySPlusthon/conditions/location.py +7 -0
  91. PySPlusthon/conditions/media.py +7 -0
  92. PySPlusthon/conditions/media_group.py +7 -0
  93. PySPlusthon/conditions/new_chat_members.py +7 -0
  94. PySPlusthon/conditions/new_chat_photo.py +7 -0
  95. PySPlusthon/conditions/new_chat_title.py +7 -0
  96. PySPlusthon/conditions/number.py +12 -0
  97. PySPlusthon/conditions/photo.py +7 -0
  98. PySPlusthon/conditions/pinned_message.py +7 -0
  99. PySPlusthon/conditions/poll.py +7 -0
  100. PySPlusthon/conditions/private.py +11 -0
  101. PySPlusthon/conditions/regex.py +17 -0
  102. PySPlusthon/conditions/reply.py +7 -0
  103. PySPlusthon/conditions/sticker.py +7 -0
  104. PySPlusthon/conditions/supergroup_chat_created.py +7 -0
  105. PySPlusthon/conditions/text.py +7 -0
  106. PySPlusthon/conditions/video.py +7 -0
  107. PySPlusthon/conditions/voice.py +7 -0
  108. PySPlusthon/dispatcher/__init__.py +5 -0
  109. PySPlusthon/dispatcher/chain.py +165 -0
  110. PySPlusthon/dispatcher/dispatcher.py +124 -0
  111. PySPlusthon/dispatcher/logging_chain.py +36 -0
  112. PySPlusthon/dispatcher/monitoring_chain.py +19 -0
  113. PySPlusthon/dispatcher/printing_chain.py +21 -0
  114. PySPlusthon/enums/__init__.py +7 -0
  115. PySPlusthon/enums/chat_member_status.py +9 -0
  116. PySPlusthon/enums/chat_type.py +9 -0
  117. PySPlusthon/enums/message_media_type.py +16 -0
  118. PySPlusthon/enums/name_enum.py +13 -0
  119. PySPlusthon/enums/peer_type.py +8 -0
  120. PySPlusthon/enums/poll_type.py +8 -0
  121. PySPlusthon/enums/transaction_status.py +10 -0
  122. PySPlusthon/errors/__init__.py +11 -0
  123. PySPlusthon/errors/dispatching_errors/__init__.py +2 -0
  124. PySPlusthon/errors/dispatching_errors/break_dispatching.py +2 -0
  125. PySPlusthon/errors/dispatching_errors/continue_dispatching.py +2 -0
  126. PySPlusthon/errors/rpc_errors/__init__.py +8 -0
  127. PySPlusthon/errors/rpc_errors/bad_request_error.py +6 -0
  128. PySPlusthon/errors/rpc_errors/flood_error.py +6 -0
  129. PySPlusthon/errors/rpc_errors/forbidden_error.py +6 -0
  130. PySPlusthon/errors/rpc_errors/internal_error.py +6 -0
  131. PySPlusthon/errors/rpc_errors/not_found_error.py +6 -0
  132. PySPlusthon/errors/rpc_errors/rpc_error.py +23 -0
  133. PySPlusthon/errors/rpc_errors/too_many_requests.py +10 -0
  134. PySPlusthon/errors/rpc_errors/unauthorized_error.py +6 -0
  135. PySPlusthon/event_handlers/__init__.py +12 -0
  136. PySPlusthon/event_handlers/callback_query_handler.py +16 -0
  137. PySPlusthon/event_handlers/command_handler.py +46 -0
  138. PySPlusthon/event_handlers/connect_handler.py +19 -0
  139. PySPlusthon/event_handlers/disconnect_handler.py +18 -0
  140. PySPlusthon/event_handlers/edited_message_handler.py +16 -0
  141. PySPlusthon/event_handlers/error_handler.py +15 -0
  142. PySPlusthon/event_handlers/event_handler.py +53 -0
  143. PySPlusthon/event_handlers/initialize_handler.py +18 -0
  144. PySPlusthon/event_handlers/message_handler.py +16 -0
  145. PySPlusthon/event_handlers/shipping_query_handler.py +16 -0
  146. PySPlusthon/event_handlers/shutdown_handler.py +18 -0
  147. PySPlusthon/event_handlers/update_handler.py +16 -0
  148. PySPlusthon/network/__init__.py +1 -0
  149. PySPlusthon/network/httpconnection.py +74 -0
  150. PySPlusthon/objects/__init__.py +43 -0
  151. PySPlusthon/objects/animation.py +44 -0
  152. PySPlusthon/objects/audio.py +36 -0
  153. PySPlusthon/objects/callback_query.py +37 -0
  154. PySPlusthon/objects/chat.py +118 -0
  155. PySPlusthon/objects/chat_member.py +53 -0
  156. PySPlusthon/objects/chat_permissions.py +26 -0
  157. PySPlusthon/objects/chat_photo.py +24 -0
  158. PySPlusthon/objects/contact.py +18 -0
  159. PySPlusthon/objects/date.py +35 -0
  160. PySPlusthon/objects/document.py +36 -0
  161. PySPlusthon/objects/edited_message.py +27 -0
  162. PySPlusthon/objects/entity.py +21 -0
  163. PySPlusthon/objects/file.py +21 -0
  164. PySPlusthon/objects/forward_origin.py +22 -0
  165. PySPlusthon/objects/inline_keyboard.py +65 -0
  166. PySPlusthon/objects/inline_keyboard_button.py +30 -0
  167. PySPlusthon/objects/input_media.py +44 -0
  168. PySPlusthon/objects/input_media_photo.py +14 -0
  169. PySPlusthon/objects/input_media_video.py +14 -0
  170. PySPlusthon/objects/invite_link.py +32 -0
  171. PySPlusthon/objects/list.py +24 -0
  172. PySPlusthon/objects/location.py +14 -0
  173. PySPlusthon/objects/message.py +478 -0
  174. PySPlusthon/objects/message_id.py +31 -0
  175. PySPlusthon/objects/object.py +154 -0
  176. PySPlusthon/objects/order_info.py +19 -0
  177. PySPlusthon/objects/photo.py +31 -0
  178. PySPlusthon/objects/poll.py +34 -0
  179. PySPlusthon/objects/poll_option.py +16 -0
  180. PySPlusthon/objects/reply_keyboard.py +79 -0
  181. PySPlusthon/objects/reply_keyboard_button.py +27 -0
  182. PySPlusthon/objects/reply_keyboard_remove.py +10 -0
  183. PySPlusthon/objects/reply_markup.py +12 -0
  184. PySPlusthon/objects/shipping_address.py +22 -0
  185. PySPlusthon/objects/shipping_query.py +20 -0
  186. PySPlusthon/objects/sticker.py +54 -0
  187. PySPlusthon/objects/sticker_set.py +29 -0
  188. PySPlusthon/objects/transaction.py +25 -0
  189. PySPlusthon/objects/update.py +33 -0
  190. PySPlusthon/objects/user.py +60 -0
  191. PySPlusthon/objects/video.py +45 -0
  192. PySPlusthon/objects/voice.py +31 -0
  193. PySPlusthon/objects/webhook_info.py +16 -0
  194. PySPlusthon/proto/__init__.py +2 -0
  195. PySPlusthon/proto/enums_pb2.py +46 -0
  196. PySPlusthon/proto/enums_pb2.pyi +99 -0
  197. PySPlusthon/proto/enums_pb2_grpc.py +24 -0
  198. PySPlusthon/proto/requests/__init__.py +209 -0
  199. PySPlusthon/proto/requests/abacus_pb2.py +40 -0
  200. PySPlusthon/proto/requests/abacus_pb2.pyi +31 -0
  201. PySPlusthon/proto/requests/abacus_pb2_grpc.py +24 -0
  202. PySPlusthon/proto/requests/auth_pb2.py +49 -0
  203. PySPlusthon/proto/requests/auth_pb2.pyi +67 -0
  204. PySPlusthon/proto/requests/auth_pb2_grpc.py +24 -0
  205. PySPlusthon/proto/requests/configs_pb2.py +37 -0
  206. PySPlusthon/proto/requests/configs_pb2.pyi +15 -0
  207. PySPlusthon/proto/requests/configs_pb2_grpc.py +24 -0
  208. PySPlusthon/proto/requests/files_pb2.py +40 -0
  209. PySPlusthon/proto/requests/files_pb2.pyi +34 -0
  210. PySPlusthon/proto/requests/files_pb2_grpc.py +24 -0
  211. PySPlusthon/proto/requests/groups_pb2.py +82 -0
  212. PySPlusthon/proto/requests/groups_pb2.pyi +213 -0
  213. PySPlusthon/proto/requests/groups_pb2_grpc.py +24 -0
  214. PySPlusthon/proto/requests/messaging_pb2.py +56 -0
  215. PySPlusthon/proto/requests/messaging_pb2.pyi +119 -0
  216. PySPlusthon/proto/requests/messaging_pb2_grpc.py +24 -0
  217. PySPlusthon/proto/requests/presence_pb2.py +40 -0
  218. PySPlusthon/proto/requests/presence_pb2.pyi +24 -0
  219. PySPlusthon/proto/requests/presence_pb2_grpc.py +24 -0
  220. PySPlusthon/proto/requests/request_pb2.py +42 -0
  221. PySPlusthon/proto/requests/request_pb2.pyi +35 -0
  222. PySPlusthon/proto/requests/request_pb2_grpc.py +24 -0
  223. PySPlusthon/proto/requests/users_pb2.py +43 -0
  224. PySPlusthon/proto/requests/users_pb2.pyi +34 -0
  225. PySPlusthon/proto/requests/users_pb2_grpc.py +24 -0
  226. PySPlusthon/proto/responses/__init__.py +6 -0
  227. PySPlusthon/proto/responses/abacus_pb2.py +37 -0
  228. PySPlusthon/proto/responses/abacus_pb2.pyi +14 -0
  229. PySPlusthon/proto/responses/abacus_pb2_grpc.py +24 -0
  230. PySPlusthon/proto/responses/auth_pb2.py +42 -0
  231. PySPlusthon/proto/responses/auth_pb2.pyi +40 -0
  232. PySPlusthon/proto/responses/auth_pb2_grpc.py +24 -0
  233. PySPlusthon/proto/responses/files_pb2.py +39 -0
  234. PySPlusthon/proto/responses/files_pb2.pyi +27 -0
  235. PySPlusthon/proto/responses/files_pb2_grpc.py +24 -0
  236. PySPlusthon/proto/responses/groups_pb2.py +59 -0
  237. PySPlusthon/proto/responses/groups_pb2.pyi +90 -0
  238. PySPlusthon/proto/responses/groups_pb2_grpc.py +24 -0
  239. PySPlusthon/proto/responses/messaging_pb2.py +44 -0
  240. PySPlusthon/proto/responses/messaging_pb2.pyi +37 -0
  241. PySPlusthon/proto/responses/messaging_pb2_grpc.py +24 -0
  242. PySPlusthon/proto/responses/users_pb2.py +41 -0
  243. PySPlusthon/proto/responses/users_pb2.pyi +28 -0
  244. PySPlusthon/proto/responses/users_pb2_grpc.py +24 -0
  245. PySPlusthon/proto/structs/__init__.py +7 -0
  246. PySPlusthon/proto/structs/collections_pb2.py +54 -0
  247. PySPlusthon/proto/structs/collections_pb2.pyi +79 -0
  248. PySPlusthon/proto/structs/collections_pb2_grpc.py +24 -0
  249. PySPlusthon/proto/structs/files_pb2.py +52 -0
  250. PySPlusthon/proto/structs/files_pb2.pyi +93 -0
  251. PySPlusthon/proto/structs/files_pb2_grpc.py +24 -0
  252. PySPlusthon/proto/structs/groups_pb2.py +49 -0
  253. PySPlusthon/proto/structs/groups_pb2.pyi +144 -0
  254. PySPlusthon/proto/structs/groups_pb2_grpc.py +24 -0
  255. PySPlusthon/proto/structs/messaging_pb2.py +81 -0
  256. PySPlusthon/proto/structs/messaging_pb2.pyi +296 -0
  257. PySPlusthon/proto/structs/messaging_pb2_grpc.py +24 -0
  258. PySPlusthon/proto/structs/peers_pb2.py +47 -0
  259. PySPlusthon/proto/structs/peers_pb2.pyi +56 -0
  260. PySPlusthon/proto/structs/peers_pb2_grpc.py +24 -0
  261. PySPlusthon/proto/structs/set_updates_pb2.py +37 -0
  262. PySPlusthon/proto/structs/set_updates_pb2.pyi +15 -0
  263. PySPlusthon/proto/structs/set_updates_pb2_grpc.py +24 -0
  264. PySPlusthon/proto/structs/users_pb2.py +54 -0
  265. PySPlusthon/proto/structs/users_pb2.pyi +122 -0
  266. PySPlusthon/proto/structs/users_pb2_grpc.py +24 -0
  267. PySPlusthon/proto/updates/__init__.py +1 -0
  268. PySPlusthon/proto/updates/messaging_pb2.py +38 -0
  269. PySPlusthon/proto/updates/messaging_pb2.pyi +26 -0
  270. PySPlusthon/proto/updates/messaging_pb2_grpc.py +24 -0
  271. PySPlusthon/proto/ws_pb2.py +52 -0
  272. PySPlusthon/proto/ws_pb2.pyi +76 -0
  273. PySPlusthon/proto/ws_pb2_grpc.py +24 -0
  274. PySPlusthon/smart_call.py +73 -0
  275. PySPlusthon/states/__init__.py +3 -0
  276. PySPlusthon/states/state.py +11 -0
  277. PySPlusthon/states/state_group.py +13 -0
  278. PySPlusthon/states/state_machine.py +83 -0
  279. PySPlusthon/sync_support.py +48 -0
  280. pysplusthon-0.5.3.dist-info/METADATA +65 -0
  281. pysplusthon-0.5.3.dist-info/RECORD +284 -0
  282. pysplusthon-0.5.3.dist-info/WHEEL +5 -0
  283. pysplusthon-0.5.3.dist-info/licenses/LICENSE +19 -0
  284. pysplusthon-0.5.3.dist-info/top_level.txt +1 -0
@@ -0,0 +1,31 @@
1
+ from . import Object
2
+
3
+
4
+ class Photo(Object):
5
+ attribute_names = [
6
+ ("id", "file_id"),
7
+ ("size", "file_size")
8
+ ]
9
+
10
+ @classmethod
11
+ def from_protobuf(cls, protobuf_data):
12
+ return cls(
13
+ id=protobuf_data.file_id,
14
+ width=protobuf_data.ext.document_ex_photo.w,
15
+ height=protobuf_data.ext.document_ex_photo.h,
16
+ size=protobuf_data.file_size
17
+ )
18
+
19
+ def __init__(
20
+ self,
21
+ id: str = None,
22
+ width: int = None,
23
+ height: int = None,
24
+ size: int = None,
25
+ **kwargs
26
+ ):
27
+ super().__init__(**kwargs)
28
+ self.id: str = id
29
+ self.width: int = width
30
+ self.height: int = height
31
+ self.size: int = size
@@ -0,0 +1,34 @@
1
+ from typing import List
2
+
3
+ from PySPlusthon import enums
4
+ from . import Object
5
+ from .poll_option import PollOption
6
+
7
+
8
+ class Poll(Object):
9
+
10
+ def __init__(
11
+ self,
12
+ id: str = None,
13
+ question: str = None,
14
+ options: List[PollOption] = None,
15
+ total_voter_count: int = None,
16
+ is_closed: bool = None,
17
+ is_anonymous: bool = None,
18
+ type: "enums.PollType" = None,
19
+ allows_multiple_answers: bool = None,
20
+ allows_revoting: bool = None,
21
+ members_only: bool = None,
22
+ **kwargs
23
+ ):
24
+ super().__init__(**kwargs)
25
+ self.id: str = id
26
+ self.question: str = question
27
+ self.options: List[PollOption] = options
28
+ self.total_voter_count: int = total_voter_count
29
+ self.is_closed: bool = is_closed
30
+ self.is_anonymous: bool = is_anonymous
31
+ self.type: "enums.PollType" = type
32
+ self.allows_multiple_answers: bool = allows_multiple_answers
33
+ self.allows_revoting: bool = allows_revoting
34
+ self.members_only: bool = members_only
@@ -0,0 +1,16 @@
1
+ from . import Object
2
+
3
+
4
+ class PollOption(Object):
5
+
6
+ def __init__(
7
+ self,
8
+ persistent_id: str = None,
9
+ text: str = None,
10
+ voter_count: int = None,
11
+ **kwargs
12
+ ):
13
+ super().__init__(**kwargs)
14
+ self.persistent_id: str = persistent_id
15
+ self.text: str = text
16
+ self.voter_count: int = voter_count
@@ -0,0 +1,79 @@
1
+ from typing import Union, List
2
+ from copy import deepcopy
3
+
4
+ from . import ReplyMarkup, ReplyKeyboardButton
5
+ from .list import Object, List as PySplusthonList
6
+ from PySPlusthon import objects
7
+
8
+
9
+ class ReplyKeyboard(ReplyMarkup):
10
+ attribute_names = [
11
+ ("resize", "resize_keyboard"),
12
+ ("one_time", "one_time_keyboard"),
13
+ ("remove", "remove_keyboard")
14
+ ]
15
+
16
+ def __init__(
17
+ self,
18
+ *rows: List[Union["objects.ReplyKeyboardButton", str]],
19
+ resize: bool = None,
20
+ one_time: bool = None,
21
+ selective: bool = None,
22
+ remove: bool = None,
23
+ **kwargs
24
+ ):
25
+ super().__init__(**kwargs)
26
+ if "keyboard" not in kwargs:
27
+ self.keyboard: List[List["objects.ReplyKeyboardButton"]] = PySplusthonList()
28
+ for row in rows:
29
+ self.add_row(*row)
30
+ self.resize: bool = resize
31
+ self.one_time: bool = one_time
32
+ self.selective: bool = selective
33
+ self.remove: bool = remove
34
+
35
+ @classmethod
36
+ def expected_types(cls):
37
+ expected_types = super().expected_types()
38
+ expected_types["keyboard"] = List[List[objects.ReplyKeyboardButton]]
39
+ return expected_types
40
+
41
+ @classmethod
42
+ def wrap(cls, raw_object):
43
+ return Object.wrap.__func__(cls, raw_object)
44
+
45
+ def add_button(
46
+ self,
47
+ button: Union["objects.ReplyKeyboardButton", str],
48
+ row_index: int = -1,
49
+ button_index: int = -1
50
+ ):
51
+ if isinstance(button, str):
52
+ button = ReplyKeyboardButton(button)
53
+ if button_index == -1:
54
+ self.keyboard[row_index].append(button)
55
+ elif button_index < 0:
56
+ self.keyboard[row_index].insert(button_index + 1, button)
57
+ else:
58
+ self.keyboard[row_index].insert(button_index, button)
59
+
60
+ def add_row(self, *row: Union["objects.ReplyKeyboardButton", str], row_index: int = -1):
61
+ if row_index == -1:
62
+ self.keyboard.append(PySplusthonList())
63
+ elif row_index < 0:
64
+ self.keyboard.insert(row_index + 1, PySplusthonList())
65
+ else:
66
+ self.keyboard.insert(row_index, PySplusthonList())
67
+ for button in row:
68
+ self.add_button(button, row_index)
69
+
70
+ def on_click(self, row_index: int, button_index: int):
71
+ from ..conditions import click
72
+ return click(self, row_index, button_index)
73
+
74
+ def format(self, *args, **kwargs):
75
+ markup = deepcopy(self)
76
+ for i, row in enumerate(markup.keyboard):
77
+ for j, button in enumerate(row):
78
+ markup.keyboard[i][j] = button.format(*args, **kwargs)
79
+ return markup
@@ -0,0 +1,27 @@
1
+ from typing import Union
2
+ from copy import deepcopy
3
+
4
+ from . import Object
5
+ from PySPlusthon import objects
6
+
7
+
8
+ class ReplyKeyboardButton(Object):
9
+
10
+ def __init__(
11
+ self,
12
+ text: str = None,
13
+ request_contact: bool = None,
14
+ request_location: bool = None,
15
+ **kwargs
16
+ ):
17
+ super().__init__(**kwargs)
18
+ self.text: str = text
19
+ self.request_contact: bool = request_contact
20
+ self.request_location: bool = request_location
21
+
22
+
23
+ def format(self, *args, **kwargs):
24
+ button = deepcopy(self)
25
+ if button.text:
26
+ button.text = button.text.format(*args, **kwargs)
27
+ return button
@@ -0,0 +1,10 @@
1
+ from . import ReplyKeyboard
2
+
3
+
4
+ class ReplyKeyboardRemove(ReplyKeyboard):
5
+
6
+ def __init__(self):
7
+ super().__init__(remove=True)
8
+
9
+ def __repr__(self):
10
+ return f"{type(self).__name__}()"
@@ -0,0 +1,12 @@
1
+ from . import Object
2
+
3
+
4
+ class ReplyMarkup(Object):
5
+
6
+ @classmethod
7
+ def wrap(cls, raw_object):
8
+ from . import InlineKeyboard, ReplyKeyboard
9
+ if "inline_keyboard" in raw_object:
10
+ return InlineKeyboard.wrap(raw_object)
11
+ elif "keyboard" in raw_object:
12
+ return ReplyKeyboard.wrap(raw_object)
@@ -0,0 +1,22 @@
1
+ from .object import Object
2
+
3
+
4
+ class ShippingAddress(Object):
5
+
6
+ def __init__(
7
+ self,
8
+ country_code: str = None,
9
+ stat: str = None,
10
+ city: str = None,
11
+ street_line1: str = None,
12
+ street_line2: str = None,
13
+ post_code: str = None,
14
+ **kwargs
15
+ ):
16
+ super().__init__(**kwargs)
17
+ self.country_code: str = country_code
18
+ self.stat: str = stat
19
+ self.city: str = city
20
+ self.street_line1: str = street_line1
21
+ self.street_line2: str = street_line2
22
+ self.post_code: str = post_code
@@ -0,0 +1,20 @@
1
+ from . import Object
2
+ from PySPlusthon import objects
3
+
4
+
5
+ class ShippingQuery(Object):
6
+ attribute_names = [
7
+ ("author", "from")
8
+ ]
9
+
10
+ def __init__(
11
+ self,
12
+ id: str = None,
13
+ author: "objects.User" = None,
14
+ shipping_address: "objects.ShippingAddress" = None,
15
+ **kwargs
16
+ ):
17
+ super().__init__(**kwargs)
18
+ self.id: str = id
19
+ self.author: "objects.User" = author
20
+ self.shipping_address: "objects.ShippingAddress" = shipping_address
@@ -0,0 +1,54 @@
1
+ from PySPlusthon import objects
2
+ from . import Object
3
+
4
+
5
+ class Sticker(Object):
6
+ attribute_names = [
7
+ ("id", "file_id"),
8
+ ("unique_id", "file_unique_id"),
9
+ ("size", "file_size")
10
+ ]
11
+
12
+ @classmethod
13
+ def from_protobuf(cls, protobuf_data):
14
+ return cls(
15
+ id=protobuf_data.image512.file_location.file_id,
16
+ unique_id=str(protobuf_data.sticker_id.value),
17
+ width=protobuf_data.image512.width,
18
+ height=protobuf_data.image512.height,
19
+ size=protobuf_data.image512.file_size,
20
+ thumb=objects.Photo(
21
+ id=protobuf_data.image256.file_location.file_id,
22
+ width=protobuf_data.image256.width,
23
+ height=protobuf_data.image256.height,
24
+ size=protobuf_data.image256.file_size
25
+ )
26
+ )
27
+
28
+ def __init__(
29
+ self,
30
+ id: str = None,
31
+ unique_id: str = None,
32
+ width: int = None,
33
+ height: int = None,
34
+ size: int = None,
35
+ thumb: "objects.Photo" = None,
36
+ emoji: str = None,
37
+ set_name: str = None,
38
+ type: str = None,
39
+ is_animated: bool = None,
40
+ is_video: bool = None,
41
+ **kwargs
42
+ ):
43
+ super().__init__(**kwargs)
44
+ self.id: str = id
45
+ self.unique_id: str = unique_id
46
+ self.width: int = width
47
+ self.height: int = height
48
+ self.size: int = size
49
+ self.thumb: "objects.Photo" = thumb
50
+ self.emoji: str = emoji
51
+ self.set_name: str = set_name
52
+ self.type: str = type
53
+ self.is_animated: bool = is_animated
54
+ self.is_video: bool = is_video
@@ -0,0 +1,29 @@
1
+ from typing import List
2
+
3
+ from . import Object
4
+ from PySPlusthon import objects
5
+
6
+
7
+ class StickerSet(Object):
8
+
9
+ def __init__(
10
+ self,
11
+ name: str = None,
12
+ title: str = None,
13
+ sticker_type: str = None,
14
+ is_animated: bool = None,
15
+ is_video: bool = None,
16
+ contains_masks: bool = None,
17
+ stickers: List["objects.Sticker"] = None,
18
+ thumb: "objects.Photo" = None,
19
+ **kwargs
20
+ ):
21
+ super().__init__(**kwargs)
22
+ self.name: str = name
23
+ self.title: str = title
24
+ self.sticker_type: str = sticker_type
25
+ self.is_animated: bool = is_animated
26
+ self.is_video: bool = is_video
27
+ self.contains_masks: bool = contains_masks
28
+ self.stickers: List["objects.Sticker"] = stickers
29
+ self.thumb: "objects.Photo" = thumb
@@ -0,0 +1,25 @@
1
+ from . import Object
2
+ from PySPlusthon import enums
3
+
4
+
5
+ class Transaction(Object):
6
+ attribute_names = [
7
+ ("user_id", "userID"),
8
+ ("created_at", "createdAt"),
9
+ ]
10
+
11
+ def __init__(
12
+ self,
13
+ id: str = None,
14
+ status: "enums.TransactionStatus" = None,
15
+ user_id: int = None,
16
+ amount: int = None,
17
+ created_at: int = None,
18
+ **kwargs
19
+ ):
20
+ super().__init__(**kwargs)
21
+ self.id: str = id
22
+ self.status: "enums.TransactionStatus" = status
23
+ self.user_id: int = user_id
24
+ self.amount: int = amount
25
+ self.created_at: int = created_at
@@ -0,0 +1,33 @@
1
+ from . import Object
2
+ from PySPlusthon import objects
3
+
4
+
5
+ class Update(Object):
6
+ attribute_names = [
7
+ ("id", "update_id")
8
+ ]
9
+
10
+ def __init__(
11
+ self,
12
+ id: int = None,
13
+ message: "objects.Message" = None,
14
+ edited_message: "objects.EditedMessage" = None,
15
+ channel_post: "objects.Message" = None,
16
+ edited_channel_post: "objects.EditedMessage" = None,
17
+ callback_query: "objects.CallbackQuery" = None,
18
+ shipping_query: "objects.ShippingQuery" = None,
19
+ **kwargs
20
+ ):
21
+ super().__init__(**kwargs)
22
+ self.id: int = id
23
+ self.message: "objects.Message" = message
24
+ self.edited_message: "objects.EditedMessage" = edited_message
25
+ self.channel_post: "objects.Message" = channel_post
26
+ self.edited_channel_post: "objects.EditedMessage" = edited_channel_post
27
+ self.callback_query: "objects.CallbackQuery" = callback_query
28
+ self.shipping_query: "objects.ShippingQuery" = shipping_query
29
+
30
+ def get_effective_update(self):
31
+ for value in self.__dict__.values():
32
+ if isinstance(value, Object):
33
+ return value
@@ -0,0 +1,60 @@
1
+ from typing import Union
2
+
3
+ from . import Object
4
+ from ..states import StateMachine
5
+ from ..sync_support import add_sync_support_to_object
6
+
7
+
8
+ @add_sync_support_to_object
9
+ class User(Object):
10
+
11
+ @classmethod
12
+ def from_protobuf(cls, id: int):
13
+ return cls(id=id)
14
+
15
+ def __init__(
16
+ self,
17
+ id: int = None,
18
+ username: str = None,
19
+ first_name: str = None,
20
+ last_name: str = None,
21
+ language_code: str = None,
22
+ is_bot: bool = None,
23
+ **kwargs
24
+ ):
25
+ super().__init__(**kwargs)
26
+ self.id: int = id
27
+ self.username: str = username
28
+ self.first_name: str = first_name
29
+ self.last_name: str = last_name
30
+ self.language_code: str = language_code
31
+ self.is_bot: bool = is_bot
32
+
33
+ def mention(self, text=None):
34
+ text = text or self.full_name
35
+ return f"[{text}](uid:{self.id})"
36
+
37
+ @property
38
+ def link(self):
39
+ if self.username:
40
+ return f"{self.client.http_connection.short_url}/{self.username}"
41
+
42
+ @property
43
+ def full_name(self):
44
+ if self.first_name and self.last_name:
45
+ return f"{self.first_name} {self.last_name}"
46
+ if self.first_name:
47
+ return self.first_name
48
+ return ""
49
+
50
+ def set_state(self, state):
51
+ StateMachine.global_state_machine[self.id] = state
52
+
53
+ def get_state(self):
54
+ return StateMachine.global_state_machine[self.id]
55
+
56
+ def del_state(self):
57
+ del StateMachine.global_state_machine[self.id]
58
+
59
+ async def invite(self, chat_id: Union[int, str]):
60
+ return await self.client.invite_user(chat_id, self.id)
@@ -0,0 +1,45 @@
1
+ from PySPlusthon import objects
2
+ from . import Object
3
+
4
+
5
+ class Video(Object):
6
+ attribute_names = [
7
+ ("id", "file_id"),
8
+ ("size", "file_size")
9
+ ]
10
+
11
+ @classmethod
12
+ def from_protobuf(cls, protobuf_data):
13
+ return cls(
14
+ id=protobuf_data.file_id,
15
+ width=protobuf_data.ext.document_ex_video.w,
16
+ height=protobuf_data.ext.document_ex_video.h,
17
+ duration=protobuf_data.ext.document_ex_video.duration,
18
+ thumb=objects.Photo(
19
+ width=protobuf_data.thumb.w,
20
+ height=protobuf_data.thumb.h,
21
+ file_size=len(protobuf_data.thumb.thumb)
22
+ ),
23
+ mime_type=protobuf_data.mime_type,
24
+ size=protobuf_data.file_size
25
+ )
26
+
27
+ def __init__(
28
+ self,
29
+ id: str = None,
30
+ width: int = None,
31
+ height: int = None,
32
+ duration: int = None,
33
+ thumb: "objects.Photo" = None,
34
+ mime_type: str = None,
35
+ size: int = None,
36
+ **kwargs
37
+ ):
38
+ super().__init__(**kwargs)
39
+ self.id: str = id
40
+ self.width: int = width
41
+ self.height: int = height
42
+ self.duration: int = duration
43
+ self.thumb: "objects.Photo" = thumb
44
+ self.mime_type: str = mime_type
45
+ self.size: int = size
@@ -0,0 +1,31 @@
1
+ from . import Object
2
+
3
+
4
+ class Voice(Object):
5
+ attribute_names = [
6
+ ("id", "file_id"),
7
+ ("size", "file_size")
8
+ ]
9
+
10
+ @classmethod
11
+ def from_protobuf(cls, protobuf_data):
12
+ return cls(
13
+ id=protobuf_data.file_id,
14
+ duration=protobuf_data.ext.document_ex_voice.duration,
15
+ mime_type=protobuf_data.mime_type,
16
+ size=protobuf_data.file_size
17
+ )
18
+
19
+ def __init__(
20
+ self,
21
+ id: str = None,
22
+ duration: int = None,
23
+ mime_type: str = None,
24
+ size: int = None,
25
+ **kwargs
26
+ ):
27
+ super().__init__(**kwargs)
28
+ self.id: str = id
29
+ self.duration: int = duration
30
+ self.mime_type: str = mime_type
31
+ self.size: int = size
@@ -0,0 +1,16 @@
1
+ from . import Object
2
+
3
+
4
+ class WebhookInfo(Object):
5
+
6
+ def __init__(
7
+ self,
8
+ url: str,
9
+ has_custom_certificate: bool,
10
+ pending_update_count: int,
11
+ **kwargs
12
+ ):
13
+ super().__init__(**kwargs)
14
+ self.url: str = url
15
+ self.has_custom_certificate: bool = has_custom_certificate
16
+ self.pending_update_count: int = pending_update_count
@@ -0,0 +1,2 @@
1
+ from . import enums_pb2 as enums
2
+ from . import ws_pb2 as ws
@@ -0,0 +1,46 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
3
+ # NO CHECKED-IN PROTOBUF GENCODE
4
+ # source: enums.proto
5
+ # Protobuf Python Version: 6.31.1
6
+ """Generated protocol buffer code."""
7
+ from google.protobuf import descriptor as _descriptor
8
+ from google.protobuf import descriptor_pool as _descriptor_pool
9
+ from google.protobuf import runtime_version as _runtime_version
10
+ from google.protobuf import symbol_database as _symbol_database
11
+ from google.protobuf.internal import builder as _builder
12
+ _runtime_version.ValidateProtobufRuntimeVersion(
13
+ _runtime_version.Domain.PUBLIC,
14
+ 6,
15
+ 31,
16
+ 1,
17
+ '',
18
+ 'enums.proto'
19
+ )
20
+ # @@protoc_insertion_point(imports)
21
+
22
+ _sym_db = _symbol_database.Default()
23
+
24
+
25
+
26
+
27
+ DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0b\x65nums.proto\x12\x05\x65nums*\xec\x01\n\x08SendType\x12\x15\n\x11SEND_TYPE_UNKNOWN\x10\x00\x12\x13\n\x0fSEND_TYPE_PHOTO\x10\x01\x12\x13\n\x0fSEND_TYPE_VIDEO\x10\x02\x12\x13\n\x0fSEND_TYPE_VOICE\x10\x03\x12\x11\n\rSEND_TYPE_GIF\x10\x04\x12\x13\n\x0fSEND_TYPE_AUDIO\x10\x05\x12\x16\n\x12SEND_TYPE_DOCUMENT\x10\x06\x12\x15\n\x11SEND_TYPE_STICKER\x10\x07\x12\x1a\n\x16SEND_TYPE_CROWDFUNDING\x10\x08\x12\x17\n\x13SEND_TYPE_SPONSORED\x10\t*>\n\x0bRestriction\x12\x17\n\x13RESTRICTION_PRIVATE\x10\x00\x12\x16\n\x12RESTRICTION_PUBLIC\x10\x01*U\n\tGroupType\x12\x14\n\x10GROUP_TYPE_GROUP\x10\x00\x12\x16\n\x12GROUP_TYPE_CHANNEL\x10\x01\x12\x1a\n\x16GROUP_TYPE_SUPER_GROUP\x10\x02*\xbe\x01\n\nExPeerType\x12\x18\n\x14\x45X_PEER_TYPE_UNKNOWN\x10\x00\x12\x18\n\x14\x45X_PEER_TYPE_PRIVATE\x10\x01\x12\x16\n\x12\x45X_PEER_TYPE_GROUP\x10\x02\x12\x18\n\x14\x45X_PEER_TYPE_CHANNEL\x10\x03\x12\x14\n\x10\x45X_PEER_TYPE_BOT\x10\x04\x12\x1b\n\x17\x45X_PEER_TYPE_SUPERGROUP\x10\x05\x12\x17\n\x13\x45X_PEER_TYPE_THREAD\x10\x06*\x9b\x03\n\nTypingType\x12\x17\n\x13TYPING_TYPE_UNKNOWN\x10\x00\x12\x14\n\x10TYPING_TYPE_TEXT\x10\x01\x12\x1f\n\x1bTYPING_TYPE_VOICE_RECORDING\x10\x02\x12\x1d\n\x19TYPING_TYPE_SENDING_VOICE\x10\x03\x12\x1c\n\x18TYPING_TYPE_SENDING_FILE\x10\x04\x12\x1d\n\x19TYPING_TYPE_SENDING_PHOTO\x10\x05\x12\x1d\n\x19TYPING_TYPE_SENDING_VIDEO\x10\x06\x12\x1d\n\x19TYPING_TYPE_SENDING_MUSIC\x10\x07\x12 \n\x1cTYPING_TYPE_CHOOSING_STICKER\x10\x08\x12\x1c\n\x18TYPING_TYPE_CHOOSING_GIF\x10\t\x12$\n TYPING_TYPE_CREATING_GIFT_PACKET\x10\n\x12\x1d\n\x19TYPING_TYPE_SENDING_ALBUM\x10\x0b\x12\x1e\n\x1aTYPING_TYPE_CHOOSING_EMOJI\x10\x0c*4\n\x03Sex\x12\x0f\n\x0bSEX_UNKNOWN\x10\x00\x12\x0c\n\x08SEX_MALE\x10\x01\x12\x0e\n\nSEX_FEMALE\x10\x02\x62\x06proto3')
28
+
29
+ _globals = globals()
30
+ _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
31
+ _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'enums_pb2', _globals)
32
+ if not _descriptor._USE_C_DESCRIPTORS:
33
+ DESCRIPTOR._loaded_options = None
34
+ _globals['_SENDTYPE']._serialized_start=23
35
+ _globals['_SENDTYPE']._serialized_end=259
36
+ _globals['_RESTRICTION']._serialized_start=261
37
+ _globals['_RESTRICTION']._serialized_end=323
38
+ _globals['_GROUPTYPE']._serialized_start=325
39
+ _globals['_GROUPTYPE']._serialized_end=410
40
+ _globals['_EXPEERTYPE']._serialized_start=413
41
+ _globals['_EXPEERTYPE']._serialized_end=603
42
+ _globals['_TYPINGTYPE']._serialized_start=606
43
+ _globals['_TYPINGTYPE']._serialized_end=1017
44
+ _globals['_SEX']._serialized_start=1019
45
+ _globals['_SEX']._serialized_end=1071
46
+ # @@protoc_insertion_point(module_scope)