forked from microsoft/BotBuilder-Samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathShowPrivateDataScorable.cs
33 lines (24 loc) · 1.02 KB
/
ShowPrivateDataScorable.cs
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
namespace TestBot.Scorables
{
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Bot.Builder.Dialogs.Internals;
using Microsoft.Bot.Connector;
public abstract class ShowPrivateDataScorable : TriggerScorable
{
private const string CodeTemplate = "~~~~\n{0}\n~~~~";
public ShowPrivateDataScorable(IBotToUser botToUser, IBotData botData) : base(botToUser, botData)
{
}
public abstract string DataKey { get; }
public abstract string NotAvailableMessage { get; }
protected override async Task PostAsync(IActivity item, bool state, CancellationToken token)
{
var data = default(string);
this.BotData.PrivateConversationData.TryGetValue(this.DataKey, out data);
var reply = this.BotToUser.MakeMessage();
reply.Text = string.IsNullOrWhiteSpace(data) ? this.NotAvailableMessage : string.Format(CodeTemplate, data);
await this.BotToUser.PostAsync(reply);
}
}
}