This is the piece of code that I'm using but after a while it stopped working:
namespace My_bot
{
class Program
{
private static ReplyKeyboardMarkup mainMenu;
private static string botToken = "xxxx";
static void Main(string[] args)
{
mainMenu = new ReplyKeyboardMarkup
{
Keyboard =
new KeyboardButton[][]
{
new KeyboardButton[] {new KeyboardButton("Main Menu") } ,
new KeyboardButton[] {new KeyboardButton("About Us") }
}
};
Task.Run(() => RunBot());
Console.ReadKey();
}
public static async Task RunBot()
{
var bot = new TelegramBot(botToken);
var me = await bot.MakeRequestAsync(new GetMe());
Console.WriteLine("My 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;
Console.WriteLine("User with ID {0} send the this request: {1}", update.Message.Chat.Id, text);
if (text == "/start" && text != null)
{
var req = new SendMessage(update.Message.Chat.Id, "Hi, please choose one of the following items:") { ReplyMarkup = mainMenu };
await bot.MakeRequestAsync(req);
continue;
}
else
{
var req = new SendMessage(update.Message.Chat.Id, "Sorry, I cannot understand what you say. Please try again") { ReplyMarkup = mainMenu };
await bot.MakeRequestAsync(req);
continue;
}
}
}
}
}
}
This issue is fixed automatically. I think there was a problem with Telegram server at the moment.