77
88
99class ConversationState (BotState ):
10- """Conversation State
11- Reads and writes conversation state for your bot to storage.
10+ """Conversation state
11+ Defines a state management object for conversation state.
12+ Extends `BootState` base class.
13+
14+ .. remarks::
15+ Conversation state is available in any turn in a specific conversation, regardless of user, such as in a group conversation.
1216 """
1317
1418 no_key_error_message = "ConversationState: channelId and/or conversation missing from context.activity."
1519
1620 def __init__ (self , storage : Storage ):
21+ """ Creates a :class:ConversationState instance
22+ Creates a new instance of the :class:ConversationState class.
23+ :param storage: The storage containing the conversation state.
24+ :type storage: Storage
25+ """
1726 super (ConversationState , self ).__init__ (storage , "ConversationState" )
1827
1928 def get_storage_key (self , turn_context : TurnContext ) -> object :
29+ """ Get storage key
30+ Gets the key to use when reading and writing state to and from storage.
31+
32+ :param turn_context: The context object for this turn.
33+ :type turn_context: TurnContext
34+
35+ :raise: `TypeError` if the `ITurnContext.Activity` for the current turn is missing
36+ :any::Schema.Activity.ChannelId or :any::Schema.Activity.Conversation information, or
37+ the conversation's :any::Schema.ConversationAccount.Id is missing.
38+
39+ :return: The storage key.
40+ :rtype: str
41+
42+ .. remarks::
43+ Conversation state includes the channel ID and conversation ID as part of its storage key.
44+ """
2045 channel_id = turn_context .activity .channel_id or self .__raise_type_error (
2146 "invalid activity-missing channel_id"
2247 )
@@ -31,4 +56,7 @@ def get_storage_key(self, turn_context: TurnContext) -> object:
3156 return storage_key
3257
3358 def __raise_type_error (self , err : str = "NoneType found while expecting value" ):
59+ """ Raise type error
60+ :raises: :class:TypeError This function raises exception.
61+ """
3462 raise TypeError (err )
0 commit comments