private static async void Bot_OnInlineQuery(object sender, Telegram.Bot.Args.InlineQueryEventArgs e) { string query = e.InlineQuery.Query; if (query.Length < 3) { return; } Database.discsArray[] discs = db.Search(query.ToLower()); InlineQueryResultBase[] results = new InlineQueryResultArticle[discs.Length]; for (int i = 0; i < results.Length; i++) { var temp = new InlineQueryResultArticle(Convert.ToString(discs[i].id), title: discs[i].name, new InputTextMessageContent($"Товар {discs[i].id}: {discs[i].name}")); temp.Description = discs[i].platform + " | " + discs[i].price + " BYN"; results[i] = temp; } if (results.Length == 0) { return; } Console.WriteLine(query); db.SetAwaitInfoType(e.InlineQuery.From.Id, (int)awaitInfoType.searchResult); try { await bot.AnswerInlineQueryAsync(e.InlineQuery.Id, results); } catch (Telegram.Bot.Exceptions.InvalidParameterException e5) { log.Error(e5.Message); return; } }
private static void PollInlineQuery(object sender, Telegram.Bot.Args.InlineQueryEventArgs e) { if (bShouldIgnore) { bShouldIgnore = false; return; } var query = e.InlineQuery; var UserId = query.From.Id; var text = query.Query; var req = pollManager.GetPollsByUser(UserId) .Where(p => p.Name.Contains(text)) .Select(p => { List <InlineKeyboardButton[]> opt = GetPollButtons(p); var message = BuildPoolMessage(p.Id, p.Name); return(new InlineQueryResultArticle { Id = p.Id.ToString(), Title = p.Name, Description = "Send pool to chat", ReplyMarkup = new InlineKeyboardMarkup(opt), InputMessageContent = new InputTextMessageContent { MessageText = message } }); }); bot.AnswerInlineQueryAsync(query.Id, req, 0); }
private async void M_TelegramBotClient_OnInlineQuery(object sender, Telegram.Bot.Args.InlineQueryEventArgs e) { try { await m_TelegramBotClient.AnswerCallbackQueryAsync(e.InlineQuery.Id, null, false, "http://79.127.47.210:76/test/index.html"); } catch (Exception ex) { // respond to user: await m_TelegramBotClient.SendTextMessageAsync(e.InlineQuery.From.Id, "خطایی رخ داده! گزارش خطا به توسعه دهنده ربات ارسال خواهد شد. لطفا دوباره تلاش کنید."); // report to group: await m_TelegramBotClient.SendTextMessageAsync(m_ReportGroupChatId, ex.StackTrace); } }
private async void Bot_OnInlineQuery(object sender, Telegram.Bot.Args.InlineQueryEventArgs e) { if (string.IsNullOrEmpty(e.InlineQuery.Query)) { return; } string nextOffset = null; if (e.InlineQuery.Query.StartsWith("r")) { nextOffset = "register"; } InlineQueryResult[] results = { new InlineQueryResultLocation { Id = "1", Latitude = 40.7058334f, // displayed result Longitude = -74.25819f, Title = "New York", InputMessageContent = new InputLocationMessageContent // message if result is selected { Latitude = 40.7058334f, Longitude = -74.25819f, } }, new InlineQueryResultLocation { Id = "2", Longitude = 52.507629f, // displayed result Latitude = 13.1449577f, Title = "Berlin", InputMessageContent = new InputLocationMessageContent // message if result is selected { Longitude = 52.507629f, Latitude = 13.1449577f } } }; await Bot.AnswerInlineQueryAsync(e.InlineQuery.Id, results, isPersonal : true, cacheTime : 0); }
private void _botClient_OnInlineQuery(object sender, Telegram.Bot.Args.InlineQueryEventArgs e) { if (e.InlineQuery.Query == null) { return; } if (e.InlineQuery.Query == "") { return; } try { var inlineQueryResults = GetInlineQueryResultPhotos(e.InlineQuery.Query); _logger.LogInformation($"Query:{e.InlineQuery.Query} From:{e.InlineQuery.From.FirstName} {e.InlineQuery.From.LastName} Results:{inlineQueryResults.Count()}"); var task = _botClient.AnswerInlineQueryAsync(e.InlineQuery.Id, inlineQueryResults, 6000000, true); task.Wait(); } catch (Exception ex) { _logger.LogError(ex.ToString(), ex); } }
private void Bot_OnInlineQuery(object sender, TBot.Args.InlineQueryEventArgs e) { }
private static void Client_OnInlineQuery(object sender, Telegram.Bot.Args.InlineQueryEventArgs e) { }
private async void BotClient_OnInlineQuery(Object sender, Telegram.Bot.Args.InlineQueryEventArgs e) { List <InlineQueryResultBase> list = new List <InlineQueryResultBase>(); DataBase db = Singleton.GetInstance().Context; Channel[] channels = db.GetChannels(); Category[] categories = db.GetCategories(); if (e.InlineQuery.Query == "") { list.Clear(); foreach (Channel channel in channels) { Settings settings = db._settings.FirstOrDefault(); if (channel.IDChannel != settings.ChannelAdmin) { String text = ""; if (channel.Description != null) { List <String> description = channel.Description.Split("\n").ToList(); for (Int32 i = 0; i < description.Count; i++) { if (description[i].StartsWith("ПРАВИЛА")) { continue; } if (description[i].Length == 0) { continue; } text += description[i] + "\n" + "\n"; } } List <List <InlineKeyboardButton> > button = new List <List <InlineKeyboardButton> > { new List <InlineKeyboardButton>() }; button[button.Count - 1] .Add(new InlineKeyboardButton() { Text = "Перейти в канал", Url = channel.LinkChannel }); button.Add(new List <InlineKeyboardButton>()); button[button.Count - 1] .Add(new InlineKeyboardButton() { Text = "Категории", SwitchInlineQueryCurrentChat = "" }); button.Add(new List <InlineKeyboardButton>()); button[button.Count - 1] .Add(new InlineKeyboardButton() { Text = "Закрыть", CallbackData = CommandText.Close }); list.Add(new InlineQueryResultArticle(id: channel.IDChannel.ToString(), title: channel.ChannelName, inputMessageContent: new InputTextMessageContent($"{text}\nЗаходите - " + channel.InviteLink)) { Url = "https://" + channel.LinkChannel, Title = channel.ChannelName, Description = text, HideUrl = true, ThumbUrl = channel.PhotoLink, ThumbHeight = 48, ThumbWidth = 48, ReplyMarkup = button.ToArray() }); } } } else if (categories.Any(p => p.Name == e.InlineQuery.Query)) { list.Clear(); Category category = categories.FirstOrDefault(p => p.Name == e.InlineQuery.Query); foreach (Channel channel in channels) { if (category.Id != channel.CategoryId) { continue; } String text = ""; if (channel.Description != null) { List <String> description = channel.Description.Split("\n").ToList(); for (Int32 i = 0; i < description.Count; i++) { if (description[i].StartsWith("ПРАВИЛА")) { continue; } if (description[i].Length == 0) { continue; } text += description[i] + "\n" + "\n"; } } List <List <InlineKeyboardButton> > button = new List <List <InlineKeyboardButton> > { new List <InlineKeyboardButton>() }; button[button.Count - 1] .Add(new InlineKeyboardButton() { Text = "Перейти в канал", Url = channel.LinkChannel }); button.Add(new List <InlineKeyboardButton>()); button[button.Count - 1] .Add(new InlineKeyboardButton() { Text = "Категории", SwitchInlineQueryCurrentChat = "" }); button.Add(new List <InlineKeyboardButton>()); button[button.Count - 1] .Add(new InlineKeyboardButton() { Text = "Закрыть", CallbackData = CommandText.Close }); list.Add(new InlineQueryResultArticle(id: channel.IDChannel.ToString(), title: channel.ChannelName, inputMessageContent: new InputTextMessageContent($"{text}\nЗаходите - " + channel.InviteLink)) { Url = "https://" + channel.LinkChannel, Title = channel.ChannelName, Description = text, HideUrl = true, ThumbUrl = channel.PhotoLink != "" ? channel.PhotoLink : "https://bipbap.ru/wp-content/uploads/2017/10/0_8eb56_842bba74_XL-640x400.jpg", ThumbHeight = 48, ThumbWidth = 48, ReplyMarkup = button.ToArray() }); } } try { await BotClient.AnswerInlineQueryAsync(e.InlineQuery.Id, list, isPersonal : true, cacheTime : 0); } catch (Exception b) { Log.Logging(b); } }
private void BotClient_OnInlineQuery(object sender, Telegram.Bot.Args.InlineQueryEventArgs e) { if (AnswerMessage(e.InlineQuery.From.Id)) { } }
private static void Bot_OnInlineQuery(object sender, Telegram.Bot.Args.InlineQueryEventArgs e) { new Task(() => { }).Start(); }
private static void BotInline(object sender, Telegram.Bot.Args.InlineQueryEventArgs e) { }
protected void Api_OnInlineQuery(object sender, Telegram.Bot.Args.InlineQueryEventArgs e) { throw new NotImplementedException(); }
private void _TBC_OnInlineQuery(object sender, Telegram.Bot.Args.InlineQueryEventArgs e) { }
private static void BOT_TEST(object sender, Telegram.Bot.Args.InlineQueryEventArgs w) { }
private static async void _bot_OnInlineQuery(object sender, Telegram.Bot.Args.InlineQueryEventArgs e) { Console.WriteLine($"InlineQuery. {e.InlineQuery.Query}"); }