Skip to content

Commit

Permalink
Updated to Bot API 6.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Eptagone committed Feb 5, 2023
1 parent 02b746e commit 7a4d6b5
Show file tree
Hide file tree
Showing 19 changed files with 654 additions and 460 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
| <img src="./docs/icon.png" alt="Logo" width="64"/> | <h1>Telegram.BotAPI for NET</h1> |
| <img src="./docs/icon.png" alt="Logo" width="64"/> | <h1>Telegram.BotAPI</h1> |
| -------------------------------------------------- | -------------------------------- |

[![NuGet version (Telegram.BotAPI)](https://img.shields.io/nuget/v/Telegram.BotAPI.svg?style=flat-square)](https://www.nuget.org/packages/Telegram.BotAPI/)
[![Compatible with Bot API v6.4](https://img.shields.io/badge/Bot%20API%20version-v6.4-blue?style=flat-square)](https://core.telegram.org/bots/api#december-30-2022)
[![Compatible with Bot API v6.5](https://img.shields.io/badge/Bot%20API%20version-v6.5-blue?style=flat-square)](https://core.telegram.org/bots/api#february-3-2023)

**Telegram.BotAPI** is one of the most complete libraries available to interact with the Telegram Bot API in your .NET projects. Free and open source.

It contains all the methods and types available in the Bot API 6.4 released on December 30, 2022.
It contains all the methods and types available in the Bot API 6.5 released on February 3, 2023.

---

## Features

- Contains pre-defined methods for all Bot API 6.4 methods.
- Contains classes for each object type used in the Bot API 6.4.
- Contains pre-defined methods for all Bot API 6.5 methods.
- Contains classes for each object type used in the Bot API 6.5.
- Sync and async methods.
- Support [System.Text.Json](https://www.nuget.org/packages/System.Text.Json/) and [Newtonsoft.Json](https://www.nuget.org/packages/Newtonsoft.Json/).

Expand Down
2 changes: 1 addition & 1 deletion src/Telegram.BotAPI.Examples/readme.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Telegram.BotAPI NET Examples

[![NuGet version (Telegram.BotAPI)](https://img.shields.io/nuget/v/Telegram.BotAPI.svg?style=flat-square)](https://www.nuget.org/packages/Telegram.BotAPI/)
[![Compatible with Bot API v6.4](https://img.shields.io/badge/Bot%20API%20version-v6.4-blue?style=flat-square)](https://core.telegram.org/bots/api#december-30-2022)
[![Compatible with Bot API v6.5](https://img.shields.io/badge/Bot%20API%20version-v6.5-blue?style=flat-square)](https://core.telegram.org/bots/api#february-3-2023)

## Sample list

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public RestrictChatMemberArgs(long chatId, long userId, ChatPermissions permissi
this.UserId = userId;
this.Permissions = permissions ?? throw new ArgumentNullException(nameof(permissions));
}

/// <summary>
/// Initializes a new instance of the <see cref="RestrictChatMemberArgs"/> class.
/// </summary>
Expand All @@ -38,19 +39,33 @@ public RestrictChatMemberArgs(string chatId, long userId, ChatPermissions permis
this.Permissions = permissions ?? throw new ArgumentNullException(nameof(permissions));
}

/// <summary>Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername).</summary>
/// <summary>
/// Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
/// </summary>
[JsonPropertyName(PropertyNames.ChatId)]
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public object ChatId { get; }
/// <summary>Unique identifier of the target user.</summary>
/// <summary>
/// Unique identifier of the target user
/// </summary>
[JsonPropertyName(PropertyNames.UserId)]
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public long UserId { get; }
/// <summary>New user permissions.</summary>
/// <summary>
/// A JSON-serialized object for new user permissions
/// </summary>
[JsonPropertyName(PropertyNames.Permissions)]
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public ChatPermissions Permissions { get; }
/// <summary>Optional. Date when restrictions will be lifted for the user, unix time. If user is restricted for more than 366 days or less than 30 seconds from the current time, they are considered to be restricted forever.</summary>
/// <summary>
/// Pass True if chat permissions are set independently. Otherwise, the can_send_other_messages and can_add_web_page_previews permissions will imply the can_send_messages, can_send_audios, can_send_documents, can_send_photos, can_send_videos, can_send_video_notes, and can_send_voice_notes permissions; the can_send_polls permission will imply the can_send_messages permission.
/// </summary>
[JsonPropertyName(PropertyNames.UseIndependentChatPermissions)]
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public bool? UseIndependentChatPermissions { get; set; }
/// <summary>
/// Date when restrictions will be lifted for the user, unix time. If user is restricted for more than 366 days or less than 30 seconds from the current time, they are considered to be restricted forever
/// </summary>
[JsonPropertyName(PropertyNames.UntilDate)]
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public uint? UntilDate { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright (c) 2023 Quetzal Rivera.
// Licensed under the MIT License, See LICENCE in the project root for license information.

using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;

namespace Telegram.BotAPI.AvailableTypes
{
/// <summary>
/// SetChatPermissions method arguments.
/// </summary>
[JsonObject(MemberSerialization = MemberSerialization.OptIn, NamingStrategyType = typeof(SnakeCaseNamingStrategy))]
public class SetChatPermissionsArgs
{
/// <summary>
/// Initialize a new instance of <see cref="SetChatPermissionsArgs"/>.
/// </summary>
/// <param name="chatId">Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername).</param>
/// <param name="permissions">New default chat permissions.</param>
public SetChatPermissionsArgs(string chatId, ChatPermissions permissions)
{
this.ChatId = chatId ?? throw new ArgumentNullException(nameof(chatId));
this.Permissions = permissions ?? throw new ArgumentNullException(nameof(permissions));
}

/// <summary>
/// Initialize a new instance of <see cref="SetChatPermissionsArgs"/>.
/// </summary>
/// <param name="chatId">Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername).</param>
/// <param name="permissions">New default chat permissions.</param>
public SetChatPermissionsArgs(long chatId, ChatPermissions permissions)
{
this.ChatId = chatId;
this.Permissions = permissions ?? throw new ArgumentNullException(nameof(permissions));
}

/// <summary>
/// Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
/// </summary>
[JsonPropertyName(PropertyNames.ChatId)]
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public object ChatId { get; }
/// <summary>
/// A JSON-serialized object for new default chat permissions
/// </summary>
[JsonPropertyName(PropertyNames.Permissions)]
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public ChatPermissions Permissions { get; }
/// <summary>
/// Pass True if chat permissions are set independently. Otherwise, the can_send_other_messages and can_add_web_page_previews permissions will imply the can_send_messages, can_send_audios, can_send_documents, can_send_photos, can_send_videos, can_send_video_notes, and can_send_voice_notes permissions; the can_send_polls permission will imply the can_send_messages permission.
/// </summary>
[JsonPropertyName(PropertyNames.UseIndependentChatPermissions)]
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public bool? UseIndependentChatPermissions { get; set; }

}
}
Loading

0 comments on commit 7a4d6b5

Please sign in to comment.