Skip to content

Commit d32a866

Browse files
committed
Some fix/compatibility for Telegram Passport
1 parent bf1be0b commit d32a866

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

src/Telegram.Bot/Extend.Types.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using System.Globalization;
22
using System.Linq;
33

4+
#pragma warning disable IDE0290 // Use primary constructor
5+
46
namespace Telegram.Bot.Types
57
{
68
public partial class Message
@@ -421,5 +423,11 @@ public partial class PersonalDetails
421423
/// <summary>Date of birth</summary>
422424
public DateTime Birthday => DateTime.ParseExact(BirthDate, "dd.MM.yyyy", null, DateTimeStyles.None);
423425
}
426+
427+
public partial class PassportScopeElementOne
428+
{
429+
/// <summary>Initializes a new instance of the <see cref="PassportScopeElementOne"/> class with the specified type</summary>
430+
public PassportScopeElementOne(EncryptedPassportElementType type) => Type = type;
431+
}
424432
}
425433
}

src/Telegram.Bot/Types/Passport/AuthorizationRequestParameters.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace Telegram.Bot.Types.Passport;
44
public class AuthorizationRequestParameters
55
{
66
/// <summary>Unique identifier for the bot. You can get it from bot token. For example, for the bot token "1234567:4TT8bAc8GHUspu3ERYn-KGcvsvGB9u_n4ddy", the bot id is 1234567.</summary>
7-
public int BotId { get; }
7+
public long BotId { get; }
88

99
/// <summary>Public key of the bot</summary>
1010
public string PublicKey { get; }
@@ -40,16 +40,15 @@ public class AuthorizationRequestParameters
4040
/// In particular, it should be long enough and it should be generated using a cryptographically secure
4141
/// pseudorandom number generator. You should never accept credentials with the same nonce twice.</param>
4242
/// <param name="scope">Description of the data you want to request</param>
43-
public AuthorizationRequestParameters(int botId, string publicKey, string nonce, PassportScope scope)
43+
public AuthorizationRequestParameters(long botId, string publicKey, string nonce, PassportScope scope)
4444
{
4545
BotId = botId;
4646
PublicKey = publicKey ?? throw new ArgumentNullException(nameof(publicKey));
4747
Nonce = nonce ?? throw new ArgumentNullException(nameof(nonce));
4848
PassportScope = scope ?? throw new ArgumentNullException(nameof(PassportScope));
4949

5050
var scopeJson = JsonSerializer.Serialize(scope, JsonBotAPI.Options);
51-
Query = "domain=telegrampassport" +
52-
$"&bot_id={System.Uri.EscapeDataString(botId + "")}" +
51+
Query = $"domain=telegrampassport&bot_id={botId}" +
5352
$"&scope={System.Uri.EscapeDataString(scopeJson)}" +
5453
$"&public_key={System.Uri.EscapeDataString(publicKey)}" +
5554
$"&nonce={System.Uri.EscapeDataString(nonce)}";

src/Telegram.Bot/Types/Passport/PassportScope.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ public partial class PassportScope
1010

1111
/// <summary>Scope version, must be <em>1</em></summary>
1212
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
13-
public int V { get; set; }
13+
public int V { get; set; } = 1;
1414
}

0 commit comments

Comments
 (0)