0
私の電報ボットコード(NetTelegramBotApiを使用して)次のとおりであり、そして私がコメントで述べた問題の助けが必要なのプレビューを表示する方法:受信した情報(コード修正依頼)
- 表示のプレビューを電話番号:123456 &あなたの会社名:MyCo。情報が正しいことを確認し、確認してください。
UI:ユーザーがそのボタンを押すことで、彼/彼女の数/位置を送ることができるようにあなたは、あなたのkeyboardbuttonにオプションの値を追加することができ、電話番号と場所のためのImage
using NetTelegramBotApi;
using NetTelegramBotApi.Requests;
using NetTelegramBotApi.Types;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace mybot
{
class Program
{
private static ReplyKeyboardMarkup mainMenu;
private static ReplyKeyboardMarkup confirmMenu;
private static string botToken = "***";
static void Main(string[] args)
{
mainMenu = new ReplyKeyboardMarkup
{
Keyboard = new KeyboardButton[][] {
new KeyboardButton[]
{
new KeyboardButton("Address"),
new KeyboardButton("Phone"),
new KeyboardButton("Company Name")
}
}
};
confirmMenu = new ReplyKeyboardMarkup
{
Keyboard = new KeyboardButton[][] {
new KeyboardButton[]
{
new KeyboardButton("Confirm"),
new KeyboardButton("Restart")
}
}
};
Task.Run(() => RunBot());
Console.ReadLine();
}
public static async Task RunBot()
{
var bot = new TelegramBot(botToken);
var me = await bot.MakeRequestAsync(new GetMe());
Console.Write("username is {0}", me.Username);
long offset = 0;
while (true)
{
var updates = await bot.MakeRequestAsync(new GetUpdates() { Offset = offset });
foreach (var update in updates)
{
offset = update.UpdateId + 1;
var text = update.Message.Text;
if (text == "/start" || text == "Restart")
{
var req = new SendMessage(update.Message.Chat.Id, "Please use the Menu") { ReplyMarkup = mainMenu };
await bot.MakeRequestAsync(req);
continue;
}
else if (text == "Address")
{
var req = new SendMessage(update.Message.Chat.Id, "Please enter your address:");
await bot.MakeRequestAsync(req);
continue;
}
else if (text == "Phone")
{
var req = new SendMessage(update.Message.Chat.Id, "Please enter your phone number:");
await bot.MakeRequestAsync(req);
continue;
}
else if (text == "Company Name")
{
var req = new SendMessage(update.Message.Chat.Id, "Please enter your company name:");
await bot.MakeRequestAsync(req);
/* Now, I need to show him the preview of received information to confirm.
Example:
Your Address: ***
Your Phone Number: ***
& Your Company Name: ***
Please check and confirm that the information are correct ('confirmMenu' keyboard could be used).
*/
continue;
}
else
{
var req = new SendMessage(update.Message.Chat.Id, "Error! Please follow the instructions") { ReplyMarkup = mainMenu };
await bot.MakeRequestAsync(req);
continue;
}
}
}
}
}
}
親愛なるtashakoriさん、コードを修正していただけますか? – ProMedia