In most documentation you'll see:
class BotHandler(ActivityHandler):
async def on_message_activity(self, turn_context: TurnContext):
await turn_context.send_activity("Hello!")
However, some Python examples will use TeamsActivityHandler
instead:
class BotHandler(TeamsActivityHandler):
async def on_message_activity(self, turn_context: TurnContext):
message = MessageFactory.text("first message")
channel_id = teams_get_channel_id(turn_context.activity)
I've noticed that
TeamsActivityHandler
, I can overload on_teams_channel_created()
that gets called when a new channel is created.ActivityHandler
, I can overload on_members_added_activity()
to greet new users (welcome message).How can I use both at the same time?
I found the solution. If you inherit from TeamsActivityHandler
you may override on_teams_members_added()
instead.
This is rather counter intuitive because when you inherit from TeamsActivityHandler
(which in turn inherits from TeamsActivity
) you assume get the same functionality (i.e: be able to override the same function(s)). This does not seem to be the case due to the super() used here.
If you inherit from TeamsActivity
you may override on_members_added_activity()
as per usual.
Not sure if this is a bug or just weird design.