Skip to content

Commit

Permalink
Add support for api v8.1
Browse files Browse the repository at this point in the history
Signed-off-by: Niklas Weimann <[email protected]>
  • Loading branch information
niklasweimann committed Dec 25, 2024
1 parent fd00043 commit 1e4de0c
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=RxTelegram_RxTelegram.Bot&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=RxTelegram_RxTelegram.Bot)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=RxTelegram_RxTelegram.Bot&metric=coverage)](https://sonarcloud.io/summary/new_code?id=RxTelegram_RxTelegram.Bot)

RxTelegram.Bot supports Telegram Bot API 8.0 (as at November 17, 2024).
RxTelegram.Bot supports Telegram Bot API 8.1 (as at December 4, 2024).

This is a reactive designed .NET Library for the Telegram Bot API. It works with the official [Reactive Extentions](https://github.com/dotnet/reactive).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ public enum TransactionPartnerType
[ImplementationType(typeof(TransactionPartnerTelegramAds))]
TelegramAds,


[ImplementationType(typeof(TransactionPartnerOther))]
Other,

[ImplementationType(typeof(TransactionPartnerTelegramApi))]
TelegramApi
TelegramApi,

[ImplementationType(typeof(TransactionPartnerAffiliateProgram))]
AffiliateProgram
}
36 changes: 36 additions & 0 deletions src/RxTelegram.Bot/Interface/Payments/AffiliateInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using RxTelegram.Bot.Interface.BaseTypes;

namespace RxTelegram.Bot.Interface.Payments;

/// <summary>
/// Contains information about the affiliate that received a commission via this transaction.
/// </summary>
public class AffiliateInfo
{
/// <summary>
/// Optional. The bot or the user that received an affiliate commission if it was received by a bot or a user
/// </summary>
public User AffiliateUser { get; set; }

/// <summary>
/// Optional. The chat that received an affiliate commission if it was received by a chat
/// </summary>
public Chat AffiliateChat { get; set; }

/// <summary>
/// The number of Telegram Stars received by the affiliate for each 1000 Telegram Stars received by the bot from referred users
/// </summary>
public int CommissionPerMille { get; set; }

/// <summary>
/// Integer amount of Telegram Stars received by the affiliate from the transaction, rounded to 0;
/// can be negative for refunds
/// </summary>
public int Amount { get; set; }

/// <summary>
/// Optional. The number of 1/1000000000 shares of Telegram Stars received by the affiliate; from -999999999 to 999999999;
/// can be negative for refunds
/// </summary>
public int? NanostarAmount { get; set; }
}
5 changes: 5 additions & 0 deletions src/RxTelegram.Bot/Interface/Payments/StarTransaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ public class StarTransaction
/// </summary>
public int Amount { get; set; }

/// <summary>
/// Optional. The number of 1/1000000000 shares of Telegram Stars transferred by the transaction; from 0 to 999999999
/// </summary>
public int? NanostarAmount { get; set; }

/// <summary>
/// Date the transaction was created in Unix time
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using RxTelegram.Bot.Interface.BaseTypes;
using RxTelegram.Bot.Interface.BaseTypes.Enums;

namespace RxTelegram.Bot.Interface.Payments;

/// <summary>
/// Describes the affiliate program that issued the affiliate commission received via this transaction.
/// </summary>
public class TransactionPartnerAffiliateProgram : TransactionPartner
{
/// <summary>
/// Type of the transaction partner, always “affiliate_program”
/// </summary>
public override TransactionPartnerType Type { get; set; } = TransactionPartnerType.AffiliateProgram;

/// <summary>
/// Optional. Information about the bot that sponsored the affiliate program
/// </summary>
public User SponsorUser { get; set; }

/// <summary>
/// The number of Telegram Stars received by the bot for each 1000 Telegram Stars received by the affiliate program sponsor from referred users
/// </summary>
public int CommissionPerMille { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ public class TransactionPartnerOther : TransactionPartner
/// <summary>
/// Type of the transaction partner, always “other”
/// </summary>
public override TransactionPartnerType Type { get; set; }
public override TransactionPartnerType Type { get; set; } = TransactionPartnerType.Other;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ public class TransactionPartnerTelegramAds : TransactionPartner
/// <summary>
/// Type of the transaction partner, always “telegram_ads”
/// </summary>
public override TransactionPartnerType Type { get; set; }
public override TransactionPartnerType Type { get; set; } = TransactionPartnerType.TelegramAds;
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public class TransactionPartnerUser : TransactionPartner
/// </summary>
public User User { get; set; }

public AffiliateInfo Affiliate { get; set; }

/// <summary>
/// Optional. Bot-specified invoice payload
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/RxTelegram.Bot/RxTelegram.Bot.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<RepositoryUrl>https://github.com/RxTelegram/RxTelegram.Bot</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>Telegram;Bot;Api;Rx;Reactive;Observable;RxTelegram;RxTelegram.Bot</PackageTags>
<PackageVersion>8.0.0</PackageVersion>
<PackageVersion>8.1.0</PackageVersion>
<PackageIcon>icon.png</PackageIcon>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
Expand Down

0 comments on commit 1e4de0c

Please sign in to comment.