public static InlineKeyboardMarkup CreateTaskResourceInlineKeyboard(string[] usernames) => new InlineKeyboardMarkup( usernames .Select(c => new[] { InlineKeyboardButton.WithCallbackData($"{c}", $"{Constants.SelectedResource}{c}") }) .Prepend(new[] { InlineKeyboardButton.WithCallbackData("На выбор таска", $"{Constants.RootPage}0:") }) );
public InlineKeyboardMarkup ForPhotoMessage() { InlineKeyboardMarkup inlineKeyboardMarkup = new InlineKeyboardMarkup(new[] { InlineKeyboardButton.WithCallbackData("Удалить", $"delete_message:{stashMessage.ChatId}:{stashMessage.DatabaseMessageId}") }); return(inlineKeyboardMarkup); }
private InlineKeyboardMarkup GetKeyboardMarkup(string payload) { return(new InlineKeyboardMarkup(new[] { new [] { InlineKeyboardButton.WithCallbackData(PreviousVersion, $"{CommandName};{payload};{PreviousVersionToken}"), InlineKeyboardButton.WithCallbackData(NextVersion, $"{CommandName};{payload};{NextVersionToken}"), } })); }
public async Task VisitButton(Button button) { await SendDialog(button.Caption, new InlineKeyboardMarkup(new[] { new[] { InlineKeyboardButton.WithCallbackData(button.Name, $"{button.Go}"), } })); }
public static InlineKeyboardMarkup StatsMarkup() { return(new InlineKeyboardMarkup(new[] { new [] // first row { InlineKeyboardButton.WithCallbackData("Refresh", Commands.RefreshStats), }, })); }
private static List <InlineKeyboardButton[]> GetPollButtons(PollData.Poll p) { var opt = BuildPoolButtons(p.Id).ToList(); if (p.CanAddOptions) { opt.Add(new[] { InlineKeyboardButton.WithCallbackData("Add New Option", $"{p.Id}|custom") }); } return(opt); }
public override void Execute(Update update, TelegramBotClient client, Exception e = null) { var Message = update.Message ?? update.CallbackQuery.Message; var menu = new InlineKeyboardMarkup(new[] { new[] { InlineKeyboardButton.WithCallbackData("Мои события", "MyEventList") } }); client.SendTextMessageAsync(Message.Chat.Id, "Администрируй на здоровье, босс", parseMode: default, false, false, 0, menu);
private static IEnumerable <InlineKeyboardButton[]> BuildPoolButtons(long PollId) { int i = 0; return(pollManager .GetPoll(PollId) .Options .Select(o => InlineKeyboardButton.WithCallbackData(o.Text, $"{PollId}|{i++}")) .Partition(BOT_MaxButtonLen)); }
public async Task HandleCallbackQuery(CallbackQuery callbackQuery) { var userFrom = callbackQuery.From; var userFullName = $"{userFrom.FirstName} {userFrom.LastName}"; var originalMessageId = callbackQuery.Message.MessageId; if (callbackQuery.Data == CallbackButtonDataContants.OptIn) { var userParticipance = _botContext.Participance .SingleOrDefault(p => p.UserId == userFrom.Id && p.MessageId == originalMessageId); if (userParticipance is null) { _botContext.Participance.Add(new Participance { UserId = userFrom.Id, MessageId = originalMessageId, UserName = userFullName }); _botContext.SaveChanges(); await SendRegisteredNotification(callbackQuery.Message, userFullName); } } if (callbackQuery.Data == CallbackButtonDataContants.OptOut) { var p = _botContext.Participance.SingleOrDefault(p => p.UserId == userFrom.Id && p.MessageId == originalMessageId); if (p != null) { _botContext.Participance.Remove(p); _botContext.SaveChanges(); await SendChangedMindNotification(callbackQuery.Message, userFullName); } } var users = _botContext.Participance.Where(p => p.MessageId == originalMessageId).Select(p => p.UserName).ToList(); var messageText = users.Count > 0 ? $"Сегодня играют: {string.Join(", ", users)}" : "Кто был, уже все успели отказаться"; if (callbackQuery.Message.Text == messageText) { return; } await _telegram.EditMessageTextAsync( callbackQuery.Message.Chat.Id, originalMessageId, messageText, replyMarkup : new InlineKeyboardButton[] { InlineKeyboardButton.WithCallbackData("Я в деле", CallbackButtonDataContants.OptIn), InlineKeyboardButton.WithCallbackData("Я передумал", CallbackButtonDataContants.OptOut) }); }
public async Task ProcessMessage(Message message) { if (_chatSettingsBotData.ActiveCommand != ActiveCommand.WeatherApi) { var inlineKeyboard = new InlineKeyboardMarkup(new[] { new[] { InlineKeyboardButton.WithCallbackData("Samara", "Samara"), InlineKeyboardButton.WithCallbackData("Saint-Petersburg", "Saint Petersburg"), InlineKeyboardButton.WithCallbackData("Moscow", "Moscow") } }); _chatSettingsBotData.ActiveCommand = ActiveCommand.WeatherApi; await _botService.Client.SendTextMessageAsync(message.Chat.Id, "Enter the city or choose from list: ", replyMarkup : inlineKeyboard); return; } var uri = $"{BotConstants.Weather.Url}?q={message.Text}&appid={BotConstants.Weather.ApiKey}"; var client = new RestClient(BotConstants.Weather.Host); var request = new RestRequest(uri, DataFormat.Json); var response = await client.ExecuteAsync(request); var json = JObject.Parse(response.Content); if (json["cod"].ToString() == "404") { await _botService.Client.SendTextMessageAsync(message.Chat.Id, "Unknown city, try again: "); return; } if (json["name"] == null) { await _botService.Client.SendTextMessageAsync(message.Chat.Id, "Server Error"); return; } var city = json["name"]; var weather = json["weather"][0]["main"]; var temp = Math.Round((double)json["main"]["temp"] - 273.15, 2); var wind = json["wind"]["speed"]; var result = $"City: {city}, Weather: {weather},{Environment.NewLine}Temperature: {temp} °C, Wind: {wind} m/s"; _chatSettingsBotData.ActiveCommand = ActiveCommand.Default; var exitKeyboard = KeyboardBuilder.CreateExitButton(); await _botService.Client.SendTextMessageAsync(message.Chat.Id, result, replyMarkup : exitKeyboard); }
public static async Task DeleteForceSubsChannelAsync(this TelegramService telegramService) { await telegramService.DeleteSenderMessageAsync(); if (!await telegramService.CheckFromAdminOrAnonymous()) { return; } var fSubsService = telegramService.GetRequiredService <ForceSubsService>(); var subscriptions = await fSubsService.GetSubsAsync(telegramService.ChatId); var inlineKeyboard = new List <IEnumerable <InlineKeyboardButton> >(); if (subscriptions.Count == 0) { await telegramService.AppendTextAsync( sendText : "Tidak ada subscription di Grup ini", scheduleDeleteAt : DateTime.UtcNow.AddMinutes(1) ); return; } var htmlMessage = HtmlMessage.Empty .BoldBr("Daftar Subscription") .TextBr("Pilih Channel untuk dihapus: "); subscriptions.ForEach( subscription => { inlineKeyboard.Add( new InlineKeyboardButton[] { InlineKeyboardButton.WithCallbackData(subscription.ChannelTitle, "fsub delete " + subscription.ChannelId) } ); } ); inlineKeyboard.Add( new InlineKeyboardButton[] { InlineKeyboardButton.WithCallbackData("❌ Batal", "delete-message current-message") } ); await telegramService.AppendTextAsync( sendText : htmlMessage.ToString(), replyMarkup : inlineKeyboard.ToButtonMarkup(), scheduleDeleteAt : DateTime.UtcNow.AddMinutes(1), includeSenderMessage : true, preventDuplicateSend : true ); }
public static InlineKeyboardButton[] BackToMonthYearPicker(DateTime date) { return(new InlineKeyboardButton[3] { InlineKeyboardButton.WithCallbackData( "<<", $"{Constants.YearMonthPicker}{date.ToString(Constants.DateFormat)}"), " ", " " }); }
public override async Task HandleCommand(long identifier, object message) { var markup = new InlineKeyboardMarkup(new[] { InlineKeyboardButton.WithCallbackData("Да", "+"), InlineKeyboardButton.WithCallbackData("Нет", "-") }); await((TelegramBotClient)BotService.Client).SendTextMessageAsync(identifier, "Создаем событие?", replyMarkup: markup); chatRepository.SetState(identifier, this, writeParams); }
public async Task GenerateAndSendAsync(TelegramBotClient bot, Update update) { var inlineKeyboardMarkup = new InlineKeyboardMarkup ( new[] { new [] { InlineKeyboardButton.WithCallbackData("CoinCapMarket", "sub=CoinCM") } } ); await bot.SendTextMessageAsync(update.Message.Chat.Id, "Choose what to subscribe to:", replyMarkup : inlineKeyboardMarkup); }
public RestartWorkerCommand(ITelegramBotClient clientBot) : base(clientBot) { NextState = FirstStep; var yesNoButtons = new List <InlineKeyboardButton>() { InlineKeyboardButton.WithCallbackData("Yes"), InlineKeyboardButton.WithCallbackData("No"), }; buttons = new InlineKeyboardMarkup(yesNoButtons); }
public List <InlineKeyboardButton> CreateDishButtons(List <Dish> dishes) { var dishButtons = new List <InlineKeyboardButton>(); foreach (var dish in dishes) { var button = InlineKeyboardButton.WithCallbackData(dish.Name); dishButtons.Add(button); } return(dishButtons); }
internal override async void Execute(Message message, TelegramBotClient client) { Message msg = await client.SendDiceAsync( chatId : message.Chat, emoji : Emoji.Darts, replyToMessageId : message.MessageId, replyMarkup : new InlineKeyboardMarkup(new[] { new[] { InlineKeyboardButton.WithCallbackData("Delete message", "delete_msg") } }) ); Logger.AddData($"(i) Darts result: {msg.Dice.Value}"); }
private async Task AllDone(long identifier) { var markup = new InlineKeyboardMarkup(new[] { InlineKeyboardButton.WithCallbackData("Да", "+"), InlineKeyboardButton.WithCallbackData("Нет", "-") }); await((TelegramBotClient)BotService.Client).SendTextMessageAsync(identifier, "Всё готово для запуска. Запустить процесс?", replyMarkup: markup); chatRepository.SetState(identifier, this, startProcess); }
public async Task ProcessMessage(Message message) { var inlineKeyboard = new InlineKeyboardMarkup(new[] { new[] { InlineKeyboardButton.WithCallbackData("Help!", TextCommandList.Help) } }); await _botService.Client.SendTextMessageAsync(message.Chat.Id, $"Welcome, {message.From.Username}! This is bot, bla-bla-bla. Click help to show more info", replyMarkup : inlineKeyboard); }
private InlineKeyboardMarkup CreateActionsInlineKeyboard() { return(new InlineKeyboardMarkup( new InlineKeyboardButton[][] { new[] { InlineKeyboardButton.WithCallbackData("Send D-mail", "%senddmail"), InlineKeyboardButton.WithCallbackData("Begin new operation", "%beginop") } } )); }
public static IEnumerable <InlineKeyboardButton> Controls(DateTime date) => new InlineKeyboardButton[] { InlineKeyboardButton.WithCallbackData( "<", $"{Constants.ChangeTo}{date.AddMonths(-1).ToString(Constants.DateFormat)}"), " ", InlineKeyboardButton.WithCallbackData( ">", $"{Constants.ChangeTo}{date.AddMonths(1).ToString(Constants.DateFormat)}"), };
/// <summary> /// Действие при получение протого соообщения, типа UpdateType.Message /// </summary> /// <param name="message"></param> /// <returns></returns> async Task MessageUpdate(Message message) { if (message.Type == MessageType.Text) { switch (message.Text.Split(' ').First()) { case "/inline": var inlineKeyboardMain = new InlineKeyboardMarkup(new[] { new [] // Первая строка { InlineKeyboardButton.WithCallbackData("Основное меню", "0") } }); await _botService.Client.SendTextMessageAsync( message.Chat.Id, "Основное меню", replyMarkup : inlineKeyboardMain); break; default: const string usage = @" Usage: /inline - send inline keyboard"; await _botService.Client.SendTextMessageAsync( message.Chat.Id, usage, replyMarkup : new ReplyKeyboardRemove()); break; } } else if (message.Type == MessageType.Photo) { // Download Photo var fileId = message.Photo.LastOrDefault()?.FileId; var file = await _botService.Client.GetFileAsync(fileId); var filename = file.FileId + "." + file.FilePath.Split('.').Last(); using (var saveImageStream = System.IO.File.Open(filename, FileMode.Create)) { await _botService.Client.DownloadFileAsync(file.FilePath, saveImageStream); } await _botService.Client.SendTextMessageAsync(message.Chat.Id, "Thx for the Pics"); } }
private InlineKeyboardMarkup CreateShedulerQuestion() { return(new Telegram.Bot.Types.ReplyMarkups.InlineKeyboardMarkup(new[] { new[] { InlineKeyboardButton.WithCallbackData("Отложить", deffer), InlineKeyboardButton.WithCallbackData("Опубликовать", publicNow) } })); }
private InlineKeyboardMarkup CreateReactionsQuestion() { return(new Telegram.Bot.Types.ReplyMarkups.InlineKeyboardMarkup(new[] { new[] { InlineKeyboardButton.WithCallbackData("Да", reactionsYes), InlineKeyboardButton.WithCallbackData("Нет", reactionsNo) } })); }
public override async Task Execute(CallbackQuery message, TelegramBotClient botClient, Microsoft.Extensions.Configuration.IConfiguration configuration) { var chatId = message.Message.Chat.Id; var settings = configuration.GetSection("Settings").Get <Settings>(); using var db = new DbNorthwind(); int.TryParse(message.Data.Replace("Проверить", ""), out int userVkId); var listWeapon = await db.WeaponList.Where(w => w.UserId == userVkId).ToListAsync(); if (listWeapon.Count > 1) { var kidal = await db.Kidals.FirstOrDefaultAsync(f => f.VkId == listWeapon[0].UserId); var list = new InlineKeyboardMarkup(new List <InlineKeyboardButton>() { InlineKeyboardButton.WithCallbackData("Показать лоты", "Показать лоты" + listWeapon[0].UserId) }); if (kidal == null) { await botClient.SendTextMessageAsync(chatId, "Информация по аккаунту: " + Environment.NewLine + $"Профиль: vk.com/id{listWeapon[0].UserId}" + Environment.NewLine + "В списках ненадежных продавцов не найден" + Environment.NewLine + Environment.NewLine + $"Чтобы посмотреть все лоты данного человека нажмите на кнопку ({listWeapon.Count} лотов)", replyMarkup : list); } else { await botClient.SendTextMessageAsync(chatId, "Информация по аккаунту: " + Environment.NewLine + $"Профиль: vk.com/id{listWeapon[0].UserId}" + Environment.NewLine + $"❗Найден в списке мошенников: https://vk.com/topic-{kidal.GroupId}_{kidal.TopicId}?post={kidal.PostId}" + Environment.NewLine + Environment.NewLine + $"Чтобы посмотреть все лоты данного человека нажмите на кнопку ({listWeapon.Count} лотов)", replyMarkup : list); } } else { var kidal = await db.Kidals.FirstOrDefaultAsync(f => f.VkId == listWeapon[0].UserId); if (kidal == null) { await botClient.SendTextMessageAsync(chatId, "Информация по аккаунту: " + Environment.NewLine + $"Профиль: vk.com/id{listWeapon[0].UserId}" + Environment.NewLine + "В списках ненадежных продавцов не найден" + Environment.NewLine + Environment.NewLine + "❗Больше лотов у данного продавца не найдено"); } else { await botClient.SendTextMessageAsync(chatId, "Информация по аккаунту: " + Environment.NewLine + $"Профиль: vk.com/id{listWeapon[0].UserId}" + Environment.NewLine + $"❗Найден в списке мошенников: https://vk.com/topic-{kidal.GroupId}_{kidal.TopicId}?post={kidal.PostId}" + Environment.NewLine + Environment.NewLine + "❗Больше лотов у данного продавца не найдено"); } } }
public async Task Reply(TelegramBotClient client, Update hook, JobBotDbContext ctx = null) { var inlineKeyboard = new InlineKeyboardMarkup(new[] { new[] { InlineKeyboardButton.WithCallbackData("Home"), } });; await client.SendTextMessageAsync(hook.ChatId(), "To setup preferences tap /update <fill with lang>", replyMarkup : inlineKeyboard); }
public async Task ShouldEditInlineMessageDocumentWithFileId() { await _fixture.SendTestCaseNotificationAsync(FactTitles.ShouldEditInlineMessageDocumentWithFileId); // Upload a GIF file to Telegram servers and obtain its file_id. This file_id will be used later in test. string animationFileId; using (Stream stream = System.IO.File.OpenRead(Constants.FileNames.Animation.Earth)) { Message gifMessage = await BotClient.SendDocumentAsync( chatId : _fixture.SupergroupChat, document : new InputOnlineFile(stream, "Earth.gif"), caption : "`file_id` of this GIF will be used", parseMode : ParseMode.Markdown, replyMarkup : (InlineKeyboardMarkup)InlineKeyboardButton .WithSwitchInlineQueryCurrentChat("Start Inline Query") ); animationFileId = gifMessage.Document.FileId; } #region Answer Inline Query with a media message Update iqUpdate = await _fixture.UpdateReceiver.GetInlineQueryUpdateAsync(); InlineQueryResultBase[] inlineQueryResults = { new InlineQueryResultDocument( id: "document:acrobat", documentUrl: "http://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/pdf_open_parameters.pdf", title: "Parameters for Opening PDF Files", mimeType: "application/pdf" ) { ReplyMarkup = InlineKeyboardButton.WithCallbackData("Click here to edit"), } }; await BotClient.AnswerInlineQueryAsync(iqUpdate.InlineQuery.Id, inlineQueryResults, 0); #endregion // Bot waits for user to click on inline button under the media Update cqUpdate = await _fixture.UpdateReceiver.GetCallbackQueryUpdateAsync(data : "Click here to edit"); // Change the YouTube video for an animation. Note that, in the case of an inline message, the new media // should be either an URL or the file_id of a previously uploaded media. // Also, animation thumbnail cannot be uploaded for an inline message. await BotClient.EditMessageMediaAsync( inlineMessageId : cqUpdate.CallbackQuery.InlineMessageId, media : new InputMediaAnimation(animationFileId) ); }
private async Task RemoveButtonsForPreviousTask(UserEntity user, Chat chat, TelegramBotClient client) { var topicId = Convert.ToBase64String(topicDto.Id.ToByteArray()); var levelId = Convert.ToBase64String(levelDto.Id.ToByteArray()); var reportCallback = $"{StringCallbacks.Report}\n{user.MessageId}\n{topicId}\n{levelId}"; var reportButton = new[] { InlineKeyboardButton .WithCallbackData(ButtonNames.Report, reportCallback) }; await client.EditMessageReplyMarkupAsync(chat.Id, user.MessageId, reportButton); }
static async Task Inicio(Message message) { if (Program.inicio) { inicio = false; await Bot.SendPhotoAsync( chatId : message.Chat, photo : "https://www.carrefoursolucoes.com.br/image/layout_set_logo?img_id=7846530&t=1596225774678", parseMode : ParseMode.Html ); const string usage = "Olá! Seja bem vindo ao assistente virtual\n" + "do Carrefour Soluções Financeiras.\n" + "Abaixo estão algumas das opções disponíveis para iniciarmos seu atendimento.\n" + "Ao selecionar um link será apresentado e você poderá acessar a area desejada."; await Bot.SendChatActionAsync(message.Chat.Id, ChatAction.Typing); await Task.Delay(500); Bot.SendTextMessageAsync(chatId: message.Chat.Id, text: usage); await Bot.SendChatActionAsync(message.Chat.Id, ChatAction.Typing); await Task.Delay(200); Bot.SendTextMessageAsync(chatId: message.Chat.Id, text: "Para mostrar o menu novamente basta digitar /menu a qualquer momento"); } var inlineKeyboard = new InlineKeyboardMarkup(new[] { // first row new [] { //("Texto Apresentado", "Texto enviado") InlineKeyboardButton.WithCallbackData("Acessar / Cadastrar", "https://www.carrefoursolucoes.com.br/primeiro-acesso"), InlineKeyboardButton.WithCallbackData("Cartão Carrefour", "https://www.carrefoursolucoes.com.br/cartao/beneficios"), InlineKeyboardButton.WithCallbackData("Seguros", "https://www.carrefoursolucoes.com.br/seguros1") }, // second row new [] { InlineKeyboardButton.WithCallbackData("Serviços", "https://www.carrefoursolucoes.com.br/servicos"), InlineKeyboardButton.WithCallbackData("Promoção", "https://www.carrefoursolucoes.com.br/promocao"), InlineKeyboardButton.WithCallbackData("Blog", "https://www.carrefoursolucoes.com.br/blog") } });; await Bot.SendTextMessageAsync( chatId : message.Chat.Id, text : "Opções", replyMarkup : inlineKeyboard ); }
public void Execute() { InlineKeyboardButton[][] keyboardButtonsRss = new InlineKeyboardButton[2][]; keyboardButtonsRss[0] = new InlineKeyboardButton[] { InlineKeyboardButton.WithCallbackData("List Rss"), InlineKeyboardButton.WithCallbackData("Remove Rss"), InlineKeyboardButton.WithCallbackData("Add Rss") }; keyboardButtonsRss[1] = new InlineKeyboardButton[] { InlineKeyboardButton.WithCallbackData("Back to Home") }; _telegramBotClient.EditMessageTextAsync( _callbackQueryEventArgs.CallbackQuery.From.Id, _callbackQueryEventArgs.CallbackQuery.Message.MessageId, "List/Edit Rss.", replyMarkup: new InlineKeyboardMarkup(keyboardButtonsRss)).GetAwaiter(); }