Skip to content

Commit 5e36083

Browse files
author
Michael Miele
committed
Update activity_handler.py
Code comments formatting.and repplaced remarks with note in methods.
1 parent ee0ec47 commit 5e36083

File tree

1 file changed

+54
-38
lines changed

1 file changed

+54
-38
lines changed

libraries/botbuilder-core/botbuilder/core/activity_handler.py

Lines changed: 54 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,23 @@
88

99
class ActivityHandler:
1010
async def on_turn(self, turn_context: TurnContext):
11-
""" Called by the adapter (for example, :class:`BotFrameworkAdapter`) at runtime
11+
"""
12+
Called by the adapter (for example, :class:`BotFrameworkAdapter`) at runtime
1213
in order to process an inbound :class:`botbuilder.schema.Activity`.
1314
14-
:param turn_context: The context object for this turn
15-
:type turn_context: :class:`TurnContext`
15+
:param turn_context: The context object for this turn
16+
:type turn_context: :class:`TurnContext`
1617
17-
:returns: A task that represents the work queued to execute
18+
:returns: A task that represents the work queued to execute
1819
19-
.. remarks::
20-
It calls other methods in this class based on the type of the activity to
21-
process, which allows a derived class to provide type-specific logic in a controlled way.
22-
In a derived class, override this method to add logic that applies to all activity types.
20+
.. remarks::
21+
It calls other methods in this class based on the type of the activity to
22+
process, which allows a derived class to provide type-specific logic in a controlled way.
23+
In a derived class, override this method to add logic that applies to all activity types.
2324
24-
.. note::
25-
- Add logic to apply before the type-specific logic and before the call to the :meth:`ActivityHandler.on_turn()` method.
26-
- Add logic to apply after the type-specific logic after the call to the :meth:`ActivityHandler.on_turn()` method.
25+
.. note::
26+
- Add logic to apply before the type-specific logic and before the call to the :meth:`ActivityHandler.on_turn()` method.
27+
- Add logic to apply after the type-specific logic after the call to the :meth:`ActivityHandler.on_turn()` method.
2728
"""
2829
if turn_context is None:
2930
raise TypeError("ActivityHandler.on_turn(): turn_context cannot be None.")
@@ -57,7 +58,8 @@ async def on_turn(self, turn_context: TurnContext):
5758
async def on_message_activity( # pylint: disable=unused-argument
5859
self, turn_context: TurnContext
5960
):
60-
"""Override this method in a derived class to provide logic specific to activities,
61+
"""
62+
Override this method in a derived class to provide logic specific to activities,
6163
such as the conversational logic.
6264
6365
:param turn_context: The context object for this turn
@@ -69,13 +71,15 @@ async def on_message_activity( # pylint: disable=unused-argument
6971
return
7072

7173
async def on_conversation_update_activity(self, turn_context: TurnContext):
72-
"""Invoked when a conversation update activity is received from the channel when the base behavior of :meth:`ActivityHandler.on_turn()` is used.
74+
"""
75+
Invoked when a conversation update activity is received from the channel when the base behavior of :meth:`ActivityHandler.on_turn()` is used.
7376
7477
:param turn_context: The context object for this turn
7578
:type turn_context: :class:`TurnContext`
79+
7680
:returns: A task that represents the work queued to execute
7781
78-
.. remarks::
82+
.. note::
7983
When the :meth:'ActivityHandler.on_turn()` method receives a conversation update activity, it calls this method.
8084
If the conversation update activity indicates that members other than the bot joined the conversation,
8185
it calls the :meth:`ActivityHandler.on_members_added_activity()` method.
@@ -103,7 +107,8 @@ async def on_conversation_update_activity(self, turn_context: TurnContext):
103107
async def on_members_added_activity(
104108
self, members_added: List[ChannelAccount], turn_context: TurnContext
105109
): # pylint: disable=unused-argument
106-
"""Override this method in a derived class to provide logic for when members other than the bot join the conversation.
110+
"""
111+
Override this method in a derived class to provide logic for when members other than the bot join the conversation.
107112
You can add your bot's welcome logic.
108113
109114
:param members_added: A list of all the members added to the conversation, as described by the conversation update activity
@@ -113,7 +118,7 @@ async def on_members_added_activity(
113118
114119
:returns: A task that represents the work queued to execute
115120
116-
.. remarks::
121+
.. note::
117122
When the :meth:'ActivityHandler.on_conversation_update_activity()` method receives a conversation update activity that indicates
118123
one or more users other than the bot are joining the conversation, it calls this method.
119124
"""
@@ -122,7 +127,8 @@ async def on_members_added_activity(
122127
async def on_members_removed_activity(
123128
self, members_removed: List[ChannelAccount], turn_context: TurnContext
124129
): # pylint: disable=unused-argument
125-
"""Override this method in a derived class to provide logic for when members other than the bot leave the conversation.
130+
"""
131+
Override this method in a derived class to provide logic for when members other than the bot leave the conversation.
126132
You can add your bot's good-bye logic.
127133
128134
:param members_added: A list of all the members removed from the conversation, as described by the conversation update activity
@@ -132,26 +138,28 @@ async def on_members_removed_activity(
132138
133139
:returns: A task that represents the work queued to execute
134140
135-
.. remarks::
141+
.. note::
136142
When the :meth:'ActivityHandler.on_conversation_update_activity()` method receives a conversation update activity that indicates
137143
one or more users other than the bot are leaving the conversation, it calls this method.
138144
"""
139145

140146
return
141147

142148
async def on_message_reaction_activity(self, turn_context: TurnContext):
143-
"""Invoked when an event activity is received from the connector when the base behavior of :meth:'ActivityHandler.on_turn()` is used.
144-
Message reactions correspond to the user adding a 'like' or 'sad' etc. (often an emoji) to a previously sent activity.
145-
Message reactions are only supported by a few channels. The activity that the message reaction corresponds to is indicated in the
146-
reply to Id property. The value of this property is the activity id of a previously sent activity given back to the bot as the response
147-
from a send call.
149+
"""
150+
Invoked when an event activity is received from the connector when the base behavior of :meth:'ActivityHandler.on_turn()` is used.
151+
148152
149153
:param turn_context: The context object for this turn
150154
:type turn_context: :class:`TurnContext`
151155
152156
:returns: A task that represents the work queued to execute
153157
154-
.. remarks::
158+
.. note::
159+
Message reactions correspond to the user adding a 'like' or 'sad' etc. (often an emoji) to a previously sent activity.
160+
Message reactions are only supported by a few channels. The activity that the message reaction corresponds to is indicated in the
161+
reply to Id property. The value of this property is the activity id of a previously sent activity given back to the bot as the response
162+
from a send call.
155163
When the :meth:'ActivityHandler.on_turn()` method receives a message reaction activity, it calls this method.
156164
If the message reaction indicates that reactions were added to a message, it calls :meth:'ActivityHandler.on_reaction_added().
157165
If the message reaction indicates that reactions were removed from a message, it calls :meth:'ActivityHandler.on_reaction_removed().
@@ -172,7 +180,8 @@ async def on_message_reaction_activity(self, turn_context: TurnContext):
172180
async def on_reactions_added( # pylint: disable=unused-argument
173181
self, message_reactions: List[MessageReaction], turn_context: TurnContext
174182
):
175-
"""Override this method in a derived class to provide logic for when reactions to a previous activity
183+
"""
184+
Override this method in a derived class to provide logic for when reactions to a previous activity
176185
are added to the conversation.
177186
178187
:param message_reactions: The list of reactions added
@@ -182,7 +191,7 @@ async def on_reactions_added( # pylint: disable=unused-argument
182191
183192
:returns: A task that represents the work queued to execute
184193
185-
.. remarks::
194+
.. note::
186195
Message reactions correspond to the user adding a 'like' or 'sad' etc. (often an emoji)
187196
to a previously sent message on the conversation. Message reactions are supported by only a few channels.
188197
The activity that the message is in reaction to is identified by the activity's reply to Id property.
@@ -194,7 +203,8 @@ async def on_reactions_added( # pylint: disable=unused-argument
194203
async def on_reactions_removed( # pylint: disable=unused-argument
195204
self, message_reactions: List[MessageReaction], turn_context: TurnContext
196205
):
197-
"""Override this method in a derived class to provide logic for when reactions to a previous activity
206+
"""
207+
Override this method in a derived class to provide logic for when reactions to a previous activity
198208
are removed from the conversation.
199209
200210
:param message_reactions: The list of reactions removed
@@ -204,7 +214,7 @@ async def on_reactions_removed( # pylint: disable=unused-argument
204214
205215
:returns: A task that represents the work queued to execute
206216
207-
.. remarks::
217+
.. note::
208218
Message reactions correspond to the user adding a 'like' or 'sad' etc. (often an emoji)
209219
to a previously sent message on the conversation. Message reactions are supported by only a few channels.
210220
The activity that the message is in reaction to is identified by the activity's reply to Id property.
@@ -214,14 +224,15 @@ async def on_reactions_removed( # pylint: disable=unused-argument
214224
return
215225

216226
async def on_event_activity(self, turn_context: TurnContext):
217-
"""Invoked when an event activity is received from the connector when the base behavior of :meth:'ActivityHandler.on_turn()` is used.
227+
"""
228+
Invoked when an event activity is received from the connector when the base behavior of :meth:'ActivityHandler.on_turn()` is used.
218229
219230
:param turn_context: The context object for this turn
220231
:type turn_context: :class:`TurnContext`
221232
222233
:returns: A task that represents the work queued to execute
223234
224-
.. remarks::
235+
.. note::
225236
When the :meth:'ActivityHandler.on_turn()` method receives an event activity, it calls this method.
226237
If the activity name is `tokens/response`, it calls :meth:'ActivityHandler.on_token_response_event()`;
227238
otherwise, it calls :meth:'ActivityHandler.on_event()`.
@@ -242,15 +253,16 @@ async def on_event_activity(self, turn_context: TurnContext):
242253
async def on_token_response_event( # pylint: disable=unused-argument
243254
self, turn_context: TurnContext
244255
):
245-
"""Invoked when a `tokens/response` event is received when the base behavior of :meth:'ActivityHandler.on_event_activity()` is used.
256+
"""
257+
Invoked when a `tokens/response` event is received when the base behavior of :meth:'ActivityHandler.on_event_activity()` is used.
246258
If using an `oauth_prompt`, override this method to forward this activity to the current dialog.
247259
248260
:param turn_context: The context object for this turn
249261
:type turn_context: :class:`TurnContext`
250262
251263
:returns: A task that represents the work queued to execute
252264
253-
.. remarks::
265+
.. note::
254266
When the :meth:'ActivityHandler.on_event()` method receives an event with an activity name of `tokens/response`,
255267
it calls this method. If your bot uses an `oauth_prompt`, forward the incoming activity to the current dialog.
256268
"""
@@ -259,25 +271,28 @@ async def on_token_response_event( # pylint: disable=unused-argument
259271
async def on_event( # pylint: disable=unused-argument
260272
self, turn_context: TurnContext
261273
):
262-
"""Invoked when an event other than `tokens/response` is received when the base behavior of
274+
"""
275+
Invoked when an event other than `tokens/response` is received when the base behavior of
263276
:meth:'ActivityHandler.on_event_activity()` is used.
264-
This method could optionally be overridden if the bot is meant to handle miscellaneous events.
277+
265278
266279
:param turn_context: The context object for this turn
267280
:type turn_context: :class:`TurnContext`
268281
269282
:returns: A task that represents the work queued to execute
270283
271-
.. remarks::
284+
.. note::
272285
When the :meth:'ActivityHandler.on_event_activity()` is used method receives an event with an
273286
activity name other than `tokens/response`, it calls this method.
287+
This method could optionally be overridden if the bot is meant to handle miscellaneous events.
274288
"""
275289
return
276290

277291
async def on_end_of_conversation_activity( # pylint: disable=unused-argument
278292
self, turn_context: TurnContext
279293
):
280-
"""Invoked when a conversation end activity is received from the channel.
294+
"""
295+
Invoked when a conversation end activity is received from the channel.
281296
282297
:param turn_context: The context object for this turn
283298
:type turn_context: :class:`TurnContext`
@@ -288,7 +303,8 @@ async def on_end_of_conversation_activity( # pylint: disable=unused-argument
288303
async def on_unrecognized_activity_type( # pylint: disable=unused-argument
289304
self, turn_context: TurnContext
290305
):
291-
"""Invoked when an activity other than a message, conversation update, or event is received when the base behavior of
306+
"""
307+
Invoked when an activity other than a message, conversation update, or event is received when the base behavior of
292308
:meth:`ActivityHandler.on_turn()` is used.
293309
If overridden, this method could potentially respond to any of the other activity types.
294310
@@ -297,7 +313,7 @@ async def on_unrecognized_activity_type( # pylint: disable=unused-argument
297313
298314
:returns: A task that represents the work queued to execute
299315
300-
.. remarks::
316+
.. note::
301317
When the :meth:`ActivityHandler.on_turn()` method receives an activity that is not a message, conversation update, message reaction,
302318
or event activity, it calls this method.
303319
"""

0 commit comments

Comments
 (0)