-
-
Notifications
You must be signed in to change notification settings - Fork 690
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1401 from TelegramBots/develop
OnMessage/OnUpdate & other stuff
- Loading branch information
Showing
118 changed files
with
395 additions
and
685 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
using System.Net.Http; | ||
using Telegram.Bot.Requests.Abstractions; | ||
|
||
namespace Telegram.Bot.Args; | ||
|
||
/// <summary> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
using System.Net.Http; | ||
|
||
namespace Telegram.Bot.Args; | ||
|
||
/// <summary> | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
#pragma warning disable 1591 | ||
|
||
namespace Telegram.Bot; | ||
|
||
public delegate ValueTask AsyncEventHandler<in TArgs>(ITelegramBotClient botClient, TArgs args, CancellationToken cancellationToken = default); | ||
public delegate Task OnUpdateHandler(Update update); | ||
public delegate Task OnMessageHandler(Message message, UpdateType type); | ||
public delegate Task OnErrorHandler(Exception exception, Polling.HandleErrorSource source); | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace Telegram.Bot.Extensions; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
using System.Net.Http; | ||
using System.Runtime.CompilerServices; | ||
|
||
namespace Telegram.Bot.Extensions; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
namespace Telegram.Bot; | ||
|
||
/// <summary>Static class offering JsonSerializerOptions configured for Bot API serialization</summary> | ||
public static class JsonBotAPI | ||
{ | ||
/// <summary>JsonSerializerOptions configured for Bot API serialization</summary> | ||
public static JsonSerializerOptions Options { get; } | ||
|
||
static JsonBotAPI() => Configure(Options = new()); | ||
|
||
/// <summary>Configure JsonSerializerOptions for Bot API serialization</summary> | ||
/// <param name="options">JsonSerializerOptions to configure</param> | ||
public static void Configure(JsonSerializerOptions options) | ||
{ | ||
options.PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower; | ||
options.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingDefault; | ||
options.UnmappedMemberHandling = JsonUnmappedMemberHandling.Skip; | ||
//options.AllowOutOfOrderMetadataProperties = true; // when System.Text.Json 9.0 is available, so we don't need custom PolymorphicJsonConverterFactory | ||
options.Converters.Add(new PolymorphicJsonConverterFactory()); | ||
//options.Converters.Add(new BanTimeConverter()); | ||
//options.Converters.Add(new ChatIdConverter()); | ||
//options.Converters.Add(new InputFileConverter()); | ||
//options.Converters.Add(new UnixDateTimeConverter()); | ||
//AddGeneratedConverters(Options.Converters); | ||
} | ||
|
||
//static partial void AddGeneratedConverters(IList<JsonConverter> converters); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
src/Telegram.Bot/Requests/Available methods/Manage Chat/UnpinAllGeneralForumTopicMessages.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 4 additions & 19 deletions
23
src/Telegram.Bot/Serialization/JsonSerializerOptionsProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,13 @@ | ||
namespace Telegram.Bot.Serialization; | ||
|
||
/// <summary>Static class offering JsonSerializerOptions configured for Telegram.Bot serialization</summary> | ||
public static partial class JsonSerializerOptionsProvider | ||
public static class JsonSerializerOptionsProvider | ||
{ | ||
/// <summary>JsonSerializerOptions configured for Telegram.Bot serialization</summary> | ||
public static JsonSerializerOptions Options { get; } | ||
|
||
static JsonSerializerOptionsProvider() => Configure(Options = new JsonSerializerOptions()); | ||
public static JsonSerializerOptions Options => JsonBotAPI.Options; | ||
|
||
/// <summary>Configure JsonSerializerOptions for Telegram.Bot serialization</summary> | ||
/// <param name="options">JsonSerializerOptions to configure</param> | ||
public static void Configure(JsonSerializerOptions options) | ||
{ | ||
options.PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower; | ||
options.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingDefault; | ||
options.UnmappedMemberHandling = JsonUnmappedMemberHandling.Skip; | ||
//options.AllowOutOfOrderMetadataProperties = true; // when System.Text.Json 9.0 is available, so we don't need custom PolymorphicJsonConverterFactory | ||
options.Converters.Add(new PolymorphicJsonConverterFactory()); | ||
//options.Converters.Add(new BanTimeConverter()); | ||
//options.Converters.Add(new ChatIdConverter()); | ||
//options.Converters.Add(new InputFileConverter()); | ||
//options.Converters.Add(new UnixDateTimeConverter()); | ||
//AddGeneratedConverters(Options.Converters); | ||
} | ||
|
||
//static partial void AddGeneratedConverters(IList<JsonConverter> converters); | ||
[Obsolete("Use JsonBotAPI.Configure()")] | ||
public static void Configure(JsonSerializerOptions options) => JsonBotAPI.Configure(options); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.