forked from BotBuilderCommunity/botbuilder-community-dotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTwitterAdapter.cs
More file actions
46 lines (40 loc) · 1.5 KB
/
Copy pathTwitterAdapter.cs
File metadata and controls
46 lines (40 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Bot.Builder.Community.Adapters.Twitter.Webhooks.Services;
using Microsoft.Bot.Builder;
using Microsoft.Bot.Schema;
using Microsoft.Extensions.Options;
namespace Bot.Builder.Community.Adapters.Twitter
{
public class TwitterAdapter : BotAdapter
{
private readonly DirectMessageSender _sender;
public TwitterAdapter(IOptions<TwitterOptions> options)
{
_sender = new DirectMessageSender(options.Value);
}
public override async Task<ResourceResponse[]> SendActivitiesAsync(ITurnContext turnContext,
Activity[] activities, CancellationToken cancellationToken)
{
var responses = new List<ResourceResponse>();
foreach (var activity in activities)
{
await _sender.SendAsync(activity.AsTwitterMessage());
responses.Add(new ResourceResponse(activity.Id));
}
return responses.ToArray();
}
public override Task<ResourceResponse> UpdateActivityAsync(ITurnContext turnContext, Activity activity, CancellationToken cancellationToken)
{
throw new NotSupportedException();
}
public override Task DeleteActivityAsync(ITurnContext turnContext, ConversationReference reference,
CancellationToken cancellationToken)
{
throw new NotSupportedException();
}
}
}