Merge pull request #1066 from strongtu/master

send_game needs chat_id by ChatId not u32
This commit is contained in:
Waffle Maybe 2024-07-21 14:36:30 +00:00 committed by GitHub
commit 89ad80dcca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 15 additions and 9 deletions

View file

@ -106,6 +106,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fix roundtrip de/serialization of `InlineQueryResult` ([#990][pr990]) - Fix roundtrip de/serialization of `InlineQueryResult` ([#990][pr990])
- Deserialization of `ApiError::CantParseEntities` ([#839][pr839]) - Deserialization of `ApiError::CantParseEntities` ([#839][pr839])
- Deserialization of empty (content-less) messages that can sometimes appear as a part of callback query ([#850][pr850], issue [#873][issue873]) - Deserialization of empty (content-less) messages that can sometimes appear as a part of callback query ([#850][pr850], issue [#873][issue873])
- Type of `chat_id` in `send_game`: `u32` => `ChatId` ([#1066][pr1066])
[pr839]: https://github.com/teloxide/teloxide/pull/839 [pr839]: https://github.com/teloxide/teloxide/pull/839
[pr879]: https://github.com/teloxide/teloxide/pull/879 [pr879]: https://github.com/teloxide/teloxide/pull/879
@ -113,6 +114,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[pr854]: https://github.com/teloxide/teloxide/pull/854 [pr854]: https://github.com/teloxide/teloxide/pull/854
[pr936]: https://github.com/teloxide/teloxide/pull/936 [pr936]: https://github.com/teloxide/teloxide/pull/936
[pr990]: https://github.com/teloxide/teloxide/pull/990 [pr990]: https://github.com/teloxide/teloxide/pull/990
[pr990]: https://github.com/teloxide/teloxide/pull/990
[pr1066]: https://github.com/teloxide/teloxide/pull/1066
### Changed ### Changed

View file

@ -4271,7 +4271,7 @@ Schema(
params: [ params: [
Param( Param(
name: "chat_id", name: "chat_id",
ty: u32, ty: RawTy("ChatId"),
descr: Doc(md: "Unique identifier for the target chat"), descr: Doc(md: "Unique identifier for the target chat"),
), ),
Param( Param(

View file

@ -941,7 +941,7 @@ trait ErasableRequester<'a> {
fn send_game( fn send_game(
&self, &self,
chat_id: u32, chat_id: ChatId,
game_short_name: String, game_short_name: String,
) -> ErasedRequest<'a, SendGame, Self::Err>; ) -> ErasedRequest<'a, SendGame, Self::Err>;
@ -1859,7 +1859,7 @@ where
fn send_game( fn send_game(
&self, &self,
chat_id: u32, chat_id: ChatId,
game_short_name: String, game_short_name: String,
) -> ErasedRequest<'a, SendGame, Self::Err> { ) -> ErasedRequest<'a, SendGame, Self::Err> {
Requester::send_game(self, chat_id, game_short_name).erase() Requester::send_game(self, chat_id, game_short_name).erase()

View file

@ -1383,8 +1383,9 @@ impl Requester for Bot {
type SendGame = JsonRequest<payloads::SendGame>; type SendGame = JsonRequest<payloads::SendGame>;
fn send_game<G>(&self, chat_id: u32, game_short_name: G) -> Self::SendGame fn send_game<C, G>(&self, chat_id: C, game_short_name: G) -> Self::SendGame
where where
C: Into<ChatId>,
G: Into<String>, G: Into<String>,
{ {
Self::SendGame::new(self.clone(), payloads::SendGame::new(chat_id, game_short_name)) Self::SendGame::new(self.clone(), payloads::SendGame::new(chat_id, game_short_name))

View file

@ -1406,9 +1406,10 @@ macro_rules! requester_forward {
(@method send_game $body:ident $ty:ident) => { (@method send_game $body:ident $ty:ident) => {
type SendGame = $ty![SendGame]; type SendGame = $ty![SendGame];
fn send_game<G>(&self, chat_id: u32, game_short_name: G) -> Self::SendGame where G: Into<String> { fn send_game<C, G>(&self, chat_id: C, game_short_name: G) -> Self::SendGame where C: Into<ChatId>,
G: Into<String> {
let this = self; let this = self;
$body!(send_game this (chat_id: u32, game_short_name: G)) $body!(send_game this (chat_id: C, game_short_name: G))
} }
}; };
(@method set_game_score $body:ident $ty:ident) => { (@method set_game_score $body:ident $ty:ident) => {

View file

@ -2,7 +2,7 @@
use serde::Serialize; use serde::Serialize;
use crate::types::{Message, MessageId, ReplyMarkup, ThreadId}; use crate::types::{ChatId, Message, MessageId, ReplyMarkup, ThreadId};
impl_payload! { impl_payload! {
/// Use this method to send a game. On success, the sent [`Message`] is returned. /// Use this method to send a game. On success, the sent [`Message`] is returned.
@ -12,7 +12,7 @@ impl_payload! {
pub SendGame (SendGameSetters) => Message { pub SendGame (SendGameSetters) => Message {
required { required {
/// Unique identifier for the target chat /// Unique identifier for the target chat
pub chat_id: u32, pub chat_id: ChatId [into],
/// Short name of the game, serves as the unique identifier for the game. Set up your games via Botfather. /// Short name of the game, serves as the unique identifier for the game. Set up your games via Botfather.
pub game_short_name: String [into], pub game_short_name: String [into],
} }

View file

@ -1189,8 +1189,9 @@ pub trait Requester {
type SendGame: Request<Payload = SendGame, Err = Self::Err>; type SendGame: Request<Payload = SendGame, Err = Self::Err>;
/// For Telegram documentation see [`SendGame`]. /// For Telegram documentation see [`SendGame`].
fn send_game<G>(&self, chat_id: u32, game_short_name: G) -> Self::SendGame fn send_game<C, G>(&self, chat_id: C, game_short_name: G) -> Self::SendGame
where where
C: Into<ChatId>,
G: Into<String>; G: Into<String>;
type SetGameScore: Request<Payload = SetGameScore, Err = Self::Err>; type SetGameScore: Request<Payload = SetGameScore, Err = Self::Err>;