PycordViews 1.3.6__tar.gz → 1.3.6.2__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.
Files changed (34) hide show
  1. {pycordviews-1.3.6 → pycordviews-1.3.6.2}/PKG-INFO +8 -1
  2. {pycordviews-1.3.6 → pycordviews-1.3.6.2}/PycordViews.egg-info/PKG-INFO +8 -1
  3. {pycordviews-1.3.6 → pycordviews-1.3.6.2}/PycordViews.egg-info/requires.txt +1 -0
  4. {pycordviews-1.3.6 → pycordviews-1.3.6.2}/README.md +6 -0
  5. {pycordviews-1.3.6 → pycordviews-1.3.6.2}/pycordViews/multibot/bot.py +2 -2
  6. {pycordviews-1.3.6 → pycordviews-1.3.6.2}/pycordViews/multibot/multibot.py +2 -1
  7. {pycordviews-1.3.6 → pycordviews-1.3.6.2}/pycordViews/multibot/process.py +35 -1
  8. {pycordviews-1.3.6 → pycordviews-1.3.6.2}/setup.py +3 -2
  9. {pycordviews-1.3.6 → pycordviews-1.3.6.2}/LICENSE +0 -0
  10. {pycordviews-1.3.6 → pycordviews-1.3.6.2}/PycordViews.egg-info/SOURCES.txt +0 -0
  11. {pycordviews-1.3.6 → pycordviews-1.3.6.2}/PycordViews.egg-info/dependency_links.txt +0 -0
  12. {pycordviews-1.3.6 → pycordviews-1.3.6.2}/PycordViews.egg-info/top_level.txt +0 -0
  13. {pycordviews-1.3.6 → pycordviews-1.3.6.2}/pycordViews/__init__.py +0 -0
  14. {pycordviews-1.3.6 → pycordviews-1.3.6.2}/pycordViews/kit/__init__.py +0 -0
  15. {pycordviews-1.3.6 → pycordviews-1.3.6.2}/pycordViews/kit/confirm.py +0 -0
  16. {pycordviews-1.3.6 → pycordviews-1.3.6.2}/pycordViews/kit/poll.py +0 -0
  17. {pycordviews-1.3.6 → pycordviews-1.3.6.2}/pycordViews/menu/__init__.py +0 -0
  18. {pycordviews-1.3.6 → pycordviews-1.3.6.2}/pycordViews/menu/errors.py +0 -0
  19. {pycordviews-1.3.6 → pycordviews-1.3.6.2}/pycordViews/menu/menu.py +0 -0
  20. {pycordviews-1.3.6 → pycordviews-1.3.6.2}/pycordViews/menu/selectMenu.py +0 -0
  21. {pycordviews-1.3.6 → pycordviews-1.3.6.2}/pycordViews/modal/__init__.py +0 -0
  22. {pycordviews-1.3.6 → pycordviews-1.3.6.2}/pycordViews/modal/easy_modal_view.py +0 -0
  23. {pycordviews-1.3.6 → pycordviews-1.3.6.2}/pycordViews/modal/errors.py +0 -0
  24. {pycordviews-1.3.6 → pycordviews-1.3.6.2}/pycordViews/multibot/__init__.py +0 -0
  25. {pycordviews-1.3.6 → pycordviews-1.3.6.2}/pycordViews/multibot/errors.py +0 -0
  26. {pycordviews-1.3.6 → pycordviews-1.3.6.2}/pycordViews/pagination/__init__.py +0 -0
  27. {pycordviews-1.3.6 → pycordviews-1.3.6.2}/pycordViews/pagination/errors.py +0 -0
  28. {pycordviews-1.3.6 → pycordviews-1.3.6.2}/pycordViews/pagination/page.py +0 -0
  29. {pycordviews-1.3.6 → pycordviews-1.3.6.2}/pycordViews/pagination/pagination_view.py +0 -0
  30. {pycordviews-1.3.6 → pycordviews-1.3.6.2}/pycordViews/views/__init__.py +0 -0
  31. {pycordviews-1.3.6 → pycordviews-1.3.6.2}/pycordViews/views/easy_modified_view.py +0 -0
  32. {pycordviews-1.3.6 → pycordviews-1.3.6.2}/pycordViews/views/errors.py +0 -0
  33. {pycordviews-1.3.6 → pycordviews-1.3.6.2}/pyproject.toml +0 -0
  34. {pycordviews-1.3.6 → pycordviews-1.3.6.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PycordViews
3
- Version: 1.3.6
3
+ Version: 1.3.6.2
4
4
  Summary: Views and multibot for py-cord library
5
5
  Home-page: https://github.com/BOXERRMD/Py-cord_Views
6
6
  Author: Chronos (alias BOXERRMD)
@@ -19,6 +19,7 @@ Requires-Python: >=3.9
19
19
  Description-Content-Type: text/markdown
20
20
  License-File: LICENSE
21
21
  Requires-Dist: immutable-Python-type
22
+ Requires-Dist: psutil
22
23
  Dynamic: author
23
24
  Dynamic: author-email
24
25
  Dynamic: classifier
@@ -35,6 +36,10 @@ Dynamic: summary
35
36
  # Py-cord_Views
36
37
  Views for py-cord library
37
38
 
39
+ DO NOT USE **MULTIBOT** CLASS FOR COMMERCIAL PURPOSES!
40
+ BOTS ARE NOT SEPARATED FROM EACH OTHER WHEN THEY ARE IN THE SAME PROCESS.
41
+ EACH BOT CAN ACCESS INFORMATION FROM OTHER BOTS CONTAINED IN THE SAME PROCESS.
42
+
38
43
  # Paginator
39
44
  The paginator instance is used to create a view acting as a “book”, with pages that can be turned using buttons.
40
45
  ## `Paginator`
@@ -226,6 +231,8 @@ Each instance of this class creates a process where bots can be added. These bot
226
231
  > > ```
227
232
  >
228
233
  > > **Method** `modify_pyFile_commands(bot_name: str, file: str, setup_function: str = 'setup') -> dict[str, str]` : Modify python discord command file and setup function. This method doesn't reload automatically commands on the bot. Use `reload_commands` after. `file` parameter require a file path, absolute or not.
234
+ >
235
+ > > **Method** `allow_subprocess(allow: bool) -> dict[str, str]` : Allow or disallow the use of subprocess to all bots in the current process. By default, it's allowed.
229
236
  >
230
237
  > > **@property** `bot_count -> int` : Return the total number of bots
231
238
  >
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PycordViews
3
- Version: 1.3.6
3
+ Version: 1.3.6.2
4
4
  Summary: Views and multibot for py-cord library
5
5
  Home-page: https://github.com/BOXERRMD/Py-cord_Views
6
6
  Author: Chronos (alias BOXERRMD)
@@ -19,6 +19,7 @@ Requires-Python: >=3.9
19
19
  Description-Content-Type: text/markdown
20
20
  License-File: LICENSE
21
21
  Requires-Dist: immutable-Python-type
22
+ Requires-Dist: psutil
22
23
  Dynamic: author
23
24
  Dynamic: author-email
24
25
  Dynamic: classifier
@@ -35,6 +36,10 @@ Dynamic: summary
35
36
  # Py-cord_Views
36
37
  Views for py-cord library
37
38
 
39
+ DO NOT USE **MULTIBOT** CLASS FOR COMMERCIAL PURPOSES!
40
+ BOTS ARE NOT SEPARATED FROM EACH OTHER WHEN THEY ARE IN THE SAME PROCESS.
41
+ EACH BOT CAN ACCESS INFORMATION FROM OTHER BOTS CONTAINED IN THE SAME PROCESS.
42
+
38
43
  # Paginator
39
44
  The paginator instance is used to create a view acting as a “book”, with pages that can be turned using buttons.
40
45
  ## `Paginator`
@@ -226,6 +231,8 @@ Each instance of this class creates a process where bots can be added. These bot
226
231
  > > ```
227
232
  >
228
233
  > > **Method** `modify_pyFile_commands(bot_name: str, file: str, setup_function: str = 'setup') -> dict[str, str]` : Modify python discord command file and setup function. This method doesn't reload automatically commands on the bot. Use `reload_commands` after. `file` parameter require a file path, absolute or not.
234
+ >
235
+ > > **Method** `allow_subprocess(allow: bool) -> dict[str, str]` : Allow or disallow the use of subprocess to all bots in the current process. By default, it's allowed.
229
236
  >
230
237
  > > **@property** `bot_count -> int` : Return the total number of bots
231
238
  >
@@ -1 +1,2 @@
1
1
  immutable-Python-type
2
+ psutil
@@ -1,6 +1,10 @@
1
1
  # Py-cord_Views
2
2
  Views for py-cord library
3
3
 
4
+ DO NOT USE **MULTIBOT** CLASS FOR COMMERCIAL PURPOSES!
5
+ BOTS ARE NOT SEPARATED FROM EACH OTHER WHEN THEY ARE IN THE SAME PROCESS.
6
+ EACH BOT CAN ACCESS INFORMATION FROM OTHER BOTS CONTAINED IN THE SAME PROCESS.
7
+
4
8
  # Paginator
5
9
  The paginator instance is used to create a view acting as a “book”, with pages that can be turned using buttons.
6
10
  ## `Paginator`
@@ -192,6 +196,8 @@ Each instance of this class creates a process where bots can be added. These bot
192
196
  > > ```
193
197
  >
194
198
  > > **Method** `modify_pyFile_commands(bot_name: str, file: str, setup_function: str = 'setup') -> dict[str, str]` : Modify python discord command file and setup function. This method doesn't reload automatically commands on the bot. Use `reload_commands` after. `file` parameter require a file path, absolute or not.
199
+ >
200
+ > > **Method** `allow_subprocess(allow: bool) -> dict[str, str]` : Allow or disallow the use of subprocess to all bots in the current process. By default, it's allowed.
195
201
  >
196
202
  > > **@property** `bot_count -> int` : Return the total number of bots
197
203
  >
@@ -77,7 +77,7 @@ class DiscordBot:
77
77
 
78
78
  def modify_pyFile_commands(self, file: str, setup_function: str):
79
79
  """
80
- Modifie un fichier de comandes et le recharge.
80
+ Modifie un fichier de commandes et le recharge.
81
81
  Ne recharge que le fichier et non les commandes du bot !
82
82
  :param file: Le chemin d'accès relatif ou absolue du fichier
83
83
  """
@@ -149,7 +149,7 @@ class DiscordBot:
149
149
  """
150
150
  Charge toutes les commandes du bot sur Discord
151
151
  """
152
- run_coroutine_threadsafe(self.__reload_commands(commands=commands), self.__loop).result(timeout=None)
152
+ run_coroutine_threadsafe(self.__reload_commands(commands=commands), self.__loop).result(timeout=60)
153
153
 
154
154
  async def __reload_commands(self, commands: Optional[list[ApplicationCommand]] = None):
155
155
  """
@@ -199,7 +199,7 @@ class Multibot:
199
199
  request_type = "RELOAD_COMMANDS"
200
200
  result = []
201
201
  for name in bot_names:
202
- self.__main_queue.put({'type': request_type, 'name': name})
202
+ self.__main_queue.put({'type': request_type, 'bot_name': name})
203
203
  result.append(self.__get_data_queue(request_type))
204
204
  return result
205
205
 
@@ -231,6 +231,7 @@ class Multibot:
231
231
  Reloads only the file, not the bot commands!
232
232
  :param bot_name: The bot's name
233
233
  :param file: The file's relative or absolute path
234
+ :param setup_function: Function name called by the process to give the Bot instance. Set to 'setup' by default.
234
235
  """
235
236
  request_type = "MODIFY_COMMAND_FILE"
236
237
  self.__main_queue.put({'type': request_type,
@@ -5,6 +5,7 @@ from discord import Intents
5
5
  from immutableType import Str_
6
6
  from sys import modules
7
7
  from os import system
8
+ from psutil import Process
8
9
 
9
10
  class ManageProcess:
10
11
 
@@ -16,6 +17,8 @@ class ManageProcess:
16
17
  self.main_queue: Queue = main_queue
17
18
  self.process_queue: Queue = process_queue
18
19
  self.removed_modules: dict[str, "ModuleType"] = {}
20
+ self.allow_create_subprocess: bool = True
21
+ self.process: Process = Process()
19
22
 
20
23
  self.commandes = {
21
24
  "ADD": self.add_bot_to_process,
@@ -37,7 +40,8 @@ class ManageProcess:
37
40
  "ADD_COMMAND_FILE": self.add_pyFile_commands,
38
41
  "MODIFY_COMMAND_FILE": self.modify_pyFile_commands,
39
42
  "REMOVE_MODULES": self.remove_modules,
40
- "ADD_MODULES": self.add_modules
43
+ "ADD_MODULES": self.add_modules,
44
+ "ALLOW_SUBPROCESS": self.allow_subprocess
41
45
  }
42
46
 
43
47
  def run(self):
@@ -45,6 +49,7 @@ class ManageProcess:
45
49
  Boucle principale du processus, écoute la queue principale.
46
50
  Doit comporter aubligatoirement un dictionnaire avec la clé 'type'
47
51
  """
52
+ wait_for = 0 # secondes avant de forcer la fermeture des subprocess
48
53
  while True:
49
54
  if not self.main_queue.empty():
50
55
  command: dict = self.main_queue.get()
@@ -59,6 +64,16 @@ class ManageProcess:
59
64
  except MultibotError as e:
60
65
  self.process_queue.put({'status': 'error', 'message': e, 'type': type_request})
61
66
 
67
+ if not self.allow_create_subprocess and wait_for > 50000 and (childrens_process := self.process.children()):
68
+ for i in childrens_process:
69
+ try:
70
+ i.kill()
71
+ except Exception:
72
+ pass
73
+ finally:
74
+ wait_for = 0
75
+ wait_for += 1
76
+
62
77
  def start_bot_to_process(self, bot_name: str) -> str:
63
78
  """
64
79
  Lance un unique bot
@@ -156,6 +171,15 @@ class ManageProcess:
156
171
  file = Str_(file).str_
157
172
  self.__bots[bot_name].modify_pyFile_commands(file=file, setup_function=setup_function)
158
173
 
174
+ def remove_pyFile_commands(self, bot_name: str, file: str):
175
+ """
176
+ Enlève un fichier de commandes et toutes ses commandes du bot.
177
+ :param bot_name: Le nom du bot
178
+ :param file: Le chemin d'accès relatif ou absolue du fichier
179
+ """
180
+ self.if_bot_no_exist(bot_name)
181
+ file = Str_(file).str_
182
+ self.__bots[bot_name].remove_pyFile_commands(file=file)
159
183
 
160
184
  def reload_all_commands(self, bot_name: str):
161
185
  """
@@ -271,3 +295,13 @@ class ManageProcess:
271
295
  Renvoie tous les noms des bots entrée par l'utilisateur
272
296
  """
273
297
  return list(self.__bots.keys())
298
+
299
+ def allow_subprocess(self, allow: bool) -> str:
300
+ """
301
+ Permet ou non l'utilisation de subprocess dans les bots.
302
+ ATTENTION : Peut poser des problèmes de sécurité si un utilisateur malveillant à accès au code.
303
+ Par défaut, False.
304
+ :param allow: True pour autoriser, False pour interdire
305
+ """
306
+ self.allow_create_subprocess = allow
307
+ return f'Subprocess allowed: {allow}'
@@ -5,7 +5,7 @@ with open("README.md", encoding='utf-8') as file:
5
5
 
6
6
  setup(
7
7
  name="PycordViews",
8
- version="1.3.6",
8
+ version="1.3.6.2",
9
9
  url="https://github.com/BOXERRMD/Py-cord_Views",
10
10
  author="Chronos (alias BOXERRMD)",
11
11
  author_email="vagabonwalybi@gmail.com",
@@ -25,7 +25,8 @@ setup(
25
25
  "Programming Language :: Python :: 3.9"
26
26
  ],
27
27
  install_requires=[
28
- "immutable-Python-type"
28
+ "immutable-Python-type",
29
+ "psutil"
29
30
  ],
30
31
  packages=['pycordViews', 'pycordViews/pagination', 'pycordViews/views', 'pycordViews/menu', 'pycordViews/multibot', 'pycordViews/kit', 'pycordViews/modal'],
31
32
  python_requires='>=3.9'
File without changes
File without changes