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,16 @@
1
+ from typing import Union
2
+
3
+ import PySPlusthon
4
+
5
+
6
+ class CreateNewStickerSet:
7
+
8
+ async def create_new_sticker_set(
9
+ self: "PySPlusthon.Client",
10
+ user_id: Union[int, str],
11
+ name: str,
12
+ title: str,
13
+ sticker=None
14
+ ) -> bool:
15
+ user_id = await self.resolve_peer_id(user_id)
16
+ return await self.auto_execute("createNewStickerSet", locals())
@@ -0,0 +1,10 @@
1
+ import PySPlusthon
2
+
3
+
4
+ class DeleteStickerFromSet:
5
+
6
+ async def delete_sticker_from_set(
7
+ self: "PySPlusthon.Client",
8
+ sticker: str
9
+ ) -> bool:
10
+ return await self.auto_execute("deleteStickerToSet", locals())
@@ -0,0 +1,11 @@
1
+ import PySPlusthon
2
+ from ...objects import StickerSet
3
+
4
+
5
+ class GetStickerSet:
6
+
7
+ async def get_sticker_set(
8
+ self: "PySPlusthon.Client",
9
+ name: str
10
+ ) -> StickerSet:
11
+ return await self.auto_execute("getStickerSet", locals())
@@ -0,0 +1,16 @@
1
+ from typing import Union, BinaryIO
2
+
3
+ import PySPlusthon
4
+ from ...objects import InputMedia, resolve_media
5
+
6
+
7
+ class UploadStickerFile:
8
+
9
+ async def upload_sticker_file(
10
+ self: "PySPlusthon.Client",
11
+ user_id: Union[int, str],
12
+ sticker: Union[str, bytes, BinaryIO, InputMedia]
13
+ ) -> str:
14
+ user_id = await self.resolve_peer_id(user_id)
15
+ sticker = resolve_media(sticker)
16
+ return await self.auto_execute("uploadStickerFile", locals())
@@ -0,0 +1,8 @@
1
+ from .delete_webhook import DeleteWebhook
2
+ from .get_updates import GetUpdates
3
+ from .get_webhook_info import GetWebhookInfo
4
+ from .set_webhook import SetWebhook
5
+
6
+
7
+ class Updates(DeleteWebhook, GetUpdates, GetWebhookInfo, SetWebhook):
8
+ pass
@@ -0,0 +1,9 @@
1
+ import PySPlusthon
2
+
3
+
4
+ class DeleteWebhook:
5
+
6
+ async def delete_webhook(
7
+ self: "PySPlusthon.Client"
8
+ ) -> bool:
9
+ return await self.auto_execute("deleteWebhook", locals())
@@ -0,0 +1,14 @@
1
+ from typing import List
2
+
3
+ import PySPlusthon
4
+ from ...objects import Update
5
+
6
+
7
+ class GetUpdates:
8
+
9
+ async def get_updates(
10
+ self: "PySPlusthon.Client",
11
+ offset: int = None,
12
+ limit: int = None
13
+ ) -> List[Update]:
14
+ return await self.auto_execute("getUpdates", locals())
@@ -0,0 +1,10 @@
1
+ import PySPlusthon
2
+ from ...objects import WebhookInfo
3
+
4
+
5
+ class GetWebhookInfo:
6
+
7
+ async def get_webhook_info(
8
+ self: "PySPlusthon.Client"
9
+ ) -> WebhookInfo:
10
+ return await self.auto_execute("getWebhookInfo", locals())
@@ -0,0 +1,10 @@
1
+ import PySPlusthon
2
+
3
+
4
+ class SetWebhook:
5
+
6
+ async def set_webhook(
7
+ self: "PySPlusthon.Client",
8
+ url: str
9
+ ) -> bool:
10
+ return await self.auto_execute("setWebhook", locals())
@@ -0,0 +1,6 @@
1
+ from .ask_review import AskReview
2
+ from .get_me import GetMe
3
+
4
+
5
+ class Users(AskReview, GetMe):
6
+ pass
@@ -0,0 +1,14 @@
1
+ from typing import Union
2
+
3
+ import PySPlusthon
4
+
5
+
6
+ class AskReview:
7
+
8
+ async def ask_review(
9
+ self: "PySPlusthon.Client",
10
+ user_id: Union[int, str],
11
+ delay_seconds: int = 0
12
+ ) -> bool:
13
+ user_id = await self.resolve_peer_id(user_id)
14
+ return await self.auto_execute("askReview", locals())
@@ -0,0 +1,16 @@
1
+ import PySPlusthon
2
+ from ...objects import User
3
+
4
+
5
+ class GetMe:
6
+
7
+ async def get_me(
8
+ self: "PySPlusthon.Client"
9
+ ) -> User:
10
+ if self.is_userbot():
11
+ jwt = self.load_session()
12
+ data = self.decode_jwt(jwt)
13
+ my_id = data["payload"]["payload"]["user_id"]
14
+ return await self.get_chat(f"{my_id}|1")
15
+
16
+ return await self.auto_execute("getMe", locals())
@@ -0,0 +1,43 @@
1
+ from .condition import Condition, AllCondition, AnyCondition, NotCondition, create
2
+ from .all import all
3
+ from .forward import forward
4
+ from .reply import reply
5
+ from .text import text
6
+ from .entities import entities
7
+ from .document import document
8
+ from .photo import photo
9
+ from .video import video
10
+ from .voice import voice
11
+ from .caption import caption
12
+ from .contact import contact
13
+ from .location import location
14
+ from .new_chat_members import new_chat_members
15
+ from .left_chat_member import left_chat_member
16
+ from .new_chat_title import new_chat_title
17
+ from .new_chat_photo import new_chat_photo
18
+ from .delete_chat_photo import delete_chat_photo
19
+ from .group_chat_created import group_chat_created
20
+ from .supergroup_chat_created import supergroup_chat_created
21
+ from .channel_chat_created import channel_chat_created
22
+ from .pinned_message import pinned_message
23
+ from .media import media
24
+ from .command import Command as command
25
+ from .private import private
26
+ from .group import group
27
+ from .channel import channel
28
+ from .regex import Regex as regex
29
+ from .at_state import AtState as at_state
30
+ from .is_instance import IsInstance as is_instance
31
+ from .chat import Chat as chat
32
+ from .is_joined import IsJoined as is_joined
33
+ from .is_admin import IsAdmin as is_admin
34
+ from .author import Author as author
35
+ from .equals import Equals as equals
36
+ from .content import content
37
+ from .media_group import media_group
38
+ from .sticker import sticker
39
+ from .number import number
40
+ from .click import Click as click
41
+ from .audio import audio
42
+ from .animation import animation
43
+ from .poll import poll
@@ -0,0 +1,6 @@
1
+ from .condition import create
2
+
3
+
4
+ @create()
5
+ def all() -> bool:
6
+ return True
@@ -0,0 +1,7 @@
1
+ from .condition import create
2
+ from ..objects import Message
3
+
4
+
5
+ @create(can_process=Message)
6
+ def animation(event) -> bool:
7
+ return bool(event.animation)
@@ -0,0 +1,18 @@
1
+ from .condition import Condition
2
+ from ..objects import Message, CallbackQuery
3
+ from ..states import State
4
+
5
+
6
+ class AtState(Condition):
7
+ def __init__(self, state, state_machine=None):
8
+ super().__init__(can_process=(Message, CallbackQuery))
9
+ self.state = str(state) if isinstance(state, State) else state
10
+ self.state_machine = state_machine
11
+
12
+ async def process(self, client, event) -> bool:
13
+ if not event.author:
14
+ return False
15
+ if self.state_machine is None:
16
+ return event.author.get_state() == self.state
17
+ else:
18
+ return self.state_machine[event.author.id] == self.state
@@ -0,0 +1,7 @@
1
+ from .condition import create
2
+ from ..objects import Message
3
+
4
+
5
+ @create(can_process=Message)
6
+ def audio(event) -> bool:
7
+ return bool(event.audio)
@@ -0,0 +1,13 @@
1
+ from .condition import Condition
2
+ from ..objects import Message, CallbackQuery
3
+
4
+
5
+ class Author(Condition):
6
+ def __init__(self, *authors):
7
+ super().__init__(can_process=(Message, CallbackQuery))
8
+ self.authors = set(authors)
9
+
10
+ async def process(self, client, event) -> bool:
11
+ if not event.author:
12
+ return False
13
+ return event.author.id in self.authors
@@ -0,0 +1,7 @@
1
+ from .condition import create
2
+ from ..objects import Message
3
+
4
+
5
+ @create(can_process=Message)
6
+ def caption(event) -> bool:
7
+ return bool(event.caption)
@@ -0,0 +1,11 @@
1
+ from .condition import create
2
+ from ..objects import Message, CallbackQuery
3
+ from ..enums import ChatType
4
+
5
+
6
+ @create(can_process=(Message, CallbackQuery))
7
+ def channel(event) -> bool:
8
+ if isinstance(event, Message):
9
+ return event.chat.type == ChatType.CHANNEL
10
+ elif isinstance(event, CallbackQuery):
11
+ return event.message.chat.type == ChatType.CHANNEL
@@ -0,0 +1,7 @@
1
+ from .condition import create
2
+ from ..objects import Message
3
+
4
+
5
+ @create(can_process=Message)
6
+ def channel_chat_created(event) -> bool:
7
+ return bool(event.channel_chat_created)
@@ -0,0 +1,14 @@
1
+ from .condition import Condition
2
+ from ..objects import Message, CallbackQuery
3
+
4
+
5
+ class Chat(Condition):
6
+ def __init__(self, *chats):
7
+ super().__init__(can_process=(Message, CallbackQuery))
8
+ self.chats = set(chats)
9
+
10
+ async def process(self, client, event) -> bool:
11
+ if isinstance(event, Message):
12
+ return event.chat.id in self.chats
13
+ elif isinstance(event, CallbackQuery):
14
+ return event.message.chat.id in self.chats
@@ -0,0 +1,24 @@
1
+ import re
2
+
3
+ from .condition import Condition
4
+ from ..objects import Message, CallbackQuery, ReplyKeyboard, InlineKeyboard
5
+
6
+
7
+ class Click(Condition):
8
+ def __init__(self, keyboard, row_index: int, button_index: int):
9
+ super().__init__(can_process=(Message, CallbackQuery))
10
+ self.keyboard = keyboard
11
+ self.row_index = row_index
12
+ self.button_index = button_index
13
+
14
+ @staticmethod
15
+ def create_regex(text):
16
+ return "^" + re.sub(r"{.*?}", ".*", text) + "$"
17
+
18
+ async def process(self, client, event) -> bool:
19
+ if isinstance(self.keyboard, ReplyKeyboard) and isinstance(event, Message):
20
+ button = self.keyboard.keyboard[self.row_index][self.button_index]
21
+ return bool(re.match(self.create_regex(button.text), event.text))
22
+ elif isinstance(self.keyboard, InlineKeyboard) and isinstance(event, CallbackQuery):
23
+ button = self.keyboard.inline_keyboard[self.row_index][self.button_index]
24
+ return bool(re.match(self.create_regex(button.callback_data), event.data))
@@ -0,0 +1,23 @@
1
+ from .condition import Condition
2
+ from ..objects import Message
3
+
4
+
5
+ class Command(Condition):
6
+ def __init__(self, name, prefix="/", min_arguments=None, max_arguments=None):
7
+ super().__init__(can_process=Message)
8
+ self.name = name
9
+ self.prefix = prefix
10
+ self.min_arguments = min_arguments
11
+ self.max_arguments = max_arguments
12
+
13
+ async def process(self, client, event) -> bool:
14
+ if not event.text:
15
+ return False
16
+ name, *arguments = event.text.split()
17
+ if name.lower() != f"{self.prefix}{self.name.lower()}":
18
+ return False
19
+ if self.min_arguments is not None and len(arguments) < self.min_arguments:
20
+ return False
21
+ if self.max_arguments is not None and len(arguments) > self.max_arguments:
22
+ return False
23
+ return True
@@ -0,0 +1,88 @@
1
+ from inspect import iscoroutinefunction
2
+
3
+ from ..smart_call import remove_unwanted_keyword_parameters
4
+
5
+
6
+ class Condition:
7
+ def __init__(self, function=None, can_process=None):
8
+ self.function = function
9
+ self.can_process = can_process
10
+
11
+ def is_not_processable(self, event):
12
+ return self.can_process is not None and not isinstance(event, self.can_process)
13
+
14
+ async def __call__(self, client, event) -> bool:
15
+ if self.is_not_processable(event):
16
+ return False
17
+ return await self.process(client, event)
18
+
19
+ async def process(self, client, event) -> bool:
20
+ kwargs = dict(condition=self, client=client, event=event)
21
+ kwargs = remove_unwanted_keyword_parameters(self.function, **kwargs)
22
+ if iscoroutinefunction(self.function):
23
+ return await self.function(**kwargs)
24
+ return self.function(**kwargs)
25
+
26
+ def __and__(self, other):
27
+ return AllCondition(self, other)
28
+
29
+ def __or__(self, other):
30
+ return AnyCondition(self, other)
31
+
32
+ def __invert__(self):
33
+ return NotCondition(self)
34
+
35
+ def __repr__(self):
36
+ return type(self).__name__
37
+
38
+
39
+ class AllCondition(Condition):
40
+ def __init__(self, *conditions):
41
+ super().__init__()
42
+ self.conditions = conditions
43
+
44
+ async def __call__(self, client, event) -> bool:
45
+ for condition in self.conditions:
46
+ if not await condition(client, event):
47
+ return False
48
+ return True
49
+
50
+ def __repr__(self):
51
+ conditions_string = ", ".join(map(str, self.conditions))
52
+ return f"All({conditions_string})"
53
+
54
+
55
+ class AnyCondition(Condition):
56
+ def __init__(self, *conditions):
57
+ super().__init__()
58
+ self.conditions = conditions
59
+
60
+ async def __call__(self, client, event) -> bool:
61
+ for condition in self.conditions:
62
+ if await condition(client, event):
63
+ return True
64
+ return False
65
+
66
+ def __repr__(self):
67
+ conditions_string = ", ".join(map(str, self.conditions))
68
+ return f"Any({conditions_string})"
69
+
70
+
71
+ class NotCondition(Condition):
72
+ def __init__(self, condition):
73
+ super().__init__()
74
+ self.condition = condition
75
+
76
+ async def __call__(self, client, event) -> bool:
77
+ return not await self.condition(client, event)
78
+
79
+ def __repr__(self):
80
+ return f"Not({self.condition})"
81
+
82
+
83
+ def create(name: str = None, can_process=None):
84
+ def decorator(function):
85
+ CustomCondition = type(name or function.__name__ or "CustomCondition", (Condition,), {})
86
+ return CustomCondition(function, can_process)
87
+
88
+ return decorator
@@ -0,0 +1,7 @@
1
+ from .condition import create
2
+ from ..objects import Message
3
+
4
+
5
+ @create(can_process=Message)
6
+ def contact(event) -> bool:
7
+ return bool(event.contact)
@@ -0,0 +1,7 @@
1
+ from .condition import create
2
+ from ..objects import Message
3
+
4
+
5
+ @create(can_process=Message)
6
+ def content(event) -> bool:
7
+ return bool(event.content)
@@ -0,0 +1,7 @@
1
+ from .condition import create
2
+ from ..objects import Message
3
+
4
+
5
+ @create(can_process=Message)
6
+ def delete_chat_photo(event) -> bool:
7
+ return bool(event.delete_chat_photo)
@@ -0,0 +1,7 @@
1
+ from .condition import create
2
+ from ..objects import Message
3
+
4
+
5
+ @create(can_process=Message)
6
+ def document(event) -> bool:
7
+ return bool(event.document)
@@ -0,0 +1,7 @@
1
+ from .condition import create
2
+ from ..objects import Message
3
+
4
+
5
+ @create(can_process=Message)
6
+ def entities(event) -> bool:
7
+ return bool(event.entities or event.caption_entities)
@@ -0,0 +1,14 @@
1
+ from .condition import Condition
2
+ from ..objects import Message, CallbackQuery
3
+
4
+
5
+ class Equals(Condition):
6
+ def __init__(self, *values):
7
+ super().__init__(can_process=(Message, CallbackQuery))
8
+ self.values = values
9
+
10
+ async def process(self, client, event) -> bool:
11
+ if isinstance(event, Message):
12
+ return event.content in self.values
13
+ elif isinstance(event, CallbackQuery):
14
+ return event.data in self.values
@@ -0,0 +1,7 @@
1
+ from .condition import create
2
+ from ..objects import Message
3
+
4
+
5
+ @create(can_process=Message)
6
+ def forward(event) -> bool:
7
+ return bool(event.forward_from or event.forward_from_chat)
@@ -0,0 +1,11 @@
1
+ from .condition import create
2
+ from ..objects import Message, CallbackQuery
3
+ from ..enums import ChatType
4
+
5
+
6
+ @create(can_process=(Message, CallbackQuery))
7
+ def group(event) -> bool:
8
+ if isinstance(event, Message):
9
+ return event.chat.type == ChatType.GROUP
10
+ elif isinstance(event, CallbackQuery):
11
+ return event.message.chat.type == ChatType.GROUP
@@ -0,0 +1,7 @@
1
+ from .condition import create
2
+ from ..objects import Message
3
+
4
+
5
+ @create(can_process=Message)
6
+ def group_chat_created(event) -> bool:
7
+ return bool(event.group_chat_created)
@@ -0,0 +1,17 @@
1
+ from typing import Union, Tuple
2
+
3
+ from .is_joined import IsJoined
4
+ from ..enums import ChatMemberStatus
5
+
6
+
7
+ class IsAdmin(IsJoined):
8
+ ACCEPTED_STATUSES = ChatMemberStatus.ADMINISTRATOR, ChatMemberStatus.CREATOR
9
+
10
+ def __init__(
11
+ self,
12
+ *chat_ids: Union[int, str],
13
+ accepted_statuses: Tuple[str, ...] = None,
14
+ source_chat: bool = False
15
+ ):
16
+ super().__init__(*chat_ids, accepted_statuses=accepted_statuses)
17
+ self.source_chat = source_chat
@@ -0,0 +1,10 @@
1
+ from .condition import Condition
2
+
3
+
4
+ class IsInstance(Condition):
5
+ def __init__(self, classes):
6
+ super().__init__()
7
+ self.classes = classes
8
+
9
+ async def process(self, client, event) -> bool:
10
+ return isinstance(event, self.classes)
@@ -0,0 +1,61 @@
1
+ from typing import Union, Tuple
2
+ from copy import copy
3
+
4
+ from .condition import Condition
5
+ from ..objects import Message, CallbackQuery
6
+ from ..enums import ChatMemberStatus
7
+ from ..errors import RPCError, ForbiddenError
8
+
9
+
10
+ class IsJoined(Condition):
11
+ ACCEPTED_STATUSES = ChatMemberStatus.MEMBER, ChatMemberStatus.ADMINISTRATOR, ChatMemberStatus.CREATOR
12
+
13
+ def __init__(self, *chat_ids: Union[int, str], accepted_statuses: Tuple[str, ...] = None):
14
+ super().__init__(can_process=(Message, CallbackQuery))
15
+ self.chat_ids = list(chat_ids)
16
+ self.chats = []
17
+ self.accepted_statuses = accepted_statuses or self.ACCEPTED_STATUSES
18
+ self.source_chat = False
19
+
20
+ async def update_chats(self, client):
21
+ self.chats = []
22
+ for chat_id in self.chat_ids:
23
+ chat = await client.get_chat(chat_id)
24
+ self.chats.append(chat)
25
+ self.chat_ids = [chat.id for chat in self.chats]
26
+
27
+ async def add_chat(self, client, chat_id):
28
+ chat = await client.get_chat(chat_id)
29
+ self.chats.append(chat)
30
+ self.chat_ids.append(chat.id)
31
+ return chat
32
+
33
+ async def remove_chat(self, client, chat_id):
34
+ chat = await client.get_chat(chat_id)
35
+ for c in self.chats:
36
+ if c.id == chat.id:
37
+ index = self.chats.index(c)
38
+ self.chats.pop(index)
39
+ self.chat_ids.remove(chat.id)
40
+ return chat
41
+
42
+ async def process(self, client, event) -> bool:
43
+ if self.chat_ids and not self.chats:
44
+ await self.update_chats(client)
45
+ if not event.author:
46
+ return False
47
+ chats = copy(self.chats)
48
+ if self.source_chat:
49
+ chats.append(event.chat if isinstance(event, Message) else event.message.chat)
50
+ event.not_accepted_chats = []
51
+ for chat in chats:
52
+ try:
53
+ chat_member = await client.get_chat_member(chat.id, event.author.id)
54
+ except ForbiddenError as error:
55
+ raise error
56
+ except RPCError:
57
+ event.not_accepted_chats.append(chat)
58
+ else:
59
+ if chat_member.status not in self.accepted_statuses:
60
+ event.not_accepted_chats.append(chat)
61
+ return not bool(event.not_accepted_chats)
@@ -0,0 +1,7 @@
1
+ from .condition import create
2
+ from ..objects import Message
3
+
4
+
5
+ @create(can_process=Message)
6
+ def left_chat_member(event) -> bool:
7
+ return bool(event.left_chat_member)
@@ -0,0 +1,7 @@
1
+ from .condition import create
2
+ from ..objects import Message
3
+
4
+
5
+ @create(can_process=Message)
6
+ def location(event) -> bool:
7
+ return bool(event.location)
@@ -0,0 +1,7 @@
1
+ from .condition import create
2
+ from ..objects import Message
3
+
4
+
5
+ @create(can_process=Message)
6
+ def media(event) -> bool:
7
+ return bool(event.animation or event.audio or event.document or event.photo or event.video or event.voice)
@@ -0,0 +1,7 @@
1
+ from .condition import create
2
+ from ..objects import Message
3
+
4
+
5
+ @create(can_process=Message)
6
+ def media_group(event) -> bool:
7
+ return bool(event.media_group_id)