PycordViews 1.3.4__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.
@@ -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=30)
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
  """
@@ -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
- return result
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
- self.__main_queue.put({"type": "ADD", "bot_name": bot_name, "token": token, 'intents': intents})
55
- response = self.__get_data_queue()
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 remove_bot(self, bot_name: str) -> dict[str, str]:
67
+ def remove_bots(self, *bot_names: str) -> list[dict[str, str]]:
59
68
  """
60
- Shutdown and remove à bot
61
- :param bot_name: Bot name to remove
69
+ Shutdown and remove bots
70
+ :param bot_names: Bot name to remove
62
71
  """
63
- self.__main_queue.put({"type": "REMOVE", "bot_name": bot_name})
64
- response = self.__get_data_queue()
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': "START", 'bot_name': bot_name})
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': "STOP", 'bot_name': bot_name})
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': "RESTART", 'bot_name': bot_name})
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
- self.__main_queue.put({'type': "RESTARTALL"})
108
- return self.__get_data_queue()
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
- self.__main_queue.put({'type': "STARTALL"})
115
- return self.__get_data_queue()
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
- self.__main_queue.put({'type': "STOPALL"})
123
- return self.__get_data_queue()
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
- self.__main_queue.put({'type': "ADD_MODULES", 'modules_name': modules_name})
133
- return self.__get_data_queue()
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
- self.__main_queue.put({'type': "REMOVE_MODULES", 'modules_name': modules_name})
142
- return self.__get_data_queue()
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
- self.__main_queue.put({'type': "IS_STARTED", 'bot_name': bot_name})
151
- return self.__get_data_queue()['message']
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
- self.__main_queue.put({'type': "IS_READY", 'bot_name': bot_name})
160
- return self.__get_data_queue()['message']
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
- self.__main_queue.put({'type': "IS_WS_RATELIMITED", 'bot_name': bot_name})
169
- return self.__get_data_queue()['message']
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': "RELOAD_COMMANDS", 'name': name})
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
- self.__main_queue.put({'type': "ADD_COMMAND_FILE",
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': "MODIFY_COMMAND_FILE",
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
- self.__main_queue.put({'type': "BOT_COUNT"})
223
- return self.__get_data_queue()['message']
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
- self.__main_queue.put({'type': "STARTED_BOT_COUNT"})
231
- return self.__get_data_queue()['message']
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
- self.__main_queue.put({'type': "SHUTDOWN_BOT_COUNT"})
239
- return self.__get_data_queue()['message']
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
- self.__main_queue.put({'type': "BOTS_NAME"})
247
- return self.__get_data_queue()['message']
274
+ request_type = "BOTS_NAME"
275
+ self.__main_queue.put({'type': request_type})
276
+ return self.__get_data_queue(request_type)['message']
@@ -50,14 +50,14 @@ class ManageProcess:
50
50
  command: dict = self.main_queue.get()
51
51
  #print(command)
52
52
 
53
- c = command["type"]
54
- if c in self.commandes.keys():
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[c](**command)
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
  """
@@ -118,7 +118,7 @@ class EasyModifiedViews(View):
118
118
  :param custom_id: item ID of the view
119
119
  :param data: Add any data to pass in called function.
120
120
  :param autorised_roles: Any role ID allowed to interact with the view
121
- :param autorised_key: Callable function to check anything. The function get the current interaction passed in parameter
121
+ :param autorised_key: Callable function to check anything. The function get the current interaction and data passed in parameter
122
122
  """
123
123
 
124
124
  def decorator(_callable: Callable):
@@ -142,7 +142,7 @@ class EasyModifiedViews(View):
142
142
  :param _callable: The asynchronous callable linked. Take UI (Button, Select...) and Interaction parameters.
143
143
  :param data: Add any data to pass in called function.
144
144
  :param autorised_roles: Any role ID allowed to interact with the view
145
- :param autorised_key: Callable function to check anything. The function get the current interaction passed in parameter
145
+ :param autorised_key: Callable function to check anything. The function get the current interaction and data passed in parameter
146
146
 
147
147
  **UI, Interaction and data parameter is required in callable function !**
148
148
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PycordViews
3
- Version: 1.3.4
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** `remove_bot(bot_name: str) -> dict[str, str]` : Remove à bot. If the bot is online, it will turn off properly. It can take a long time !
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,19 +10,19 @@ 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=pD-BPXNo7JeJPguTn7qLii0UzBSS4ITvmOPv8htKJG8,8284
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=A_abouhHcellnBNbgN7uF9UheApQwptfUuDt2tZQZZc,9253
16
- pycordViews/multibot/process.py,sha256=-rJTw6ACfvMMinoAhQVGqPx76m0Nai5nymtDv1LrnxQ,10239
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
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=BbEnIfv4mVm4Glj45sAuYLbXIA1KRN699XdVVtmiaUo,14024
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.4.dist-info/licenses/LICENSE,sha256=lNgcw1_xb7QENAQi3uHGymaFtbs0RV-ihiCd7AoLQjA,1082
25
- pycordviews-1.3.4.dist-info/METADATA,sha256=WOeLWZAkCLc57fIOBHhy-U_w_ALSrHvXTJpJPXhI5jk,12417
26
- pycordviews-1.3.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
27
- pycordviews-1.3.4.dist-info/top_level.txt,sha256=3NvgH6MjESe7Q6jb6aqHgdYrYb5NhxwxnoDyE6PkThY,125
28
- pycordviews-1.3.4.dist-info/RECORD,,
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,,