microsoft/teams.net
Publicmirrored fromhttps://github.com/microsoft/teams.netAvailable
Libraries/Microsoft.Teams.Apps/Events/ActivityEvent.cs
29lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | // Licensed under the MIT License. |
| 3 | |
| 4 | using Microsoft.Teams.Api.Activities; |
| 5 | using Microsoft.Teams.Api.Auth; |
| 6 | using Microsoft.Teams.Apps.Plugins; |
| 7 | |
| 8 | namespace Microsoft.Teams.Apps.Events; |
| 9 | |
| 10 | public class ActivityEvent : Event |
| 11 | { |
| 12 | public required IToken Token { get; set; } |
| 13 | public required IActivity Activity { get; set; } |
| 14 | public IServiceProvider? Services { get; set; } |
| 15 | public IDictionary<string, object?>? Extra { get; set; } |
| 16 | } |
| 17 | |
| 18 | public static partial class AppEventExtensions |
| 19 | { |
| 20 | public static App OnActivity(this App app, Action<ISenderPlugin, ActivityEvent> handler) |
| 21 | { |
| 22 | return app.OnEvent(EventType.Activity, (plugin, @event) => handler((ISenderPlugin)plugin, (ActivityEvent)@event)); |
| 23 | } |
| 24 | |
| 25 | public static App OnActivity(this App app, Func<ISenderPlugin, ActivityEvent, CancellationToken, Task> handler) |
| 26 | { |
| 27 | return app.OnEvent(EventType.Activity, (plugin, @event, token) => handler((ISenderPlugin)plugin, (ActivityEvent)@event, token)); |
| 28 | } |
| 29 | } |