make SendAlbumAsync accept list too

This commit is contained in:
Wizou 2022-10-12 23:25:15 +02:00
parent fdc05e5514
commit 88d54eb5a6
3 changed files with 15 additions and 11 deletions

View file

@ -216,7 +216,7 @@ namespace WTelegram
/// <summary>Helper function to send an album (media group) of photos or documents more easily</summary>
/// <param name="peer">Destination of message (chat group, channel, user chat, etc..) </param>
/// <param name="medias">An array of <see cref="InputMedia">InputMedia</see>-derived class</param>
/// <param name="medias">An array or List of <see cref="InputMedia">InputMedia</see>-derived class</param>
/// <param name="caption">Caption for the media <i>(in plain text)</i> or <see langword="null"/></param>
/// <param name="reply_to_msg_id">Your message is a reply to an existing message with this ID, in the same chat</param>
/// <param name="entities">Text formatting entities for the caption. You can use <see cref="Markdown.MarkdownToEntities">MarkdownToEntities</see> to create these</param>
@ -228,14 +228,16 @@ namespace WTelegram
/// WTelegramClient proxy settings don't apply to HttpClient<br/>
/// * You may run into errors if you mix, in the same album, photos and file documents having no thumbnails/video attributes
/// </remarks>
public async Task<Message[]> SendAlbumAsync(InputPeer peer, InputMedia[] medias, string caption = null, int reply_to_msg_id = 0, MessageEntity[] entities = null, DateTime schedule_date = default)
public async Task<Message[]> SendAlbumAsync(InputPeer peer, ICollection<InputMedia> medias, string caption = null, int reply_to_msg_id = 0, MessageEntity[] entities = null, DateTime schedule_date = default)
{
System.Net.Http.HttpClient httpClient = null;
var multiMedia = new InputSingleMedia[medias.Length];
int i = 0, length = medias.Count;
var multiMedia = new InputSingleMedia[length];
var random_id = Helpers.RandomLong();
for (int i = 0; i < medias.Length; i++)
foreach (var media in medias)
{
var ism = multiMedia[i] = new InputSingleMedia { random_id = random_id + i, media = medias[i] };
var ism = multiMedia[i] = new InputSingleMedia { random_id = random_id + i, media = media };
i++;
retry:
switch (ism.media)
{
@ -283,8 +285,8 @@ namespace WTelegram
var updates = await this.Messages_SendMultiMedia(peer, multiMedia, reply_to_msg_id: reply_to_msg_id, schedule_date: schedule_date);
RaiseUpdate(updates);
var msgIds = new int[medias.Length];
var result = new Message[medias.Length];
var msgIds = new int[length];
var result = new Message[length];
foreach (var update in updates.UpdateList)
{
switch (update)

View file

@ -10,13 +10,15 @@ using System.Net;
using System.Net.Sockets;
using System.Reflection;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Web;
using TL;
using static WTelegram.Encryption;
// necessary for .NET Standard 2.0 compilation:
#pragma warning disable CA1835 // Prefer the 'Memory'-based overloads for 'ReadAsync' and 'WriteAsync'
namespace WTelegram
{
public partial class Client : IDisposable
@ -877,7 +879,7 @@ namespace WTelegram
/// <summary>Login as a user with given phone number (or resume previous session)<br/>Call this method again to provide additional requested login information</summary>
/// <param name="loginInfo">First call should be with phone number<br/>Further calls should be with the requested configuration value</param>
/// <returns>Configuration item requested to continue login, or <see langword="null"/> when login is successful<br/>
/// Possible values: <b>verification_code</b>, <b>name</b> (signup), <b>password</b> (2FA)</returns>
/// Possible values: <b>verification_code</b>, <b>name</b> (signup), <b>password</b> (2FA), <b>email</b> &amp; <b>email_verification_code</b> (email registration)</returns>
/// <exception cref="ApplicationException"/><exception cref="RpcException"/>
public async Task<string> Login(string loginInfo)
{
@ -972,7 +974,7 @@ namespace WTelegram
/// <summary>Login as a user (if not already logged-in).
/// <br/><i>(this method calls <see cref="ConnectAsync">ConnectAsync</see> if necessary)</i></summary>
/// <remarks>Config callback is queried for: <b>phone_number</b>, <b>verification_code</b> <br/>and eventually <b>first_name</b>, <b>last_name</b> (signup required), <b>password</b> (2FA auth), <b>user_id</b> (alt validation)</remarks>
/// <remarks>Config callback is queried for: <b>phone_number</b>, <b>verification_code</b> <br/>and eventually <b>first_name</b>, <b>last_name</b> (signup required), <b>password</b> (2FA auth), <b>email</b> &amp; <b>email_verification_code</b> (email registration), <b>user_id</b> (alt validation)</remarks>
/// <param name="settings">(optional) Preference for verification_code sending</param>
/// <param name="reloginOnFailedResume">Proceed to logout and login if active user session cannot be resumed successfully</param>
/// <returns>Detail about the logged-in user

View file

@ -23,7 +23,7 @@
<RepositoryType>git</RepositoryType>
<PackageTags>Telegram;Client;Api;UserBot;MTProto;TLSharp;OpenTl</PackageTags>
<PackageReadmeFile>README.md</PackageReadmeFile>
<NoWarn>IDE0079;0419;1573;1591</NoWarn>
<NoWarn>IDE0079;0419;1573;1591;NETSDK1138</NoWarn>
<DefineConstants>TRACE;OBFUSCATION</DefineConstants>
</PropertyGroup>