44from http import HTTPStatus
55from pydantic import BaseModel
66
7+ from microsoft .agents .core import TurnContextProtocol
78from microsoft .agents .core .models import (
89 Activity ,
910 ActivityTypes ,
1617)
1718
1819from .bot import Bot
19- from .turn_context import TurnContext
2020
2121
2222class ActivityHandler (Bot ):
@@ -30,7 +30,7 @@ class ActivityHandler(Bot):
3030 """
3131
3232 async def on_turn (
33- self , turn_context : TurnContext
33+ self , turn_context : TurnContextProtocol
3434 ): # pylint: disable=arguments-differ
3535 """
3636 Called by the adapter (for example, :class:`BotFrameworkAdapter`) at runtime
@@ -97,7 +97,7 @@ async def on_turn(
9797 await self .on_unrecognized_activity_type (turn_context )
9898
9999 async def on_message_activity ( # pylint: disable=unused-argument
100- self , turn_context : TurnContext
100+ self , turn_context : TurnContextProtocol
101101 ):
102102 """
103103 Override this method in a derived class to provide logic specific to activities,
@@ -111,7 +111,7 @@ async def on_message_activity( # pylint: disable=unused-argument
111111 return
112112
113113 async def on_message_update_activity ( # pylint: disable=unused-argument
114- self , turn_context : TurnContext
114+ self , turn_context : TurnContextProtocol
115115 ):
116116 """
117117 Override this method in a derived class to provide logic specific to activities,
@@ -125,7 +125,7 @@ async def on_message_update_activity( # pylint: disable=unused-argument
125125 return
126126
127127 async def on_message_delete_activity ( # pylint: disable=unused-argument
128- self , turn_context : TurnContext
128+ self , turn_context : TurnContextProtocol
129129 ):
130130 """
131131 Override this method in a derived class to provide logic specific to activities,
@@ -138,7 +138,7 @@ async def on_message_delete_activity( # pylint: disable=unused-argument
138138 """
139139 return
140140
141- async def on_conversation_update_activity (self , turn_context : TurnContext ):
141+ async def on_conversation_update_activity (self , turn_context : TurnContextProtocol ):
142142 """
143143 Invoked when a conversation update activity is received from the channel when the base behavior of
144144 :meth:`on_turn()` is used.
@@ -176,7 +176,7 @@ async def on_conversation_update_activity(self, turn_context: TurnContext):
176176 return
177177
178178 async def on_members_added_activity (
179- self , members_added : list [ChannelAccount ], turn_context : TurnContext
179+ self , members_added : list [ChannelAccount ], turn_context : TurnContextProtocol
180180 ): # pylint: disable=unused-argument
181181 """
182182 Override this method in a derived class to provide logic for when members other than the bot join
@@ -198,7 +198,7 @@ async def on_members_added_activity(
198198 return
199199
200200 async def on_members_removed_activity (
201- self , members_removed : list [ChannelAccount ], turn_context : TurnContext
201+ self , members_removed : list [ChannelAccount ], turn_context : TurnContextProtocol
202202 ): # pylint: disable=unused-argument
203203 """
204204 Override this method in a derived class to provide logic for when members other than the bot leave
@@ -220,7 +220,7 @@ async def on_members_removed_activity(
220220
221221 return
222222
223- async def on_message_reaction_activity (self , turn_context : TurnContext ):
223+ async def on_message_reaction_activity (self , turn_context : TurnContextProtocol ):
224224 """
225225 Invoked when an event activity is received from the connector when the base behavior of
226226 :meth:`on_turn()` is used.
@@ -261,7 +261,9 @@ async def on_message_reaction_activity(self, turn_context: TurnContext):
261261 )
262262
263263 async def on_reactions_added ( # pylint: disable=unused-argument
264- self , message_reactions : list [MessageReaction ], turn_context : TurnContext
264+ self ,
265+ message_reactions : list [MessageReaction ],
266+ turn_context : TurnContextProtocol ,
265267 ):
266268 """
267269 Override this method in a derived class to provide logic for when reactions to a previous activity
@@ -285,7 +287,9 @@ async def on_reactions_added( # pylint: disable=unused-argument
285287 return
286288
287289 async def on_reactions_removed ( # pylint: disable=unused-argument
288- self , message_reactions : list [MessageReaction ], turn_context : TurnContext
290+ self ,
291+ message_reactions : list [MessageReaction ],
292+ turn_context : TurnContextProtocol ,
289293 ):
290294 """
291295 Override this method in a derived class to provide logic for when reactions to a previous activity
@@ -307,7 +311,7 @@ async def on_reactions_removed( # pylint: disable=unused-argument
307311 """
308312 return
309313
310- async def on_event_activity (self , turn_context : TurnContext ):
314+ async def on_event_activity (self , turn_context : TurnContextProtocol ):
311315 """
312316 Invoked when an event activity is received from the connector when the base behavior of
313317 :meth:`on_turn()` is used.
@@ -336,7 +340,7 @@ async def on_event_activity(self, turn_context: TurnContext):
336340 return await self .on_event (turn_context )
337341
338342 async def on_token_response_event ( # pylint: disable=unused-argument
339- self , turn_context : TurnContext
343+ self , turn_context : TurnContextProtocol
340344 ):
341345 """
342346 Invoked when a `tokens/response` event is received when the base behavior of
@@ -356,7 +360,7 @@ async def on_token_response_event( # pylint: disable=unused-argument
356360 return
357361
358362 async def on_event ( # pylint: disable=unused-argument
359- self , turn_context : TurnContext
363+ self , turn_context : TurnContextProtocol
360364 ):
361365 """
362366 Invoked when an event other than `tokens/response` is received when the base behavior of
@@ -376,7 +380,7 @@ async def on_event( # pylint: disable=unused-argument
376380 return
377381
378382 async def on_end_of_conversation_activity ( # pylint: disable=unused-argument
379- self , turn_context : TurnContext
383+ self , turn_context : TurnContextProtocol
380384 ):
381385 """
382386 Invoked when a conversation end activity is received from the channel.
@@ -388,7 +392,7 @@ async def on_end_of_conversation_activity( # pylint: disable=unused-argument
388392 return
389393
390394 async def on_typing_activity ( # pylint: disable=unused-argument
391- self , turn_context : TurnContext
395+ self , turn_context : TurnContextProtocol
392396 ):
393397 """
394398 Override this in a derived class to provide logic specific to
@@ -401,7 +405,7 @@ async def on_typing_activity( # pylint: disable=unused-argument
401405 return
402406
403407 async def on_installation_update ( # pylint: disable=unused-argument
404- self , turn_context : TurnContext
408+ self , turn_context : TurnContextProtocol
405409 ):
406410 """
407411 Override this in a derived class to provide logic specific to
@@ -418,7 +422,7 @@ async def on_installation_update( # pylint: disable=unused-argument
418422 return
419423
420424 async def on_installation_update_add ( # pylint: disable=unused-argument
421- self , turn_context : TurnContext
425+ self , turn_context : TurnContextProtocol
422426 ):
423427 """
424428 Override this in a derived class to provide logic specific to
@@ -431,7 +435,7 @@ async def on_installation_update_add( # pylint: disable=unused-argument
431435 return
432436
433437 async def on_installation_update_remove ( # pylint: disable=unused-argument
434- self , turn_context : TurnContext
438+ self , turn_context : TurnContextProtocol
435439 ):
436440 """
437441 Override this in a derived class to provide logic specific to
@@ -444,7 +448,7 @@ async def on_installation_update_remove( # pylint: disable=unused-argument
444448 return
445449
446450 async def on_unrecognized_activity_type ( # pylint: disable=unused-argument
447- self , turn_context : TurnContext
451+ self , turn_context : TurnContextProtocol
448452 ):
449453 """
450454 Invoked when an activity other than a message, conversation update, or event is received when the base
@@ -463,7 +467,7 @@ async def on_unrecognized_activity_type( # pylint: disable=unused-argument
463467 return
464468
465469 async def on_invoke_activity ( # pylint: disable=unused-argument
466- self , turn_context : TurnContext
470+ self , turn_context : TurnContextProtocol
467471 ) -> InvokeResponse | None :
468472 """
469473 Registers an activity event handler for the _invoke_ event, emitted for every incoming event activity.
@@ -496,7 +500,7 @@ async def on_invoke_activity( # pylint: disable=unused-argument
496500 return invoke_exception .create_invoke_response ()
497501
498502 async def on_sign_in_invoke ( # pylint: disable=unused-argument
499- self , turn_context : TurnContext
503+ self , turn_context : TurnContextProtocol
500504 ):
501505 """
502506 Invoked when a signin/verifyState or signin/tokenExchange event is received when the base behavior of
@@ -512,7 +516,7 @@ async def on_sign_in_invoke( # pylint: disable=unused-argument
512516 raise _InvokeResponseException (HTTPStatus .NOT_IMPLEMENTED )
513517
514518 async def on_adaptive_card_invoke (
515- self , turn_context : TurnContext , invoke_value : AdaptiveCardInvokeValue
519+ self , turn_context : TurnContextProtocol , invoke_value : AdaptiveCardInvokeValue
516520 ) -> AdaptiveCardInvokeResponse :
517521 """
518522 Invoked when the bot is sent an Adaptive Card Action Execute.
0 commit comments