From f72a54a1f9ed8cbd3bee782e787918288b7404ae Mon Sep 17 00:00:00 2001 From: Michael Miele Date: Fri, 10 Jan 2020 11:50:56 -0800 Subject: [PATCH] Update conversation_state.py Added ref documentation. --- .../botbuilder/core/conversation_state.py | 32 +++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/libraries/botbuilder-core/botbuilder/core/conversation_state.py b/libraries/botbuilder-core/botbuilder/core/conversation_state.py index 94bc8fedb..11f6b328d 100644 --- a/libraries/botbuilder-core/botbuilder/core/conversation_state.py +++ b/libraries/botbuilder-core/botbuilder/core/conversation_state.py @@ -7,16 +7,41 @@ class ConversationState(BotState): - """Conversation State - Reads and writes conversation state for your bot to storage. + """Conversation state + Defines a state management object for conversation state. + Extends `BootState` base class. + + .. remarks:: + Conversation state is available in any turn in a specific conversation, regardless of user, such as in a group conversation. """ no_key_error_message = "ConversationState: channelId and/or conversation missing from context.activity." def __init__(self, storage: Storage): + """ Creates a :class:ConversationState instance + Creates a new instance of the :class:ConversationState class. + :param storage: The storage containing the conversation state. + :type storage: Storage + """ super(ConversationState, self).__init__(storage, "ConversationState") def get_storage_key(self, turn_context: TurnContext) -> object: + """ Get storage key + Gets the key to use when reading and writing state to and from storage. + + :param turn_context: The context object for this turn. + :type turn_context: TurnContext + + :raise: `TypeError` if the `ITurnContext.Activity` for the current turn is missing + :any::Schema.Activity.ChannelId or :any::Schema.Activity.Conversation information, or + the conversation's :any::Schema.ConversationAccount.Id is missing. + + :return: The storage key. + :rtype: str + + .. remarks:: + Conversation state includes the channel ID and conversation ID as part of its storage key. + """ channel_id = turn_context.activity.channel_id or self.__raise_type_error( "invalid activity-missing channel_id" ) @@ -31,4 +56,7 @@ def get_storage_key(self, turn_context: TurnContext) -> object: return storage_key def __raise_type_error(self, err: str = "NoneType found while expecting value"): + """ Raise type error + :raises: :class:TypeError This function raises exception. + """ raise TypeError(err)