C# Bot框架中用于电报部署的新线

C# Bot框架中用于电报部署的新线,c#,botframework,C#,Botframework,方法1: public async Task WelcomeAsync( IDialogContext context, IAwaitable<Message> argument) { var message = await argument; message.SetBotConversationData("DateTime", DateTime.UtcNow); StorageAccess.StoreTemporaryLog

方法1:

public async Task WelcomeAsync(
        IDialogContext context,
        IAwaitable<Message> argument)
{
    var message = await argument;
    message.SetBotConversationData("DateTime", DateTime.UtcNow);

    StorageAccess.StoreTemporaryLog(
    StorageAccess.GetDateTime(message.GetBotConversationData<DateTime>("DateTime")),
        "user",
        message.Text);

    await context.PostAsync(
        "Welcome to VAM Insurance Bot\n" +
        "Do you already have a policy or do you want to buy a new policy?\n" +
        "1.Already\n" +
        "2.New\n" +
        "Please enter the correct choice:");

    StorageAccess.StoreTemporaryLog(
        StorageAccess.GetDateTime(message.GetBotConversationData<DateTime>("DateTime")),
        "bot",
        "Welcome to VAM Insurance Bot\n" +
        "Do you already have a policy or do you want to buy a new policy?\n" +
        "1.Already\n" +
        "2.New\n" +
        "Please enter the correct choice:");

    context.Wait(AlreadyNewAsync);
}
公共异步任务WelcomeAsync(
IDialogContext上下文,
(可等待参数)
{
var message=等待参数;
message.SetBotConversationData(“DateTime”,DateTime.UtcNow);
StorageAccess.StoreTemporaryLog(
StorageAccess.GetDateTime(message.GetBotConversationData(“DateTime”),
“用户”,
信息(文本);
wait context.PostAsync(
“欢迎使用VAM保险机器人\n”+
“您是否已经有保险单,还是要购买新保险单?\n”+
“1.已经\n”+
“2.新的\n”+
请输入正确的选项:);
StorageAccess.StoreTemporaryLog(
StorageAccess.GetDateTime(message.GetBotConversationData(“DateTime”),
“机器人”,
“欢迎使用VAM保险机器人\n”+
“您是否已经有保险单,还是要购买新保险单?\n”+
“1.已经\n”+
“2.新的\n”+
请输入正确的选项:);
Wait(AlreadyNewAsync);
}
方法2:

public async Task AuthenicateClientAsync(
        IDialogContext context,
        IAwaitable<Message> argument)
{
    var message = await argument;
    StorageAccess.StoreStructuredLog(
        StorageAccess.GetDateTime(message.GetBotConversationData<DateTime>("DateTime")),
        message.GetBotUserData<string>("policyNo"),
        "user",
        message.Text);

    if (DBAccess.AuthenticateOTP(message.Text))
    {
        await context.PostAsync("You have been successfully authenticated!");

        StorageAccess.StoreStructuredLog(
            StorageAccess.GetDateTime(
                message.GetBotConversationData<DateTime>("DateTime")),
            message.GetBotUserData<string>("policyNo"),
            "bot",
            "You have been successfully authenticated!");

        await context.PostAsync(
            "What would you like to do?\n" +
            "1. View your policy\n" +
            "2. Renew you policy\n" +
            "3. File an insurance claim\n" +
            "Please enter the suitable options number:");

        StorageAccess.StoreStructuredLog(
            StorageAccess.GetDateTime(
                message.GetBotConversationData<DateTime>("DateTime")),
            message.GetBotUserData<string>("policyNo"),
            "bot",
            "What would you like to do?\n" +
            "1. View your policy\n" +
            "2. Renew you policy\n" +
            "3. File an insurance claim\n" +
            "Please enter the suitable options number:");

        context.Wait(ViewRenewFileClaimAsync);
    }
    else
    {
        await context.PostAsync(
            "The OTP that you have entered is either incorrect or expired.\n" +
            "Would you like to go over again?\n" +
            "Yes\n" +
            "No");

        StorageAccess.StoreStructuredLog(
             StorageAccess.GetDateTime(
                 message.GetBotConversationData<DateTime>("DateTime")),
             message.GetBotUserData<string>("policyNo"),
             "bot",
             "The OTP that you have entered is either incorrect or expired.\n" +
             "Would you like to go over again?\n" +
             "Yes\n" +
             "No");

         context.Wait(RepeatAsync);
    }
}
public异步任务authenicateclientsync(
IDialogContext上下文,
(可等待参数)
{
var message=等待参数;
StorageAccess.StoreStructuredLog(
StorageAccess.GetDateTime(message.GetBotConversationData(“DateTime”),
message.GetBotUserData(“policyNo”),
“用户”,
信息(文本);
if(DBAccess.AuthenticateOTP(message.Text))
{
wait context.PostAsync(“您已成功通过身份验证!”);
StorageAccess.StoreStructuredLog(
StorageAccess.GetDateTime(
message.GetBotConversationData(“DateTime”),
message.GetBotUserData(“policyNo”),
“机器人”,
“您已成功通过身份验证!”);
wait context.PostAsync(
“您想做什么?\n”+
“1.查看您的策略\n”+
“2.续订您的保险单\n”+
“3.提交保险索赔\n”+
“请输入合适的选项编号:”;
StorageAccess.StoreStructuredLog(
StorageAccess.GetDateTime(
message.GetBotConversationData(“DateTime”),
message.GetBotUserData(“policyNo”),
“机器人”,
“您想做什么?\n”+
“1.查看您的策略\n”+
“2.续订您的保险单\n”+
“3.提交保险索赔\n”+
“请输入合适的选项编号:”;
context.Wait(viewRenewFileSync);
}
其他的
{
wait context.PostAsync(
“您输入的OTP不正确或已过期。\n”+
“您想再看一遍吗?\n”+
“是\n”+
“否”);
StorageAccess.StoreStructuredLog(
StorageAccess.GetDateTime(
message.GetBotConversationData(“DateTime”),
message.GetBotUserData(“policyNo”),
“机器人”,
“您输入的OTP不正确或已过期。\n”+
“您想再看一遍吗?\n”+
“是\n”+
“否”);
Wait(repeatsync);
}
}
这是我项目中的两种对话方法。我已经将它们部署在Azure上并连接到Telegram。但是“\n”似乎并不适用于任何地方。正如你在截图中看到的,它只在一些地方起作用。如您所见,方法1的对话没有换行。但是在方法2中,除了最后一行之外,他们得到了新的行。
访问获取图像

框架使用降价。您可以在

中查看解决方案,谢谢!!我错过了这些资源。