Skip to content

Client

Reminder

A class to manage reminders.

PARAMETER DESCRIPTION
cycle

The cycle duration in milliseconds (default is 180ms). This determines how frequently the system checks for due schedules.

TYPE: int DEFAULT: 180

loop

The event loop to use, by default None (the current event loop is used).

TYPE: Optional[asyncio.AbstractEventLoop] DEFAULT: None

event

event(coro: Callable[..., Any]) -> None

Register a coroutine function as an event handler.

This method assigns the given coroutine function to be used as an event handler with the same name as the coroutine function.

PARAMETER DESCRIPTION
coro

The coroutine function to register as an event handler.

TYPE: Callable[..., Any]

Example
@client.event
async def on_initiate():
    ...

on_error async staticmethod

on_error(event_name: str, error: Exception, /, *args: Any, **kwargs: Any) -> None

Handle errors occurring during event dispatch.

This static method logs an exception that occurred during the processing of an event.

PARAMETER DESCRIPTION
event_name

The name of the event that caused the error.

TYPE: str

error

The exception that was raised.

TYPE: Exception

*args

Positional arguments passed to the event.

TYPE: Any DEFAULT: ()

**kwargs

Keyword arguments passed to the event.

TYPE: Any DEFAULT: {}

wait_for async

wait_for(schedule: Schedule) -> None

Wait for a schedule to complete based on its ID.

PARAMETER DESCRIPTION
schedule

The schedule object to wait for.

TYPE: Schedule

RAISES DESCRIPTION
ValueError

If no schedule with the given ID exists.

get_schedule_by_id

get_schedule_by_id(schedule_id: str) -> Schedule

Retrieve a schedule by its unique ID.

PARAMETER DESCRIPTION
schedule_id

The unique ID of the schedule to retrieve.

TYPE: str

RETURNS DESCRIPTION
Schedule

The schedule with the matching ID.

RAISES DESCRIPTION
ValueError

If no schedule with the given ID exists.

get_schedules

get_schedules() -> List[Schedule]

Retrieve all schedules.

RETURNS DESCRIPTION
List[Schedule]

A list of all schedules.

remove_schedule

remove_schedule(schedule_id: str) -> None

Remove a schedule by its unique ID.

PARAMETER DESCRIPTION
schedule_id

The unique ID of the schedule to remove.

TYPE: str

RAISES DESCRIPTION
ValueError

If no schedule with the given ID is found.

remove_schedule_by_title

remove_schedule_by_title(title: str) -> None

Remove a schedule by its title via the manager.

PARAMETER DESCRIPTION
title

The title of the schedule to remove.

TYPE: str

RAISES DESCRIPTION
ValueError

If no schedule with the given title is found.

add_schedule

add_schedule(title: Optional[str] = None, duration: timedelta = timedelta(seconds=0), description: Optional[str] = None, callback: Optional[str] = None) -> Schedule

Add a new reminder with a specified title, duration, and optional description.

PARAMETER DESCRIPTION
title

The title of the schedule.

TYPE: Optional[str] DEFAULT: None

duration

The duration of the schedule.

TYPE: timedelta DEFAULT: timedelta(seconds=0)

description

A description of the schedule.

TYPE: Optional[str] DEFAULT: None

callback

A callback event name to be executed when the schedule ends.

TYPE: Optional[str] DEFAULT: None

start async

start()

Start the reminder system by initiating the event loop and controller.

run

run(log_handler: Optional[logging.Handler] = None, log_level: Optional[int] = None, root_logger: bool = False) -> None

Run the reminder system, setting up logging and starting the asynchronous event loop.

This method sets up the logging configuration and starts an asynchronous loop to run the main process, including the event handler and scheduler.

PARAMETER DESCRIPTION
log_handler

A logging handler to manage log outputs. If None, default logging handler will be used. (default is None)

TYPE: Optional[logging.Handler] DEFAULT: None

log_level

The log level to use for logging output. If None, the default level will be used. (default is None)

TYPE: Optional[int] DEFAULT: None

root_logger

Whether to set up the root logger. (default is False)

TYPE: bool DEFAULT: False