src.bot.state module

class src.bot.state.BotState(_lock: allocate_lock, _daily_target_time: str | None = None, _active_channel: str | None = None, _selected_preset: str | None = None, _selected_mode: str | None = None, _random_start_time: str | None = None, _random_end_time: str | None = None, _static_time: str | None = None, _active_days: Set[str] = <factory>, _active_token: str | None = None, _pending_topic: str | None = None, _active_tags: Set[str] = <factory>, _last_prompt_ts: str | None = None, _reminder_sent: bool = False, _reminder_enabled: bool = False, _pending_custom_prompt: str | None = None, _user_prompt_creator_used_today: bool = False, _social_connector_used_today: bool = False, _mentor_checkin_week: int | None = None, _prompt_response_type: str = 'image', _last_prompt_channel: str | None = None)[source]

Bases: object

Thread-safe per-workspace bot configuration and runtime state.

get_active_channel() str | None[source]

Return the Slack channel ID where prompts will be posted.

get_active_days() Set[str][source]

Return a snapshot of the weekday names on which prompts are posted.

get_active_tags() Set[str][source]

Return a snapshot of the active tag filter set.

get_active_token() str | None[source]

Return the Slack bot token for this workspace.

get_and_clear_pending_custom_prompt() str | None[source]

Return the pending custom prompt text and clear it so it is used only once.

get_and_clear_pending_topic() str | None[source]

Returns the pending topic and clears it so it only applies once.

get_daily_target_time() str | None[source]

Return the resolved daily target time (HH:MM) for the current day.

get_last_prompt_channel() str | None[source]

Return the channel ID where the most recent prompt was posted.

get_last_prompt_ts() str | None[source]

Return the Slack message timestamp of the last posted prompt.

get_mentor_checkin_week() int | None[source]

Return the ISO week number when the last mentor check-in was sent.

get_prompt_response_type() str[source]

Return the expected response type for prompts: ‘image’, ‘text’, or ‘any’.

get_random_end_time() str | None[source]

Return the latest time (HH:MM) for random prompt scheduling.

get_random_start_time() str | None[source]

Return the earliest time (HH:MM) for random prompt scheduling.

get_reminder_enabled() bool[source]

Return whether prompt reminders are enabled for this workspace.

get_reminder_sent() bool[source]

Return whether a reminder has already been sent for the current prompt.

get_selected_mode() str | None[source]

Return the scheduling mode (e.g. ‘random’, ‘static’).

get_selected_preset() str | None[source]

Return the active scheduling preset name.

get_social_connector_used_today() bool[source]

Return whether the social connector flow has already run today.

get_static_time() str | None[source]

Return the fixed daily time (HH:MM) used in static scheduling mode.

get_user_prompt_creator_used_today() bool[source]

Return whether a user has already been invited to create a prompt today.

is_today_active() bool[source]

Return True if today’s weekday is in the active days set.

set_active_channel(channel: str | None) None[source]

Set the Slack channel ID where prompts will be posted.

set_active_days(days: Set[str]) None[source]

Replace the set of weekday names on which prompts are posted.

set_active_tags(tags: Set[str]) None[source]

Replace the set of tags used to filter prompt selection.

set_active_token(token: str | None) None[source]

Store the Slack bot token for this workspace.

set_daily_target_time(t: str | None) None[source]

Set the resolved daily target time (HH:MM) for the current day.

set_last_prompt_channel(channel: str | None) None[source]

Set the channel ID where the most recent prompt was posted.

set_last_prompt_ts(ts: str | None, channel: str | None = None) None[source]

Store the timestamp of the last prompt and reset the reminder flag.

set_mentor_checkin_week(week: int | None) None[source]

Store the ISO week number when the last mentor check-in was sent.

set_pending_custom_prompt(text: str | None) None[source]

Queue a user-authored prompt text to be used instead of a generated one.

set_pending_topic(topic: str | None) None[source]

Queue a topic to be used as context for the next prompt.

set_prompt_response_type(value: str) None[source]

Set the expected response type for prompts: ‘image’, ‘text’, or ‘any’.

set_random_end_time(value: str | None) None[source]

Set the latest time (HH:MM) for random prompt scheduling.

set_random_start_time(value: str | None) None[source]

Set the earliest time (HH:MM) for random prompt scheduling.

set_reminder_enabled(value: bool) None[source]

Enable or disable prompt reminders for this workspace.

set_reminder_sent(value: bool) None[source]

Mark whether a reminder has been sent for the current prompt.

set_selected_mode(value: str | None) None[source]

Set the scheduling mode (e.g. ‘random’, ‘static’).

set_selected_preset(value: str | None) None[source]

Set the active scheduling preset name.

set_social_connector_used_today(value: bool) None[source]

Mark whether the social connector flow has already run today.

set_static_time(value: str | None) None[source]

Set the fixed daily time (HH:MM) used in static scheduling mode.

set_user_prompt_creator_used_today(value: bool) None[source]

Mark whether a user has already been invited to create a prompt today.

class src.bot.state.StateManager[source]

Bases: object

Registry that maps workspace team IDs to their BotState instances.

all_states() dict[source]

Return a shallow copy of the team_id → BotState mapping.

get_state(team_id: str) BotState[source]

Return the BotState for the given team, creating one if it does not exist.

src.bot.state.create_state(default_channel: str | None = None) BotState[source]

Create a new BotState with a fresh lock, optionally pre-setting the active channel.

src.bot.state.get_team_id(body: dict) str | None[source]

Extract team_id from a Slack request body, handling both slash commands and block actions.