From 88d54eb5a680eaf4c817cfca9191e5752057dee1 Mon Sep 17 00:00:00 2001
From: Wizou <11647984+wiz0u@users.noreply.github.com>
Date: Wed, 12 Oct 2022 23:25:15 +0200
Subject: [PATCH] make SendAlbumAsync accept list too
---
src/Client.Helpers.cs | 16 +++++++++-------
src/Client.cs | 8 +++++---
src/WTelegramClient.csproj | 2 +-
3 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/src/Client.Helpers.cs b/src/Client.Helpers.cs
index 260cbdd..db97629 100644
--- a/src/Client.Helpers.cs
+++ b/src/Client.Helpers.cs
@@ -216,7 +216,7 @@ namespace WTelegram
/// Helper function to send an album (media group) of photos or documents more easily
/// Destination of message (chat group, channel, user chat, etc..)
- /// An array of InputMedia-derived class
+ /// An array or List of InputMedia-derived class
/// Caption for the media (in plain text) or
/// Your message is a reply to an existing message with this ID, in the same chat
/// Text formatting entities for the caption. You can use MarkdownToEntities to create these
@@ -228,14 +228,16 @@ namespace WTelegram
/// WTelegramClient proxy settings don't apply to HttpClient
/// * You may run into errors if you mix, in the same album, photos and file documents having no thumbnails/video attributes
///
- public async Task SendAlbumAsync(InputPeer peer, InputMedia[] medias, string caption = null, int reply_to_msg_id = 0, MessageEntity[] entities = null, DateTime schedule_date = default)
+ public async Task SendAlbumAsync(InputPeer peer, ICollection 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)
diff --git a/src/Client.cs b/src/Client.cs
index 30ccbce..da3ee18 100644
--- a/src/Client.cs
+++ b/src/Client.cs
@@ -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
/// Login as a user with given phone number (or resume previous session)
Call this method again to provide additional requested login information
/// First call should be with phone number
Further calls should be with the requested configuration value
/// Configuration item requested to continue login, or when login is successful
- /// Possible values: verification_code, name (signup), password (2FA)
+ /// Possible values: verification_code, name (signup), password (2FA), email & email_verification_code (email registration)
///
public async Task Login(string loginInfo)
{
@@ -972,7 +974,7 @@ namespace WTelegram
/// Login as a user (if not already logged-in).
///
(this method calls ConnectAsync if necessary)
- /// Config callback is queried for: phone_number, verification_code
and eventually first_name, last_name (signup required), password (2FA auth), user_id (alt validation)
+ /// Config callback is queried for: phone_number, verification_code
and eventually first_name, last_name (signup required), password (2FA auth), email & email_verification_code (email registration), user_id (alt validation)
/// (optional) Preference for verification_code sending
/// Proceed to logout and login if active user session cannot be resumed successfully
/// Detail about the logged-in user
diff --git a/src/WTelegramClient.csproj b/src/WTelegramClient.csproj
index b0963c6..1356ff0 100644
--- a/src/WTelegramClient.csproj
+++ b/src/WTelegramClient.csproj
@@ -23,7 +23,7 @@
git
Telegram;Client;Api;UserBot;MTProto;TLSharp;OpenTl
README.md
- IDE0079;0419;1573;1591
+ IDE0079;0419;1573;1591;NETSDK1138
TRACE;OBFUSCATION