PycordViews 1.1.4__py3-none-any.whl → 1.2.0__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.
@@ -1,80 +0,0 @@
1
-
2
- from typing import Union, Any
3
- from multiprocessing import Process, Queue, set_start_method, get_start_method
4
- from asyncio import create_task, sleep
5
- from time import sleep as tsleep
6
-
7
- from .process_for_bots import ProcessBot
8
- from .process_messages import ProcessMessage
9
-
10
-
11
- class Multibot:
12
-
13
- def __init__(self, limit_bots_in_tread: int = 10):
14
- """
15
- Create an instance of Multibot_asyncio class to manage few bots with asyncio.
16
- :param limit_bots_in_tread: Max running bot in a single asyncio loop in a thread.
17
- """
18
- if get_start_method() != "spawn":
19
- set_start_method("spawn")
20
-
21
- self.__queue_parent: Queue = Queue()
22
- self.__queue_children: Queue = Queue()
23
-
24
- self.__process: Union[Process] = Process(target=ProcessBot, args=(self.__queue_parent, self.__queue_children, limit_bots_in_tread)) # Process to run all bots
25
-
26
- async def start_process(self) -> "Multibot":
27
- """
28
- Start the process. It is required !
29
- """
30
- self.__process.start()
31
- create_task(self.__message_process_receiver())
32
-
33
- def __message_process_sender(self, message: dict):
34
- """
35
- Send a message to children process
36
- """
37
- print(f"Message envoyé par le parent : {message}")
38
- self.__queue_children.put(message)
39
-
40
- async def __message_process_receiver(self):
41
- """
42
- Wait message from children process (always a dict with the key "children_message")
43
- """
44
- while True:
45
- await sleep(0.02)
46
- while not self.__queue_parent.empty():
47
- try:
48
- message = self.__queue_parent.get_nowait()
49
- await self.__decode_message(message)
50
- except:
51
- break
52
-
53
- async def __decode_message(self, message: Any):
54
- """
55
- Decode the current message sent by the parent process
56
- :param message: The message.
57
- """
58
- print(message)
59
-
60
- async def add_bot(self, token: str, name: str = None, autoshared: bool = False, **kwargs):
61
- """
62
- Add a bot
63
- """
64
- data = {
65
- 'parent_message': ProcessMessage.ADD_BOT.value,
66
- 'token': token,
67
- 'name': name,
68
- 'autoshared': autoshared,
69
- }
70
- data.update(kwargs)
71
-
72
- self.__message_process_sender(data)
73
-
74
- async def run_all_bots(self):
75
- """
76
- Run all bots
77
- """
78
- self.__message_process_sender({'parent_message': ProcessMessage.RUN_ALL.value})
79
-
80
-
@@ -1,80 +0,0 @@
1
- Metadata-Version: 2.2
2
- Name: PycordViews
3
- Version: 1.1.4
4
- Summary: Views for py-cord library
5
- Home-page: https://github.com/BOXERRMD/Py-cord_Views
6
- Author: Chronos (alias BOXERRMD)
7
- Author-email: vagabonwalybi@gmail.com
8
- Maintainer: Chronos
9
- License: MIT License
10
- Classifier: Development Status :: 3 - Alpha
11
- Classifier: License :: OSI Approved :: MIT License
12
- Classifier: Natural Language :: English
13
- Classifier: Operating System :: Microsoft :: Windows :: Windows 11
14
- Classifier: Operating System :: Microsoft :: Windows :: Windows 10
15
- Classifier: Operating System :: POSIX :: Linux
16
- Classifier: Operating System :: MacOS
17
- Classifier: Programming Language :: Python :: 3.9
18
- Requires-Python: >=3.9
19
- Description-Content-Type: text/markdown
20
- License-File: LICENSE
21
- Requires-Dist: py-cord==2.6.1
22
- Dynamic: author
23
- Dynamic: author-email
24
- Dynamic: classifier
25
- Dynamic: description
26
- Dynamic: description-content-type
27
- Dynamic: home-page
28
- Dynamic: license
29
- Dynamic: maintainer
30
- Dynamic: requires-dist
31
- Dynamic: requires-python
32
- Dynamic: summary
33
-
34
- # Py-cord_Views
35
- Views for py-cord library
36
-
37
- ```python
38
- from pycordViews.pagination import Pagination
39
- from pycordViews.menu import SelectMenu
40
- import discord
41
-
42
- intents = discord.Intents.all()
43
- bot = discord.AutoShardedBot(intents=intents)
44
-
45
- @bot.command(name="My command paginator", description="...")
46
- async def pagination_command(ctx):
47
- """
48
- Create a command pagination
49
- """
50
- pages: Pagination = Pagination(timeout=None, disabled_on_timeout=False)
51
-
52
- pages.add_page(content="It's my first page !!", embed=None)# reset embed else he show the embed of the page after
53
-
54
- embed = discord.Embed(title="My embed title", description="..........")
55
- pages.add_page(content=None, embed=embed) # reset content else he show the content of the page before
56
-
57
- pages.add_page(content="My last page !", embed=None)# reset embed else he show the embed of the page before
58
-
59
- await pages.respond(ctx=ctx) # respond to the command
60
- await pages.send(send_to=ctx.author) # send the message to the command author
61
-
62
- @bot.command(name="My command select")
63
- async def select_command(ctx):
64
- """
65
- Create a command select
66
- """
67
- async def your_response(select, interaction):
68
- await interaction.response.send(f"You have selected {select.values[0]} !")
69
-
70
- my_selector = SelectMenu(timeout=None, disabled_on_timeout=False) # A basic selector menu
71
- my_menu = my_selector.add_string_select_menu(placeholder="Choice anything !") # add string_select UI
72
-
73
- my_menu.add_option(label="My first choice !", emoji="😊", default=True, description="It's the first choice !", value='first choice')
74
- my_menu.add_option(label="My second choice !", value='second choice')
75
- my_menu.set_callable(your_response)
76
-
77
- await my_selector.respond(ctx)
78
-
79
- bot.run("Your token")
80
- ```
@@ -1,22 +0,0 @@
1
- pycordViews/__init__.py,sha256=g2OUxHZYfJf5E6F5ytwYm6bcL88NjHU1-79SWW5XHPw,240
2
- pycordViews/menu/__init__.py,sha256=QUXA9ezyeTScvS1kxMNFgKEbZMsPq5yUnWWgbXCytCk,97
3
- pycordViews/menu/errors.py,sha256=0Um-oH5qMdWSZB_bGlqILsf9WSDtC4n_HwkheekiMV4,480
4
- pycordViews/menu/menu.py,sha256=JrPH2YE93JphB71w9lSHrAtlInn8PSUW3bYM1dRBbaM,4298
5
- pycordViews/menu/selectMenu.py,sha256=-eun3-EywSjiF_tzGTIQtuG99mkcAX0mMIKKBywvFtE,10428
6
- pycordViews/multibot/__init__.py,sha256=fP7jipm2AfsNyMLGgh4TEhvASA7NrPSLhSl2hU_xkw4,175
7
- pycordViews/multibot/errors.py,sha256=8C6jRRCOs3Y_tY_cvZIsGvz7XSreCkvWQ5ikj2hOf2s,238
8
- pycordViews/multibot/process_for_bots.py,sha256=O7Drpyy_A4y1zQq2D3SXLySWLJPnz6WVdynvTPk8gKM,3920
9
- pycordViews/multibot/process_messages.py,sha256=tt39bcfVOxTgo7_O4FPYA88spQMqx2Dvee1T2FyURmQ,108
10
- pycordViews/multibot/runner.py,sha256=ZyHTDu-wdZFbnoyEC00qe8MTf-STqFvrXytUE8Hr-Ec,406
11
- pycordViews/multibot/start_multibot.py,sha256=mHDBhiy7-Z3rvLbr8Ibqe9J9RXe_BusbZxq0aO3a16w,2598
12
- pycordViews/pagination/__init__.py,sha256=Z9BcdoTWyC1KXGwQ1_C0tu9rkZpdrrjEHwMmjXsckeE,81
13
- pycordViews/pagination/errors.py,sha256=CYb5gBcXx0kYDUDkNpfUrqSxQAcJE_qfpomWtUFOsTk,316
14
- pycordViews/pagination/pagination_view.py,sha256=sJHDkmiTGwJzxfAUQijF2ry6NPVwepJvbdkAvA6j0es,4846
15
- pycordViews/views/__init__.py,sha256=yligptZmw-np8tjKLr76SVmi0807Nk6jCyKkKYLhbCY,89
16
- pycordViews/views/easy_modified_view.py,sha256=QuS8AnkTLHrdKl7Tya0_gjuwhWHLIvMAEK3DsyE1ALg,8986
17
- pycordViews/views/errors.py,sha256=0NBjBDaSFZChJua1ho9qyfbNzwXy1U6Kcob5CCUxBK8,218
18
- pycordviews-1.1.4.dist-info/LICENSE,sha256=lNgcw1_xb7QENAQi3uHGymaFtbs0RV-ihiCd7AoLQjA,1082
19
- pycordviews-1.1.4.dist-info/METADATA,sha256=d1TMei7H42T-uSiZXentxHkNblnWMudJf6PQ4M31wO4,2897
20
- pycordviews-1.1.4.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
21
- pycordviews-1.1.4.dist-info/top_level.txt,sha256=nqBU40KmnSCjtry8kmv97-RvZC-8xQrhrrloOJX2ROs,91
22
- pycordviews-1.1.4.dist-info/RECORD,,