Example #1
0
 ///<summary>Use this method to set the score of the specified user in a game.</summary>
 ///<param name="bot">BotClient</param>
 /// <param name="args">Parameters.</param>
 /// <param name="cancellationToken">The cancellation token to cancel operation.</param>
 /// <exception cref="BotRequestException">Thrown when a request to Telegram Bot API got an error response.</exception>
 /// <exception cref="ArgumentNullException">Thrown when a required parameter is null.</exception>
 /// <returns><see cref="Message"/> or <see cref="bool"/>. On success, if the message was sent by the bot, returns the edited Message, otherwise returns True. Returns an error, if the new score is not greater than the user's current score in the chat and force is False.</returns>
 public static async Task <Message> SetGameScoreAsync(this BotClient bot, SetGameScoreArgs args, [Optional] CancellationToken cancellationToken)
 {
     if (bot == default)
     {
         throw new ArgumentNullException(nameof(bot));
     }
     if (args == default)
     {
         throw new ArgumentNullException(nameof(args));
     }
     return(await bot.RPCA <Message>(MethodNames.SetGameScore, args, cancellationToken : cancellationToken).ConfigureAwait(false));
 }
Example #2
0
 ///<summary>Use this method to set the score of the specified user in a game.</summary>
 ///<param name="bot">BotClient</param>
 /// <param name="args">Parameters.</param>
 /// <exception cref="BotRequestException">Thrown when a request to Telegram Bot API got an error response.</exception>
 /// <exception cref="ArgumentNullException">Thrown when a required parameter is null.</exception>
 /// <returns><see cref="Message"/> or <see cref="bool"/>. On success, if the message was sent by the bot, returns the edited Message, otherwise returns True. Returns an error, if the new score is not greater than the user's current score in the chat and force is False.</returns>
 public static Message SetGameScore(this BotClient bot, SetGameScoreArgs args)
 {
     if (bot == default)
     {
         throw new ArgumentNullException(nameof(bot));
     }
     if (args == default)
     {
         throw new ArgumentNullException(nameof(args));
     }
     return(bot.RPC <Message>(MethodNames.SetGameScore, args));
 }
Example #3
0
 ///<summary>Use this method to set the score of the specified user in a game.</summary>
 ///<param name="bot">BotClient</param>
 /// <param name="args">Parameters.</param>
 /// <param name="cancellationToken">The cancellation token to cancel operation.</param>
 /// <exception cref="BotRequestException">Thrown when a request to Telegram Bot API got an error response.</exception>
 /// <exception cref="ArgumentNullException">Thrown when a required parameter is null.</exception>
 /// <exception cref="ArgumentException">Thrown when T is not Telegram.BotAPI.AvailableTypes.Message or bool.</exception>
 /// <returns><see cref="Message"/> or <see cref="bool"/>. On success, if the message was sent by the bot, returns the edited Message, otherwise returns True. Returns an error, if the new score is not greater than the user's current score in the chat and force is False.</returns>
 public static async Task <T> SetGameScoreAsync <T>(this BotClient bot, SetGameScoreArgs args, [Optional] CancellationToken cancellationToken)
 {
     if (bot == default)
     {
         throw new ArgumentNullException(nameof(bot));
     }
     if (args == default)
     {
         throw new ArgumentNullException(nameof(args));
     }
     if (typeof(T) != typeof(Message) && typeof(T) != typeof(bool) && typeof(T) != typeof(JObject) && typeof(T) != typeof(JsonDocument))
     {
         throw new ArgumentException($"{nameof(T)} must be Telegram.BotAPI.AvailableTypes.Message or bool.");
     }
     return(await bot.RPCA <T>(MethodNames.SetGameScore, args, cancellationToken : cancellationToken).ConfigureAwait(false));
 }
Example #4
0
 ///<summary>Use this method to set the score of the specified user in a game.</summary>
 ///<param name="bot">BotClient</param>
 /// <param name="args">Parameters.</param>
 /// <exception cref="BotRequestException">Thrown when a request to Telegram Bot API got an error response.</exception>
 /// <exception cref="ArgumentNullException">Thrown when a required parameter is null.</exception>
 /// <exception cref="ArgumentException">Thrown when T is not Telegram.BotAPI.AvailableTypes.Message or bool.</exception>
 /// <returns><see cref="Message"/> or <see cref="bool"/>. On success, if the message was sent by the bot, returns the edited Message, otherwise returns True. Returns an error, if the new score is not greater than the user's current score in the chat and force is False.</returns>
 public static T SetGameScore <T>(this BotClient bot, SetGameScoreArgs args)
 {
     if (bot == default)
     {
         throw new ArgumentNullException(nameof(bot));
     }
     if (args == default)
     {
         throw new ArgumentNullException(nameof(args));
     }
     if (typeof(T) != typeof(Message) && typeof(T) != typeof(bool) && typeof(T) != typeof(JObject) && typeof(T) != typeof(JsonDocument))
     {
         throw new ArgumentException($"{nameof(T)} must be Telegram.BotAPI.AvailableTypes.Message or bool.");
     }
     return(bot.RPC <T>(MethodNames.SetGameScore, args));
 }