PycordViews 1.3.0__tar.gz → 1.3.1__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.0 → pycordviews-1.3.1}/PKG-INFO +1 -1
  2. {pycordviews-1.3.0 → pycordviews-1.3.1}/PycordViews.egg-info/PKG-INFO +1 -1
  3. {pycordviews-1.3.0 → pycordviews-1.3.1}/pycordViews/multibot/errors.py +5 -1
  4. {pycordviews-1.3.0 → pycordviews-1.3.1}/pycordViews/multibot/multibot.py +28 -1
  5. {pycordviews-1.3.0 → pycordviews-1.3.1}/pycordViews/multibot/process.py +43 -3
  6. {pycordviews-1.3.0 → pycordviews-1.3.1}/pycordViews/views/easy_modified_view.py +3 -3
  7. {pycordviews-1.3.0 → pycordviews-1.3.1}/setup.py +1 -1
  8. {pycordviews-1.3.0 → pycordviews-1.3.1}/LICENSE +0 -0
  9. {pycordviews-1.3.0 → pycordviews-1.3.1}/PycordViews.egg-info/SOURCES.txt +0 -0
  10. {pycordviews-1.3.0 → pycordviews-1.3.1}/PycordViews.egg-info/dependency_links.txt +0 -0
  11. {pycordviews-1.3.0 → pycordviews-1.3.1}/PycordViews.egg-info/requires.txt +0 -0
  12. {pycordviews-1.3.0 → pycordviews-1.3.1}/PycordViews.egg-info/top_level.txt +0 -0
  13. {pycordviews-1.3.0 → pycordviews-1.3.1}/README.md +0 -0
  14. {pycordviews-1.3.0 → pycordviews-1.3.1}/pycordViews/__init__.py +0 -0
  15. {pycordviews-1.3.0 → pycordviews-1.3.1}/pycordViews/kit/__init__.py +0 -0
  16. {pycordviews-1.3.0 → pycordviews-1.3.1}/pycordViews/kit/confirm.py +0 -0
  17. {pycordviews-1.3.0 → pycordviews-1.3.1}/pycordViews/kit/poll.py +0 -0
  18. {pycordviews-1.3.0 → pycordviews-1.3.1}/pycordViews/menu/__init__.py +0 -0
  19. {pycordviews-1.3.0 → pycordviews-1.3.1}/pycordViews/menu/errors.py +0 -0
  20. {pycordviews-1.3.0 → pycordviews-1.3.1}/pycordViews/menu/menu.py +0 -0
  21. {pycordviews-1.3.0 → pycordviews-1.3.1}/pycordViews/menu/selectMenu.py +0 -0
  22. {pycordviews-1.3.0 → pycordviews-1.3.1}/pycordViews/modal/__init__.py +0 -0
  23. {pycordviews-1.3.0 → pycordviews-1.3.1}/pycordViews/modal/easy_modal_view.py +0 -0
  24. {pycordviews-1.3.0 → pycordviews-1.3.1}/pycordViews/modal/errors.py +0 -0
  25. {pycordviews-1.3.0 → pycordviews-1.3.1}/pycordViews/multibot/__init__.py +0 -0
  26. {pycordviews-1.3.0 → pycordviews-1.3.1}/pycordViews/multibot/bot.py +0 -0
  27. {pycordviews-1.3.0 → pycordviews-1.3.1}/pycordViews/pagination/__init__.py +0 -0
  28. {pycordviews-1.3.0 → pycordviews-1.3.1}/pycordViews/pagination/errors.py +0 -0
  29. {pycordviews-1.3.0 → pycordviews-1.3.1}/pycordViews/pagination/page.py +0 -0
  30. {pycordviews-1.3.0 → pycordviews-1.3.1}/pycordViews/pagination/pagination_view.py +0 -0
  31. {pycordviews-1.3.0 → pycordviews-1.3.1}/pycordViews/views/__init__.py +0 -0
  32. {pycordviews-1.3.0 → pycordviews-1.3.1}/pycordViews/views/errors.py +0 -0
  33. {pycordviews-1.3.0 → pycordviews-1.3.1}/pyproject.toml +0 -0
  34. {pycordviews-1.3.0 → pycordviews-1.3.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PycordViews
3
- Version: 1.3.0
3
+ Version: 1.3.1
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)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PycordViews
3
- Version: 1.3.0
3
+ Version: 1.3.1
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)
@@ -27,4 +27,8 @@ class SetupCommandFunctionNotFound(MultibotError):
27
27
 
28
28
  class CommandFileNotFoundError(MultibotError):
29
29
  def __init__(self, file_name: str):
30
- super().__init__(f"'{file_name}' file not found ! Init commands impossible.")
30
+ super().__init__(f"'{file_name}' file not found ! Init commands impossible !")
31
+
32
+ class ModuleNotFoundError(MultibotError):
33
+ def __init__(self, module_name: str):
34
+ super().__init__(f"{module_name} module not found !")
@@ -95,7 +95,15 @@ class Multibot:
95
95
  self.__main_queue.put({'type': "RESTART", 'bot_name': bot_name})
96
96
  results.append(self.__get_data_queue())
97
97
  return results
98
-
98
+
99
+ def restart_all(self):
100
+ """
101
+ Stop and restart all bots
102
+ This function is slow ! It's shutdown all bots properly.
103
+ """
104
+ self.__main_queue.put({'type': "RESTARTALL"})
105
+ return self.__get_data_queue()
106
+
99
107
  def start_all(self) -> list[dict[str, list[str]]]:
100
108
  """
101
109
  Start all bots in the process.
@@ -111,6 +119,25 @@ class Multibot:
111
119
  self.__main_queue.put({'type': "STOPALL"})
112
120
  return self.__get_data_queue()
113
121
 
122
+ def add_modules(self, *modules_name):
123
+ """
124
+ Adds modules (library) to the process (thus affecting bots).
125
+ Only previously removed modules can be added again!
126
+ To be run before launching a bot!
127
+ :param modules_name: names of modules to be added
128
+ """
129
+ self.__main_queue.put({'type': "ADD_MODULES", 'modules_name': modules_name})
130
+ return self.__get_data_queue()
131
+
132
+ def remove_modules(self, *modules_name):
133
+ """
134
+ Removes modules (library) to the process (thus affecting bots).
135
+ To be run before launching a bot!
136
+ :param modules_name: names of modules to be removed
137
+ """
138
+ self.__main_queue.put({'type': "REMOVE_MODULES", 'modules_name': modules_name})
139
+ return self.__get_data_queue()
140
+
114
141
  def is_started(self, bot_name: str) -> bool:
115
142
  """
116
143
  Return the current Websocket connexion status
@@ -1,9 +1,9 @@
1
1
  from multiprocessing import Queue
2
- from .errors import BotAlreadyExistError, BotNotFoundError, MultibotError, BotNotStartedError
2
+ from .errors import BotAlreadyExistError, BotNotFoundError, MultibotError, BotNotStartedError, ModuleNotFoundError
3
3
  from .bot import DiscordBot
4
4
  from discord import Intents
5
5
  from immutableType import Str_
6
- from typing import Optional
6
+ from sys import modules
7
7
 
8
8
  class ManageProcess:
9
9
 
@@ -14,6 +14,7 @@ class ManageProcess:
14
14
  self.__bots: dict[str, DiscordBot] = {}
15
15
  self.main_queue: Queue = main_queue
16
16
  self.process_queue: Queue = process_queue
17
+ self.removed_modules: dict[str, "ModuleType"] = {}
17
18
 
18
19
  self.commandes = {
19
20
  "ADD": self.add_bot_to_process,
@@ -26,13 +27,16 @@ class ManageProcess:
26
27
  "IS_WS_RATELIMITED": self.is_ws_ratelimited,
27
28
  "STOPALL": self.stop_all_bot_to_process,
28
29
  "STARTALL": self.start_all_bot_to_process,
30
+ "RESTARTALL": self.restart_all_bot_to_process,
29
31
  "BOT_COUNT": self.bot_count,
30
32
  "STARTED_BOT_COUNT": self.started_bot_count,
31
33
  "SHUTDOWN_BOT_COUNT": self.shutdown_bot_count,
32
34
  "BOTS_bot_name": self.get_bots_bot_name,
33
35
  "RELOAD_COMMANDS": self.reload_all_commands,
34
36
  "ADD_COMMAND_FILE": self.add_pyFile_commands,
35
- "MODIFY_COMMAND_FILE": self.modify_pyFile_commands
37
+ "MODIFY_COMMAND_FILE": self.modify_pyFile_commands,
38
+ "REMOVE_MODULES": self.remove_modules,
39
+ "ADD_MODULES": self.add_modules
36
40
  }
37
41
 
38
42
  def run(self):
@@ -82,6 +86,15 @@ class ManageProcess:
82
86
  self.__bots[bot_name].reload_pyFile_commands()
83
87
  return f'{bot_name} bot restarted'
84
88
 
89
+ def restart_all_bot_to_process(self) -> list[str]:
90
+ """
91
+ Redémarre tous les bots du processus
92
+ """
93
+ result = []
94
+ for bot in self.__bots.keys():
95
+ result.append(self.restart_bot_to_process(bot))
96
+ return result
97
+
85
98
  def start_all_bot_to_process(self) -> list[str]:
86
99
  """
87
100
  Start tous les bots du processus
@@ -166,6 +179,33 @@ class ManageProcess:
166
179
  del self.__bots[bot_name]
167
180
  return f'Bot {bot_name} removed'
168
181
 
182
+ def remove_modules(self, modules_name: tuple[str]):
183
+ """
184
+ Enlève les modules (bibliothèque) de tous le processus (affecte donc les bots).
185
+ A éxécuter avant de lancer un bot !
186
+ :param modules_name: Tuple contenant les noms des modules à enlever
187
+ """
188
+ for module in modules_name:
189
+ if module in modules_name:
190
+ self.removed_modules[module] = modules.pop(module)
191
+ else:
192
+ raise ModuleNotFoundError(module)
193
+ return f"[{', '.join(modules_name)}] modules removed"
194
+
195
+ def add_modules(self, modules_name: tuple[str]):
196
+ """
197
+ Ajoute les modules (bibliothèque) de tous le processus (affecte donc les bots).
198
+ Uniquement les modules enlever au préalable peuvent-être de nouveau ajouter !
199
+ A éxécuter avant de lancer un bot !
200
+ :param modules_name: Tuple contenant les noms des modules à ajouter
201
+ """
202
+ for module in modules_name:
203
+ if module in self.removed_modules.keys():
204
+ modules[module] = self.removed_modules.pop(module)
205
+ else:
206
+ raise ModuleNotFoundError(module)
207
+ return f"[{', '.join(modules_name)}] modules added"
208
+
169
209
  def is_started(self, bot_name: str) -> bool:
170
210
  """
171
211
  Regarde si la connexion au Websocket est effectué
@@ -290,14 +290,14 @@ class EasyModifiedViews(View):
290
290
 
291
291
  await self._update()
292
292
 
293
- def on_timeout(self) -> None:
293
+ async def on_timeout(self) -> None:
294
294
  """
295
295
  Called if timeout view is finished
296
296
  """
297
297
  if self.__disabled_on_timeout:
298
- create_task(self.shutdown())
298
+ await self.shutdown()
299
299
  if self.__call_on_timeout is not None:
300
- create_task(self.__call_on_timeout(self.__ctx))
300
+ await self.__call_on_timeout(self.__ctx)
301
301
 
302
302
  def call_on_timeout(self, _callable: Callable) -> None:
303
303
  """
@@ -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.0",
8
+ version="1.3.1",
9
9
  url="https://github.com/BOXERRMD/Py-cord_Views",
10
10
  author="Chronos (alias BOXERRMD)",
11
11
  author_email="vagabonwalybi@gmail.com",
File without changes
File without changes
File without changes
File without changes