Message period#
FixedDurationPeriod#
- class daf.message.messageperiod.FixedDurationPeriod(duration: timedelta, next_send_time: timedelta | datetime | None = None)#
A fixed message (sending) period.
- Parameters:
duration (timedelta) – The period duration (how much time to wait after every send).
next_send_time (datetime | timedelta) – Represents the time at which the message should first be sent. Use
datetime
to specify the exact date and time at which the message should start being sent. Usetimedelta
to specify how soon (after creation of the object) the message should start being sent.
- calculate()#
Calculates the next datetime the message is going to be sent.
RandomizedDurationPeriod#
- class daf.message.messageperiod.RandomizedDurationPeriod(minimum: timedelta, maximum: timedelta, next_send_time: timedelta | datetime | None = None)#
A randomized message (sending) period. After every send, the message will wait a different randomly chosen period within
minimum
andmaximum
.- Parameters:
minimum (timedelta) – Bottom limit of the randomized period.
maximum (timedelta) – Upper limit of the randomized period.
next_send_time (datetime | timedelta) – Represents the time at which the message should first be sent. Use
datetime
to specify the exact date and time at which the message should start being sent. Usetimedelta
to specify how soon (after creation of the object) the message should start being sent.
- calculate()#
Calculates the next datetime the message is going to be sent.
DaysOfWeekPeriod#
- class daf.message.messageperiod.DaysOfWeekPeriod(days: list[Literal['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']], time: time, next_send_time: timedelta | datetime | None = None)#
Represents a period that will send on
days
at specifictime
.E. g., parameters
days=["Mon", "Wed"]
andtime=time(hour=12, minute=0)
produce a behavior that will send a message every Monday and Wednesday at 12:00.- Parameters:
days (list[Literal["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]]) – List of day abbreviations on which the message will be sent.
time (
datetime.time
) – The time on which the message will be sent (every day ofdays
).next_send_time (datetime | timedelta) – Represents the time at which the message should first be sent. Use
datetime
to specify the exact date and time at which the message should start being sent. Usetimedelta
to specify how soon (after creation of the object) the message should start being sent.
- Raises:
ValueError – The
days
parameter was an empty list.
- calculate()#
Calculates the next datetime the message is going to be sent.
DailyPeriod#
- class daf.message.messageperiod.DailyPeriod(time: time, next_send_time: timedelta | datetime | None = None)#
Represents a daily send period. Messages will be sent every day at
time
.- Parameters:
time (time) – The time on which the message will be sent.
next_send_time (datetime | timedelta) – Represents the time at which the message should first be sent. Use
datetime
to specify the exact date and time at which the message should start being sent. Usetimedelta
to specify how soon (after creation of the object) the message should start being sent.
- calculate()#
Calculates the next datetime the message is going to be sent.