PycordViews 1.3.5__py3-none-any.whl → 1.3.6__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/bot.py +1 -1
- pycordViews/multibot/multibot.py +76 -47
- pycordViews/multibot/process.py +5 -5
- {pycordviews-1.3.5.dist-info → pycordviews-1.3.6.dist-info}/METADATA +8 -2
- {pycordviews-1.3.5.dist-info → pycordviews-1.3.6.dist-info}/RECORD +8 -8
- {pycordviews-1.3.5.dist-info → pycordviews-1.3.6.dist-info}/WHEEL +0 -0
- {pycordviews-1.3.5.dist-info → pycordviews-1.3.6.dist-info}/licenses/LICENSE +0 -0
- {pycordviews-1.3.5.dist-info → pycordviews-1.3.6.dist-info}/top_level.txt +0 -0
pycordViews/multibot/bot.py
CHANGED
@@ -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=
|
152
|
+
run_coroutine_threadsafe(self.__reload_commands(commands=commands), self.__loop).result(timeout=None)
|
153
153
|
|
154
154
|
async def __reload_commands(self, commands: Optional[list[ApplicationCommand]] = None):
|
155
155
|
"""
|
pycordViews/multibot/multibot.py
CHANGED
@@ -25,17 +25,22 @@ class Multibot:
|
|
25
25
|
|
26
26
|
self.global_timeout = global_timeout
|
27
27
|
|
28
|
-
def __get_data_queue(self) -> Union[list[dict], dict]:
|
28
|
+
def __get_data_queue(self, type: str) -> Union[list[dict], dict]:
|
29
29
|
"""
|
30
30
|
Récupère les données dans la queue processus
|
31
|
+
:param type: Type de la requête. Si elle ne correspond pas à la requête écoutée, elle refera un cicle d'écoute
|
31
32
|
"""
|
32
33
|
try:
|
33
34
|
result = self.__process_queue.get(timeout=self.global_timeout)
|
34
|
-
|
35
|
+
if result['type'] == type:
|
36
|
+
return result
|
37
|
+
else:
|
38
|
+
# Si le type ne correspond pas, on relance la récupération
|
39
|
+
return self.__get_data_queue(type)
|
35
40
|
except Empty:
|
36
41
|
return {'status': 'error', 'message': 'timeout request exceeded'}
|
37
42
|
except ValueError:
|
38
|
-
return {'status': 'critical error', 'message': 'queue was closed !'}
|
43
|
+
return {'status': 'critical error', 'message': 'queue was closed ! Process was killed ?'}
|
39
44
|
|
40
45
|
def _start_process(self):
|
41
46
|
"""
|
@@ -51,17 +56,24 @@ class Multibot:
|
|
51
56
|
:param token: Token bot
|
52
57
|
:param intents: Intents bot to Intents discord class
|
53
58
|
"""
|
54
|
-
|
55
|
-
|
59
|
+
request_type = "ADD"
|
60
|
+
self.__main_queue.put({"type": request_type,
|
61
|
+
"bot_name": bot_name,
|
62
|
+
"token": token,
|
63
|
+
"intents": intents})
|
64
|
+
response = self.__get_data_queue(request_type)
|
56
65
|
return response # Retourne le statut de l'ajout
|
57
66
|
|
58
|
-
def
|
67
|
+
def remove_bots(self, *bot_names: str) -> list[dict[str, str]]:
|
59
68
|
"""
|
60
|
-
Shutdown and remove
|
61
|
-
:param
|
69
|
+
Shutdown and remove bots
|
70
|
+
:param bot_names: Bot name to remove
|
62
71
|
"""
|
63
|
-
|
64
|
-
response =
|
72
|
+
request_type = "REMOVE"
|
73
|
+
response = []
|
74
|
+
for bot_name in bot_names:
|
75
|
+
self.__main_queue.put({"type": request_type, "bot_name": bot_name})
|
76
|
+
response.append(self.__get_data_queue(request_type))
|
65
77
|
return response # Retourne le statut de la suppression
|
66
78
|
|
67
79
|
def start(self, *bot_names: str) -> list[dict[str, str]]:
|
@@ -70,10 +82,11 @@ class Multibot:
|
|
70
82
|
:param bot_names: Bots name to start
|
71
83
|
:return: List of data bot status
|
72
84
|
"""
|
85
|
+
request_type = "START"
|
73
86
|
results = []
|
74
87
|
for bot_name in bot_names:
|
75
|
-
self.__main_queue.put({'type':
|
76
|
-
results.append(self.__get_data_queue())
|
88
|
+
self.__main_queue.put({'type': request_type, 'bot_name': bot_name})
|
89
|
+
results.append(self.__get_data_queue(request_type))
|
77
90
|
return results
|
78
91
|
|
79
92
|
def stop(self, *bot_names: str) -> list[dict[str, str]]:
|
@@ -82,10 +95,11 @@ class Multibot:
|
|
82
95
|
:param bot_names: Bots name to start
|
83
96
|
:return: Data status dict
|
84
97
|
"""
|
98
|
+
request_type = "STOP"
|
85
99
|
results = []
|
86
100
|
for bot_name in bot_names:
|
87
|
-
self.__main_queue.put({'type':
|
88
|
-
results.append(self.__get_data_queue())
|
101
|
+
self.__main_queue.put({'type': request_type, 'bot_name': bot_name})
|
102
|
+
results.append(self.__get_data_queue(request_type))
|
89
103
|
return results
|
90
104
|
|
91
105
|
def restart(self, *bot_names: str) -> list[dict[str, str]]:
|
@@ -93,10 +107,11 @@ class Multibot:
|
|
93
107
|
Stop and start bots.
|
94
108
|
This function is slow ! It's shutdown all bots properly.
|
95
109
|
"""
|
110
|
+
request_type = "RESTART"
|
96
111
|
results = []
|
97
112
|
for bot_name in bot_names:
|
98
|
-
self.__main_queue.put({'type':
|
99
|
-
results.append(self.__get_data_queue())
|
113
|
+
self.__main_queue.put({'type': request_type, 'bot_name': bot_name})
|
114
|
+
results.append(self.__get_data_queue(request_type))
|
100
115
|
return results
|
101
116
|
|
102
117
|
def restart_all(self):
|
@@ -104,23 +119,26 @@ class Multibot:
|
|
104
119
|
Stop and restart all bots
|
105
120
|
This function is slow ! It's shutdown all bots properly.
|
106
121
|
"""
|
107
|
-
|
108
|
-
|
122
|
+
request_type = "RESTARTALL"
|
123
|
+
self.__main_queue.put({'type': request_type})
|
124
|
+
return self.__get_data_queue(request_type)
|
109
125
|
|
110
126
|
def start_all(self) -> list[dict[str, list[str]]]:
|
111
127
|
"""
|
112
128
|
Start all bots in the process.
|
113
129
|
"""
|
114
|
-
|
115
|
-
|
130
|
+
request_type = "STARTALL"
|
131
|
+
self.__main_queue.put({'type': request_type})
|
132
|
+
return self.__get_data_queue(request_type)
|
116
133
|
|
117
134
|
def stop_all(self) -> list[dict[str, list[str]]]:
|
118
135
|
"""
|
119
136
|
Stop all bots in the process.
|
120
137
|
This function is slow ! It's shutdown all bots properly.
|
121
138
|
"""
|
122
|
-
|
123
|
-
|
139
|
+
request_type = "STOPALL"
|
140
|
+
self.__main_queue.put({'type': request_type})
|
141
|
+
return self.__get_data_queue(request_type)
|
124
142
|
|
125
143
|
def add_modules(self, *modules_name):
|
126
144
|
"""
|
@@ -129,8 +147,9 @@ class Multibot:
|
|
129
147
|
To be run before launching a bot!
|
130
148
|
:param modules_name: names of modules to be added
|
131
149
|
"""
|
132
|
-
|
133
|
-
|
150
|
+
request_type = "ADD_MODULES"
|
151
|
+
self.__main_queue.put({'type': request_type, 'modules_name': modules_name})
|
152
|
+
return self.__get_data_queue(request_type)
|
134
153
|
|
135
154
|
def remove_modules(self, *modules_name):
|
136
155
|
"""
|
@@ -138,8 +157,9 @@ class Multibot:
|
|
138
157
|
To be run before launching a bot!
|
139
158
|
:param modules_name: names of modules to be removed
|
140
159
|
"""
|
141
|
-
|
142
|
-
|
160
|
+
request_type = "REMOVE_MODULES"
|
161
|
+
self.__main_queue.put({'type': request_type, 'modules_name': modules_name})
|
162
|
+
return self.__get_data_queue(request_type)
|
143
163
|
|
144
164
|
def is_started(self, bot_name: str) -> bool:
|
145
165
|
"""
|
@@ -147,8 +167,9 @@ class Multibot:
|
|
147
167
|
:param bot_name: Bot name
|
148
168
|
:return: True if the Websocket is online, else False
|
149
169
|
"""
|
150
|
-
|
151
|
-
|
170
|
+
request_type = "IS_STARTED"
|
171
|
+
self.__main_queue.put({'type': request_type, 'bot_name': bot_name})
|
172
|
+
return self.__get_data_queue(request_type)['message']
|
152
173
|
|
153
174
|
def is_ready(self, bot_name: str) -> bool:
|
154
175
|
"""
|
@@ -156,8 +177,9 @@ class Multibot:
|
|
156
177
|
:param bot_name: Bot name
|
157
178
|
:return: True if the bot if ready, else False
|
158
179
|
"""
|
159
|
-
|
160
|
-
|
180
|
+
request_type = "IS_READY"
|
181
|
+
self.__main_queue.put({'type': request_type, 'bot_name': bot_name})
|
182
|
+
return self.__get_data_queue(request_type)['message']
|
161
183
|
|
162
184
|
def is_ws_ratelimited(self, bot_name: str) -> bool:
|
163
185
|
"""
|
@@ -165,18 +187,20 @@ class Multibot:
|
|
165
187
|
:param bot_name: Bot name
|
166
188
|
:return: True if the bot was ratelimited, else False
|
167
189
|
"""
|
168
|
-
|
169
|
-
|
190
|
+
request_type = "IS_WS_RATELIMITED"
|
191
|
+
self.__main_queue.put({'type': request_type, 'bot_name': bot_name})
|
192
|
+
return self.__get_data_queue(request_type)['message']
|
170
193
|
|
171
194
|
def reload_commands(self, *bot_names: str) -> list[dict[str, str]]:
|
172
195
|
"""
|
173
196
|
Reload all commands for each bot when bots are ready
|
174
197
|
:param bot_names: Bots name to reload commands
|
175
198
|
"""
|
199
|
+
request_type = "RELOAD_COMMANDS"
|
176
200
|
result = []
|
177
201
|
for name in bot_names:
|
178
|
-
self.__main_queue.put({'type':
|
179
|
-
result.append(self.__get_data_queue())
|
202
|
+
self.__main_queue.put({'type': request_type, 'name': name})
|
203
|
+
result.append(self.__get_data_queue(request_type))
|
180
204
|
return result
|
181
205
|
|
182
206
|
def add_pyFile_commands(self, bot_name: str, file: str, setup_function: str = 'setup', reload_command: bool = True) -> dict[str, str]:
|
@@ -192,12 +216,13 @@ class Multibot:
|
|
192
216
|
:param setup_function: Function name called by the process to give the Bot instance. Set to 'setup' by default.
|
193
217
|
:param reload_command: Reload all command in the fil and dependencies. Default : True
|
194
218
|
"""
|
195
|
-
|
219
|
+
request_type = "ADD_COMMAND_FILE"
|
220
|
+
self.__main_queue.put({'type': request_type,
|
196
221
|
'bot_name': bot_name,
|
197
222
|
'file': file,
|
198
223
|
'setup_function': setup_function,
|
199
224
|
'reload_command': reload_command})
|
200
|
-
return self.__get_data_queue()
|
225
|
+
return self.__get_data_queue(request_type)
|
201
226
|
|
202
227
|
def modify_pyFile_commands(self, bot_name: str, file: str, setup_function: str = 'setup') -> dict[str, str]:
|
203
228
|
|
@@ -207,41 +232,45 @@ class Multibot:
|
|
207
232
|
:param bot_name: The bot's name
|
208
233
|
:param file: The file's relative or absolute path
|
209
234
|
"""
|
210
|
-
|
211
|
-
self.__main_queue.put({'type':
|
235
|
+
request_type = "MODIFY_COMMAND_FILE"
|
236
|
+
self.__main_queue.put({'type': request_type,
|
212
237
|
'bot_name': bot_name,
|
213
238
|
'file': file,
|
214
239
|
'setup_function': setup_function})
|
215
|
-
return self.__get_data_queue()
|
240
|
+
return self.__get_data_queue(request_type)
|
216
241
|
|
217
242
|
@property
|
218
243
|
def bot_count(self) -> int:
|
219
244
|
"""
|
220
245
|
Return the total number of bots
|
221
246
|
"""
|
222
|
-
|
223
|
-
|
247
|
+
request_type = "BOT_COUNT"
|
248
|
+
self.__main_queue.put({'type': request_type})
|
249
|
+
return self.__get_data_queue(request_type)['message']
|
224
250
|
|
225
251
|
@property
|
226
252
|
def started_bot_count(self) -> int:
|
227
253
|
"""
|
228
254
|
Return the total number of started bots
|
229
255
|
"""
|
230
|
-
|
231
|
-
|
256
|
+
request_type = "STARTED_BOT_COUNT"
|
257
|
+
self.__main_queue.put({'type': request_type})
|
258
|
+
return self.__get_data_queue(request_type)['message']
|
232
259
|
|
233
260
|
@property
|
234
261
|
def shutdown_bot_count(self) -> int:
|
235
262
|
"""
|
236
263
|
Return the total number of shutdown bots
|
237
264
|
"""
|
238
|
-
|
239
|
-
|
265
|
+
request_type = "SHUTDOWN_BOT_COUNT"
|
266
|
+
self.__main_queue.put({'type': request_type})
|
267
|
+
return self.__get_data_queue(request_type)['message']
|
240
268
|
|
241
269
|
@property
|
242
270
|
def get_bots_name(self) -> list[str]:
|
243
271
|
"""
|
244
272
|
Return all bots name (not real name of bots)
|
245
273
|
"""
|
246
|
-
|
247
|
-
|
274
|
+
request_type = "BOTS_NAME"
|
275
|
+
self.__main_queue.put({'type': request_type})
|
276
|
+
return self.__get_data_queue(request_type)['message']
|
pycordViews/multibot/process.py
CHANGED
@@ -50,14 +50,14 @@ class ManageProcess:
|
|
50
50
|
command: dict = self.main_queue.get()
|
51
51
|
#print(command)
|
52
52
|
|
53
|
-
|
54
|
-
if
|
53
|
+
type_request = command["type"]
|
54
|
+
if type_request in self.commandes.keys():
|
55
55
|
del command['type']
|
56
56
|
try:
|
57
|
-
result = self.commandes[
|
58
|
-
self.process_queue.put({'status': 'success', 'message': result})
|
57
|
+
result = self.commandes[type_request](**command)
|
58
|
+
self.process_queue.put({'status': 'success', 'message': result, 'type': type_request})
|
59
59
|
except MultibotError as e:
|
60
|
-
self.process_queue.put({'status': 'error', 'message': e})
|
60
|
+
self.process_queue.put({'status': 'error', 'message': e, 'type': type_request})
|
61
61
|
|
62
62
|
def start_bot_to_process(self, bot_name: str) -> str:
|
63
63
|
"""
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: PycordViews
|
3
|
-
Version: 1.3.
|
3
|
+
Version: 1.3.6
|
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)
|
@@ -169,7 +169,7 @@ Each instance of this class creates a process where bots can be added. These bot
|
|
169
169
|
> ```
|
170
170
|
> > **Method** `add_bot(bot_name: str, token: str, intents: Intents) -> None` : Add a bot. The name given here is not the real bot name, it's juste an ID
|
171
171
|
>
|
172
|
-
> > **Method** `
|
172
|
+
> > **Method** `remove_bots(bot_names: str) -> list[dict[str, str]]` : Remove bots. If bots are online, they will turn off properly. It can take a long time !
|
173
173
|
>
|
174
174
|
> > **Method** `start(*bot_names: str) -> list[dict[str, str]]` : Start bots
|
175
175
|
>
|
@@ -177,10 +177,16 @@ Each instance of this class creates a process where bots can be added. These bot
|
|
177
177
|
>
|
178
178
|
> > **Method** `restart(*bot_names: str) -> list[dict[str, str]]` : Restarts bots
|
179
179
|
>
|
180
|
+
> > **Method** `restart_all() -> list[dict[str, str]]` : Restarts all bots in the process
|
181
|
+
>
|
180
182
|
> > **Method** `start_all() -> list[dict[str, list[str]]]` : Start all bot in the process
|
181
183
|
>
|
182
184
|
> > **Method** `stop_all() -> list[dict[str, list[str]]]` : Stop all bot in the process properly
|
183
185
|
>
|
186
|
+
> > **Method** `add_modules(*modules_name: str) -> list[dict[str, str]]` : Add a module to the process. It can be only a package to download from pypi. Install the package for all bots in the process.
|
187
|
+
>
|
188
|
+
> > **Method** `remove_modules(*modules_name: str) -> list[dict[str, str]]` : Remove a module from the process. It can be only a package to download from pypi. Uninstall the package for all bots in the process. If modules was used by a bot, an error was raised when the bot attempt to use it.
|
189
|
+
>
|
184
190
|
> > **Method** `is_started(bot_name: str) -> bool` : Return if the bot is connected at the Discord WebSocket
|
185
191
|
>
|
186
192
|
> > **Method** `is_ready(bot_name: str) -> bool` : Return if the bot is ready in Discord
|
@@ -10,10 +10,10 @@ pycordViews/modal/__init__.py,sha256=TFUX3z25oInBhBzoOQhnLbKmwArXo4IVVqBfN6y11Bo
|
|
10
10
|
pycordViews/modal/easy_modal_view.py,sha256=sNxfSg6sgoiKa3vc6eKa4RV7vNVNaSrI1XUJ9RMSD80,4281
|
11
11
|
pycordViews/modal/errors.py,sha256=nIGYyOS_oWH49Dj8ZGW53nnzaPmbvFbAo7ydikD5xWE,307
|
12
12
|
pycordViews/multibot/__init__.py,sha256=93Q_URiRUMsvwQJIqUnb75aq6SPM83yteSMrH0rmXMg,30
|
13
|
-
pycordViews/multibot/bot.py,sha256=
|
13
|
+
pycordViews/multibot/bot.py,sha256=GuA7gw5YUfTyEwgJKF5hSEqGfmQL1nE3yr9eArEi0_8,8286
|
14
14
|
pycordViews/multibot/errors.py,sha256=sPl_mM6b72Q8uuz4JkocO0TKBQ_9R3f0yT5eGhH_-PY,1328
|
15
|
-
pycordViews/multibot/multibot.py,sha256=
|
16
|
-
pycordViews/multibot/process.py,sha256
|
15
|
+
pycordViews/multibot/multibot.py,sha256=ENzMU-FN2Xl-eu1At1f_1rRwUu1EKDaHnhP-mZcnJeE,10759
|
16
|
+
pycordViews/multibot/process.py,sha256=3PIhciUuOdruYh88j-fM-XOVk_7-cIV9sFUQ-fWbs_Q,10316
|
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
|
@@ -21,8 +21,8 @@ pycordViews/pagination/pagination_view.py,sha256=t6wvTLNTYg-w4eJQiyiX-LmEeR385SC
|
|
21
21
|
pycordViews/views/__init__.py,sha256=yligptZmw-np8tjKLr76SVmi0807Nk6jCyKkKYLhbCY,89
|
22
22
|
pycordViews/views/easy_modified_view.py,sha256=3WM3dFflPjIK6_8cXrSsLK27dAqnEZ0kKDq4-wQ8HMo,14042
|
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.6.dist-info/licenses/LICENSE,sha256=lNgcw1_xb7QENAQi3uHGymaFtbs0RV-ihiCd7AoLQjA,1082
|
25
|
+
pycordviews-1.3.6.dist-info/METADATA,sha256=yjtSJAbl3GI4er98xhtE-Xrqk__fT9tyVanIDOBwPYw,13022
|
26
|
+
pycordviews-1.3.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
27
|
+
pycordviews-1.3.6.dist-info/top_level.txt,sha256=3NvgH6MjESe7Q6jb6aqHgdYrYb5NhxwxnoDyE6PkThY,125
|
28
|
+
pycordviews-1.3.6.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|