From 703c65c0c28d1b314d5248c574fdb5e2c4757e6b Mon Sep 17 00:00:00 2001 From: strongtu Date: Fri, 17 May 2024 22:39:17 +0800 Subject: [PATCH] let send_message use ChatId --- crates/teloxide-core/schema.ron | 2 +- crates/teloxide-core/src/bot/api.rs | 2 +- crates/teloxide-core/src/local_macros.rs | 4 ++-- crates/teloxide-core/src/payloads/send_game.rs | 4 ++-- crates/teloxide-core/src/requests/requester.rs | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/teloxide-core/schema.ron b/crates/teloxide-core/schema.ron index 5bc31785..bbf01235 100644 --- a/crates/teloxide-core/schema.ron +++ b/crates/teloxide-core/schema.ron @@ -4031,7 +4031,7 @@ Schema( params: [ Param( name: "chat_id", - ty: i64, + ty: RawTy("ChatId"), descr: Doc(md: "Unique identifier for the target chat"), ), Param( diff --git a/crates/teloxide-core/src/bot/api.rs b/crates/teloxide-core/src/bot/api.rs index 3d1a31dd..15d607ff 100644 --- a/crates/teloxide-core/src/bot/api.rs +++ b/crates/teloxide-core/src/bot/api.rs @@ -1264,7 +1264,7 @@ impl Requester for Bot { type SendGame = JsonRequest; - fn send_game(&self, chat_id: i64, game_short_name: G) -> Self::SendGame + fn send_game(&self, chat_id: ChatId, game_short_name: G) -> Self::SendGame where G: Into, { diff --git a/crates/teloxide-core/src/local_macros.rs b/crates/teloxide-core/src/local_macros.rs index 34462105..fc2c9cc3 100644 --- a/crates/teloxide-core/src/local_macros.rs +++ b/crates/teloxide-core/src/local_macros.rs @@ -1301,9 +1301,9 @@ macro_rules! requester_forward { (@method send_game $body:ident $ty:ident) => { type SendGame = $ty![SendGame]; - fn send_game(&self, chat_id: i64, game_short_name: G) -> Self::SendGame where G: Into { + fn send_game(&self, chat_id: ChatId, game_short_name: G) -> Self::SendGame where G: Into { let this = self; - $body!(send_game this (chat_id: i64, game_short_name: G)) + $body!(send_game this (chat_id: ChatId, game_short_name: G)) } }; (@method set_game_score $body:ident $ty:ident) => { diff --git a/crates/teloxide-core/src/payloads/send_game.rs b/crates/teloxide-core/src/payloads/send_game.rs index 92b8d912..bb2b02c2 100644 --- a/crates/teloxide-core/src/payloads/send_game.rs +++ b/crates/teloxide-core/src/payloads/send_game.rs @@ -2,7 +2,7 @@ use serde::Serialize; -use crate::types::{Message, MessageId, ReplyMarkup, ThreadId}; +use crate::types::{ChatId, Message, MessageId, ReplyMarkup, ThreadId}; impl_payload! { /// Use this method to send a game. On success, the sent [`Message`] is returned. @@ -12,7 +12,7 @@ impl_payload! { pub SendGame (SendGameSetters) => Message { required { /// Unique identifier for the target chat - pub chat_id: i64, + pub chat_id: ChatId [into], /// 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], } diff --git a/crates/teloxide-core/src/requests/requester.rs b/crates/teloxide-core/src/requests/requester.rs index cd45e352..ba0e940d 100644 --- a/crates/teloxide-core/src/requests/requester.rs +++ b/crates/teloxide-core/src/requests/requester.rs @@ -1093,7 +1093,7 @@ pub trait Requester { type SendGame: Request; /// For Telegram documentation see [`SendGame`]. - fn send_game(&self, chat_id: i64, game_short_name: G) -> Self::SendGame + fn send_game(&self, chat_id: ChatId, game_short_name: G) -> Self::SendGame where G: Into;