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. Use timedelta to specify how soon (after creation of the object) the message should start being sent.

adjust(minimum: timedelta) None#

Adjust the period to always be greater than the minimum.

calculate()#

Calculates the next datetime the message is going to be sent.

defer(dt: datetime)#

Defers advertising until dt This should be used for overriding the normal next datetime the message was supposed to be sent on.

get() datetime#

Returns 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 and maximum.

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. Use timedelta to specify how soon (after creation of the object) the message should start being sent.

adjust(minimum: timedelta) None#

Adjust the period to always be greater than the minimum.

calculate()#

Calculates the next datetime the message is going to be sent.

defer(dt: datetime)#

Defers advertising until dt This should be used for overriding the normal next datetime the message was supposed to be sent on.

get() datetime#

Returns 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 specific time.

E. g., parameters days=["Mon", "Wed"] and time=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 of days).

  • 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. Use timedelta 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.

adjust(minimum: timedelta) None#

Adjust the period to always be greater than the minimum.

defer(dt: datetime)#

Defers advertising until dt This should be used for overriding the normal next datetime the message was supposed to be sent on.

get() datetime#

Returns 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. Use timedelta to specify how soon (after creation of the object) the message should start being sent.

adjust(minimum: timedelta) None#

Adjust the period to always be greater than the minimum.

calculate()#

Calculates the next datetime the message is going to be sent.

defer(dt: datetime)#

Defers advertising until dt This should be used for overriding the normal next datetime the message was supposed to be sent on.

get() datetime#

Returns the next datetime the message is going to be sent.