本文整理汇总了C#中IMessageContext.Respond方法的典型用法代码示例。如果您正苦于以下问题:C# IMessageContext.Respond方法的具体用法?C# IMessageContext.Respond怎么用?C# IMessageContext.Respond使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMessageContext
的用法示例。
在下文中一共展示了IMessageContext.Respond方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Publish
public void Publish(IMessage message, IMessageContext sender)
{
var messageTpye = message.GetType();
if (handlers.ContainsKey(messageTpye))
{
foreach (var handler in handlers[messageTpye])
{
dynamic instance = handlerFactory(handler);
try
{
if (HasResponse(message))
{
var result = instance.Handle((dynamic)(message.ToPublishedMessage(sender)));
sender.Respond(result);
}
else
instance.Handle((dynamic)(message.ToPublishedMessage(sender)));
}
catch (Exception ex)
{
sender.ErrorFormat("{0} , {1}", ex.Message, ex.StackTrace);
}
}
}
}
示例2: Respond
public Task Respond(ChatContextHolder chatContextHolder, IMessageContext context)
{
var volumeLevel = ValueConverterHelper.ToInt(ExtractStartsWith(context, "set volume"),10);
var result = string.Format("volume set to {0}", volumeLevel);
_textToSpeech.Play(result);
_volumeSetter.SetVolume(volumeLevel);
return context.Respond(result);
}
示例3: Respond
public async Task Respond(ChatContextHolder chatContextHolder, IMessageContext context)
{
var oneLiner = RandomTextHelper.OneLiner.Split('.');
foreach (var message in oneLiner)
{
await context.Respond(message);
await Task.Delay(5000);
}
}
示例4: Response
protected override async Task Response(ChatContextHolder chatContextHolder, IMessageContext context, Server server)
{
if (string.IsNullOrEmpty(server.Name))
{
await
context.Respond(string.Format("Scanning servers."));
}
else
{
await
context.Respond(string.Format("Scanning {0} servers.", server.Name));
}
Task.Run(async () =>
{
await RunOnBackground(context, server);
}).FireAndForgetWithLogging();
}
示例5: Monitor
private async Task Monitor(IMessageContext context, Server link, List<string> list , bool report)
{
for (int i = 0; i < link.ScanCount; i++)
{
var serverVersion = await GetVerionForLink(link);
if (serverVersion == null || list.Contains(serverVersion.ServerName + serverVersion.Version)) continue;
list.Add(serverVersion.ServerName + serverVersion.Version);
if (report)
{
await
context.Respond(string.Format("{0} now on a new version {1}, released {2} ago.",
serverVersion.ServerName, serverVersion.Version,
serverVersion.Date.Humanize()));
}
}
// if (!list.Any())
// {
// await context.Respond(string.Format("Oops, {0} seems to be down.", link.Uri));
// }
}
示例6: Respond
public Task Respond(ChatContextHolder chatContextHolder, IMessageContext context)
{
return Task.Run(() =>
{
foreach (LightPin pin in _lights)
{
pin.Set(context.Text, _pinManager);
}
LightPin[] allOn = _lights.Where(x => x.ContainsSection(context.Text) && x.IsOn(context.Text)).ToArray();
if (!allOn.Select(x => x.Color).Any())
{
context.Respond(string.Format("{0} lights are now off",
_lights.Where(x => x.ContainsSection(context.Text))
.Select(x => x.Section)
.Distinct()
.StringJoin()));
}
else
{
context.Respond(string.Format("{0} {1} lights are now on",
allOn.Select(x => x.Section).Distinct().StringJoin(),
allOn.Select(x => x.Color).Distinct().StringJoin()));
}
});
}