microsoft/teams.net
Publicmirrored from https://github.com/microsoft/teams.netAvailable
Samples/Samples.Echo/Program.cs
44lines · modecode
| 1 | using Microsoft.Teams.Api.Activities; |
| 2 | using Microsoft.Teams.Apps; |
| 3 | using Microsoft.Teams.Apps.Annotations; |
| 4 | using Microsoft.Teams.Apps.Extensions; |
| 5 | using Microsoft.Teams.Apps.Routing; |
| 6 | using Microsoft.Teams.Plugins.AspNetCore.DevTools.Extensions; |
| 7 | using Microsoft.Teams.Plugins.AspNetCore.Extensions; |
| 8 | |
| 9 | namespace Samples.Echo; |
| 10 | |
| 11 | public static partial class Program |
| 12 | { |
| 13 | public static void Main(string[] args) |
| 14 | { |
| 15 | var builder = WebApplication.CreateBuilder(args); |
| 16 | builder.Services.AddOpenApi(); |
| 17 | builder.AddTeams().AddTeamsDevTools(); |
| 18 | |
| 19 | var app = builder.Build(); |
| 20 | |
| 21 | if (app.Environment.IsDevelopment()) |
| 22 | { |
| 23 | app.MapOpenApi(); |
| 24 | } |
| 25 | |
| 26 | app.UseHttpsRedirection(); |
| 27 | app.UseTeams(); |
| 28 | app.Run(); |
| 29 | } |
| 30 | |
| 31 | [Activity] |
| 32 | public static async Task OnActivity(IContext<Activity> context, [Context] IContext.Next next) |
| 33 | { |
| 34 | context.Log.Info(context.AppId); |
| 35 | await next(); |
| 36 | } |
| 37 | |
| 38 | [Message] |
| 39 | public static async Task OnMessage([Context] MessageActivity activity, [Context] IContext.Client client) |
| 40 | { |
| 41 | await client.Typing(); |
| 42 | await client.Send($"you said '{activity.Text}'"); |
| 43 | } |
| 44 | } |