microsoft/teams.net
Publicmirrored from https://github.com/microsoft/teams.netAvailable
core/src/Microsoft.Bot.Core.Compat/CompatBotAdapter.cs
70lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. |
| 2 | // Licensed under the MIT License. |
| 3 | |
| 4 | using Microsoft.Bot.Builder; |
| 5 | using Microsoft.Bot.Core.Schema; |
| 6 | using Microsoft.Bot.Schema; |
| 7 | |
| 8 | |
| 9 | namespace Microsoft.Bot.Core.Compat; |
| 10 | |
| 11 | /// <summary> |
| 12 | /// Provides a Bot Framework adapter that enables compatibility between the Bot Framework SDK and a custom bot |
| 13 | /// application implementation. |
| 14 | /// </summary> |
| 15 | /// <remarks>Use this adapter to bridge Bot Framework turn contexts and activities with a custom bot application. |
| 16 | /// This class is intended for scenarios where integration with non-standard bot runtimes or legacy systems is |
| 17 | /// required.</remarks> |
| 18 | /// <param name="botApplication">The bot application instance used to process and send activities within the adapter.</param> |
| 19 | public class CompatBotAdapter(BotApplication botApplication) : BotAdapter |
| 20 | { |
| 21 | /// <summary> |
| 22 | /// Deletes an activity from the conversation. |
| 23 | /// </summary> |
| 24 | /// <param name="turnContext"></param> |
| 25 | /// <param name="reference"></param> |
| 26 | /// <param name="cancellationToken"></param> |
| 27 | /// <returns></returns> |
| 28 | /// <exception cref="NotImplementedException"></exception> |
| 29 | public override Task DeleteActivityAsync(ITurnContext turnContext, ConversationReference reference, CancellationToken cancellationToken) |
| 30 | { |
| 31 | throw new NotImplementedException(); |
| 32 | } |
| 33 | |
| 34 | /// <summary> |
| 35 | /// Sends a set of activities to the conversation. |
| 36 | /// </summary> |
| 37 | /// <param name="turnContext"></param> |
| 38 | /// <param name="activities"></param> |
| 39 | /// <param name="cancellationToken"></param> |
| 40 | /// <returns></returns> |
| 41 | public override async Task<ResourceResponse[]> SendActivitiesAsync(ITurnContext turnContext, Activity[] activities, CancellationToken cancellationToken) |
| 42 | { |
| 43 | ArgumentNullException.ThrowIfNull(activities); |
| 44 | |
| 45 | ResourceResponse[] responses = new ResourceResponse[1]; |
| 46 | for (int i = 0; i < activities.Length; i++) |
| 47 | { |
| 48 | CoreActivity a = activities[i].FromCompatActivity(); |
| 49 | |
| 50 | string resp = await botApplication.SendActivityAsync(a, cancellationToken).ConfigureAwait(false); |
| 51 | responses[i] = new ResourceResponse(id: resp); |
| 52 | } |
| 53 | return responses; |
| 54 | } |
| 55 | |
| 56 | /// <summary> |
| 57 | /// Updates an existing activity in the conversation. |
| 58 | /// </summary> |
| 59 | /// <param name="turnContext"></param> |
| 60 | /// <param name="activity"></param> |
| 61 | /// <param name="cancellationToken"></param> |
| 62 | /// <returns></returns> |
| 63 | /// <exception cref="NotImplementedException"></exception> |
| 64 | public override Task<ResourceResponse> UpdateActivityAsync(ITurnContext turnContext, Activity activity, CancellationToken cancellationToken) |
| 65 | { |
| 66 | throw new NotImplementedException(); |
| 67 | } |
| 68 | |
| 69 | |
| 70 | } |
| 71 | |