PycordViews 1.3.0__py3-none-any.whl → 1.3.1__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.
- pycordViews/multibot/errors.py +5 -1
- pycordViews/multibot/multibot.py +28 -1
- pycordViews/multibot/process.py +43 -3
- pycordViews/views/easy_modified_view.py +3 -3
- {pycordviews-1.3.0.dist-info → pycordviews-1.3.1.dist-info}/METADATA +1 -1
- {pycordviews-1.3.0.dist-info → pycordviews-1.3.1.dist-info}/RECORD +9 -9
- {pycordviews-1.3.0.dist-info → pycordviews-1.3.1.dist-info}/WHEEL +1 -1
- {pycordviews-1.3.0.dist-info → pycordviews-1.3.1.dist-info}/licenses/LICENSE +0 -0
- {pycordviews-1.3.0.dist-info → pycordviews-1.3.1.dist-info}/top_level.txt +0 -0
pycordViews/multibot/errors.py
CHANGED
@@ -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 !")
|
pycordViews/multibot/multibot.py
CHANGED
@@ -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
|
pycordViews/multibot/process.py
CHANGED
@@ -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
|
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
|
-
|
298
|
+
await self.shutdown()
|
299
299
|
if self.__call_on_timeout is not None:
|
300
|
-
|
300
|
+
await self.__call_on_timeout(self.__ctx)
|
301
301
|
|
302
302
|
def call_on_timeout(self, _callable: Callable) -> None:
|
303
303
|
"""
|
@@ -11,18 +11,18 @@ pycordViews/modal/easy_modal_view.py,sha256=sNxfSg6sgoiKa3vc6eKa4RV7vNVNaSrI1XUJ
|
|
11
11
|
pycordViews/modal/errors.py,sha256=nIGYyOS_oWH49Dj8ZGW53nnzaPmbvFbAo7ydikD5xWE,307
|
12
12
|
pycordViews/multibot/__init__.py,sha256=93Q_URiRUMsvwQJIqUnb75aq6SPM83yteSMrH0rmXMg,30
|
13
13
|
pycordViews/multibot/bot.py,sha256=pD-BPXNo7JeJPguTn7qLii0UzBSS4ITvmOPv8htKJG8,8284
|
14
|
-
pycordViews/multibot/errors.py,sha256=
|
15
|
-
pycordViews/multibot/multibot.py,sha256=
|
16
|
-
pycordViews/multibot/process.py,sha256=
|
14
|
+
pycordViews/multibot/errors.py,sha256=sPl_mM6b72Q8uuz4JkocO0TKBQ_9R3f0yT5eGhH_-PY,1328
|
15
|
+
pycordViews/multibot/multibot.py,sha256=625UTZ1FcgjR_BzXv2LZfkXonq9qosB_C1-zazr1pYs,9112
|
16
|
+
pycordViews/multibot/process.py,sha256=efSWVeHxrN88RdikUb3oOm8pAKgnQn2Q20CZqXGATfo,10114
|
17
17
|
pycordViews/pagination/__init__.py,sha256=rvOp-nGXZ6EX_ojK1_1lcOHYUcrB0LG3DL7zwatkRPY,105
|
18
18
|
pycordViews/pagination/errors.py,sha256=CYb5gBcXx0kYDUDkNpfUrqSxQAcJE_qfpomWtUFOsTk,316
|
19
19
|
pycordViews/pagination/page.py,sha256=sKi_gCFt1euY7uJKWgMnxEqP1B4LMhUysxQ8oQbhNVQ,1147
|
20
20
|
pycordViews/pagination/pagination_view.py,sha256=t6wvTLNTYg-w4eJQiyiX-LmEeR385SChifUzhiVSZBs,5793
|
21
21
|
pycordViews/views/__init__.py,sha256=yligptZmw-np8tjKLr76SVmi0807Nk6jCyKkKYLhbCY,89
|
22
|
-
pycordViews/views/easy_modified_view.py,sha256=
|
22
|
+
pycordViews/views/easy_modified_view.py,sha256=dOiSZ59zthRUV6s-mzdnql0o-z6hQM2ppKShJjmipu0,13992
|
23
23
|
pycordViews/views/errors.py,sha256=AkhGskuBjbFs0ZQdTDlVyfvAJ1WRMMQx2sAXUnYjmog,360
|
24
|
-
pycordviews-1.3.
|
25
|
-
pycordviews-1.3.
|
26
|
-
pycordviews-1.3.
|
27
|
-
pycordviews-1.3.
|
28
|
-
pycordviews-1.3.
|
24
|
+
pycordviews-1.3.1.dist-info/licenses/LICENSE,sha256=lNgcw1_xb7QENAQi3uHGymaFtbs0RV-ihiCd7AoLQjA,1082
|
25
|
+
pycordviews-1.3.1.dist-info/METADATA,sha256=Qf2sc2nqKIu9X02j7OEjSs4vVjHA5EC14fXgglLjVyI,12417
|
26
|
+
pycordviews-1.3.1.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
|
27
|
+
pycordviews-1.3.1.dist-info/top_level.txt,sha256=3NvgH6MjESe7Q6jb6aqHgdYrYb5NhxwxnoDyE6PkThY,125
|
28
|
+
pycordviews-1.3.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|