rewrite: New Pomodoro Timer system.

This commit is contained in:
2023-05-19 09:45:06 +03:00
parent 8d5840c696
commit 4aa2587c45
29 changed files with 2860 additions and 12 deletions

View File

@@ -316,7 +316,7 @@ class MessageUI(LeoUI):
"""
raise NotImplementedError
async def draw(self, interaction, force_followup=False):
async def draw(self, interaction, force_followup=False, **kwargs):
"""
Send the UI as a response or followup to the given interaction.
@@ -332,10 +332,10 @@ class MessageUI(LeoUI):
as_followup = force_followup or interaction.response.is_done()
if as_followup:
self._message = await interaction.followup.send(**args.send_args, view=self)
self._message = await interaction.followup.send(**args.send_args, **kwargs, view=self)
else:
self._original = interaction
await interaction.response.send_message(**args.send_args, view=self)
await interaction.response.send_message(**args.send_args, **kwargs, view=self)
async def redraw(self, thinking: Optional[discord.Interaction] = None):
"""

View File

@@ -76,8 +76,8 @@ class FastModal(LeoModal):
return
try:
await coro(interaction, *pass_args, **pass_kwargs)
except Exception as error:
await self.on_error(interaction, error)
except Exception:
raise
finally:
if once:
self._waiters.remove(wrapped_callback)
@@ -100,12 +100,20 @@ class FastModal(LeoModal):
await super().on_error(interaction, error)
async def on_submit(self, interaction):
print("On submit")
old_result = self._result
self._result = asyncio.get_event_loop().create_future()
old_result.set_result(interaction)
tasks = []
for waiter in self._waiters:
asyncio.create_task(waiter(interaction), name=f"leo-ui-fastmodal-{self.id}-callback-{waiter.__name__}")
task = asyncio.create_task(
waiter(interaction),
name=f"leo-ui-fastmodal-{self.id}-callback-{waiter.__name__}"
)
tasks.append(task)
if tasks:
await asyncio.gather(*tasks)
async def input(