public static bool AnswerInlineQuery(this BotClient api, string inlineQueryId, IEnumerable <InlineQueryResult> results, [Optional] uint?cacheTime, [Optional] bool?isPersonal, [Optional] string?nextOffset, [Optional] string?switchPmText, [Optional] string?switchPmParameter) { if (api == null) { throw new ArgumentNullException(nameof(api)); } var args = new AnswerInlineQueryArgs(inlineQueryId, results) { CacheTime = cacheTime, IsPersonal = isPersonal, NextOffset = nextOffset, SwitchPmText = switchPmText, SwitchPmParameter = switchPmParameter }; return(api.RPC <bool>(MethodNames.AnswerInlineQuery, args)); }
public static async Task <bool> AnswerInlineQueryAsync(this BotClient api, string inlineQueryId, IEnumerable <InlineQueryResult> results, [Optional] uint?cacheTime, [Optional] bool?isPersonal, [Optional] string?nextOffset, [Optional] string?switchPmText, [Optional] string?switchPmParameter, [Optional] CancellationToken cancellationToken) { if (api == null) { throw new ArgumentNullException(nameof(api)); } var args = new AnswerInlineQueryArgs(inlineQueryId, results) { CacheTime = cacheTime, IsPersonal = isPersonal, NextOffset = nextOffset, SwitchPmText = switchPmText, SwitchPmParameter = switchPmParameter }; return(await api.RPCA <bool>(MethodNames.AnswerInlineQuery, args, cancellationToken).ConfigureAwait(false)); }
public static async Task <bool> AnswerInlineQueryAsync(this BotClient bot, AnswerInlineQueryArgs args, [Optional] CancellationToken cancellationToken) { if (bot == default) { throw new ArgumentNullException(nameof(bot)); } if (args == default) { throw new ArgumentNullException(nameof(args)); } var stream = new MemoryStream(); await JsonSerializer.SerializeAsync(stream, args, typeof(AnswerInlineQueryArgs), BotClient.DefaultSerializerOptions, cancellationToken : cancellationToken).ConfigureAwait(false); stream.Seek(0, SeekOrigin.Begin); return(await bot.RPCA <bool>(MethodNames.AnswerInlineQuery, stream, cancellationToken).ConfigureAwait(false)); }
public static bool AnswerInlineQuery(this BotClient bot, AnswerInlineQueryArgs args) { if (bot == default) { throw new ArgumentNullException(nameof(bot)); } if (args == default) { throw new ArgumentNullException(nameof(args)); } var stream = new MemoryStream(); using var json = new Utf8JsonWriter(stream); JsonSerializer.Serialize(json, args, typeof(AnswerInlineQueryArgs), BotClient.DefaultSerializerOptions); json.Flush(); json.Dispose(); stream.Seek(0, SeekOrigin.Begin); return(bot.RPC <bool>(MethodNames.AnswerInlineQuery, stream)); }