From 33989c7f63d3c3ef05c8f5f6d71f2e6077dc9ab1 Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Tue, 14 Feb 2023 14:47:06 +0400 Subject: [PATCH] Fix arguments and return types of live location methods --- crates/teloxide-core/schema.ron | 24 ++----------------- crates/teloxide-core/src/adaptors/erased.rs | 14 ++--------- crates/teloxide-core/src/bot/api.rs | 8 ++----- crates/teloxide-core/src/local_macros.rs | 8 +++---- .../edit_message_live_location_inline.rs | 4 ++-- .../payloads/stop_message_live_location.rs | 6 +---- .../stop_message_live_location_inline.rs | 10 +++----- .../teloxide-core/src/requests/requester.rs | 4 ---- 8 files changed, 16 insertions(+), 62 deletions(-) diff --git a/crates/teloxide-core/schema.ron b/crates/teloxide-core/schema.ron index 8d209588..7cd6bc18 100644 --- a/crates/teloxide-core/schema.ron +++ b/crates/teloxide-core/schema.ron @@ -1314,7 +1314,7 @@ Schema( ), Method( names: ("editMessageLiveLocationInline", "EditMessageLiveLocationInline", "edit_message_live_location_inline"), - return_ty: RawTy("Message"), + return_ty: True, doc: Doc( md: "Use this method to edit live location messages. A location can be edited until its live_period expires or editing is explicitly disabled by a call to [stopMessageLiveLocation]. On success, True is returned.", md_links: {"stopMessageLiveLocation": "https://core.telegram.org/bots/api#stopmessagelivelocation"}, @@ -1389,16 +1389,6 @@ Schema( ty: RawTy("MessageId"), descr: Doc(md: "Identifier of the message to edit") ), - Param( - name: "latitude", - ty: f64, - descr: Doc(md: "Latitude of new location"), - ), - Param( - name: "longitude", - ty: f64, - descr: Doc(md: "Longitude of new location"), - ), Param( name: "reply_markup", ty: Option(RawTy("ReplyMarkup")), @@ -1415,7 +1405,7 @@ Schema( ), Method( names: ("stopMessageLiveLocationInline", "StopMessageLiveLocationInline", "stop_message_live_location_inline"), - return_ty: RawTy("Message"), + return_ty: True, doc: Doc( md: "Use this method to edit live location messages. A location can be edited until its live_period expires or editing is explicitly disabled by a call to [stopMessageLiveLocation]. On success, True is returned.", md_links: {"stopMessageLiveLocation": "https://core.telegram.org/bots/api#stopmessagelivelocation"}, @@ -1428,16 +1418,6 @@ Schema( ty: String, descr: Doc(md: "Identifier of the inline message"), ), - Param( - name: "latitude", - ty: f64, - descr: Doc(md: "Latitude of new location"), - ), - Param( - name: "longitude", - ty: f64, - descr: Doc(md: "Longitude of new location"), - ), Param( name: "reply_markup", ty: Option(RawTy("ReplyMarkup")), diff --git a/crates/teloxide-core/src/adaptors/erased.rs b/crates/teloxide-core/src/adaptors/erased.rs index 4d06a22e..05cb03cf 100644 --- a/crates/teloxide-core/src/adaptors/erased.rs +++ b/crates/teloxide-core/src/adaptors/erased.rs @@ -402,15 +402,11 @@ trait ErasableRequester<'a> { &self, chat_id: Recipient, message_id: MessageId, - latitude: f64, - longitude: f64, ) -> ErasedRequest<'a, StopMessageLiveLocation, Self::Err>; fn stop_message_live_location_inline( &self, inline_message_id: String, - latitude: f64, - longitude: f64, ) -> ErasedRequest<'a, StopMessageLiveLocationInline, Self::Err>; fn send_venue( @@ -1064,21 +1060,15 @@ where &self, chat_id: Recipient, message_id: MessageId, - latitude: f64, - longitude: f64, ) -> ErasedRequest<'a, StopMessageLiveLocation, Self::Err> { - Requester::stop_message_live_location(self, chat_id, message_id, latitude, longitude) - .erase() + Requester::stop_message_live_location(self, chat_id, message_id).erase() } fn stop_message_live_location_inline( &self, inline_message_id: String, - latitude: f64, - longitude: f64, ) -> ErasedRequest<'a, StopMessageLiveLocationInline, Self::Err> { - Requester::stop_message_live_location_inline(self, inline_message_id, latitude, longitude) - .erase() + Requester::stop_message_live_location_inline(self, inline_message_id).erase() } fn send_venue( diff --git a/crates/teloxide-core/src/bot/api.rs b/crates/teloxide-core/src/bot/api.rs index 7f1b4d32..2fbedee0 100644 --- a/crates/teloxide-core/src/bot/api.rs +++ b/crates/teloxide-core/src/bot/api.rs @@ -198,15 +198,13 @@ impl Requester for Bot { &self, chat_id: C, message_id: MessageId, - latitude: f64, - longitude: f64, ) -> Self::StopMessageLiveLocation where C: Into, { Self::StopMessageLiveLocation::new( self.clone(), - payloads::StopMessageLiveLocation::new(chat_id, message_id, latitude, longitude), + payloads::StopMessageLiveLocation::new(chat_id, message_id), ) } @@ -215,15 +213,13 @@ impl Requester for Bot { fn stop_message_live_location_inline( &self, inline_message_id: I, - latitude: f64, - longitude: f64, ) -> Self::StopMessageLiveLocationInline where I: Into, { Self::StopMessageLiveLocationInline::new( self.clone(), - payloads::StopMessageLiveLocationInline::new(inline_message_id, latitude, longitude), + payloads::StopMessageLiveLocationInline::new(inline_message_id), ) } diff --git a/crates/teloxide-core/src/local_macros.rs b/crates/teloxide-core/src/local_macros.rs index 95b31eb0..c0c6e51c 100644 --- a/crates/teloxide-core/src/local_macros.rs +++ b/crates/teloxide-core/src/local_macros.rs @@ -588,17 +588,17 @@ macro_rules! requester_forward { (@method stop_message_live_location $body:ident $ty:ident) => { type StopMessageLiveLocation = $ty![StopMessageLiveLocation]; - fn stop_message_live_location(&self, chat_id: C, message_id: MessageId, latitude: f64, longitude: f64) -> Self::StopMessageLiveLocation where C: Into { + fn stop_message_live_location(&self, chat_id: C, message_id: MessageId) -> Self::StopMessageLiveLocation where C: Into { let this = self; - $body!(stop_message_live_location this (chat_id: C, message_id: MessageId, latitude: f64, longitude: f64)) + $body!(stop_message_live_location this (chat_id: C, message_id: MessageId)) } }; (@method stop_message_live_location_inline $body:ident $ty:ident) => { type StopMessageLiveLocationInline = $ty![StopMessageLiveLocationInline]; - fn stop_message_live_location_inline(&self, inline_message_id: I, latitude: f64, longitude: f64) -> Self::StopMessageLiveLocationInline where I: Into { + fn stop_message_live_location_inline(&self, inline_message_id: I) -> Self::StopMessageLiveLocationInline where I: Into { let this = self; - $body!(stop_message_live_location_inline this (inline_message_id: I, latitude: f64, longitude: f64)) + $body!(stop_message_live_location_inline this (inline_message_id: I)) } }; (@method send_venue $body:ident $ty:ident) => { diff --git a/crates/teloxide-core/src/payloads/edit_message_live_location_inline.rs b/crates/teloxide-core/src/payloads/edit_message_live_location_inline.rs index 83883889..e0f6e5e4 100644 --- a/crates/teloxide-core/src/payloads/edit_message_live_location_inline.rs +++ b/crates/teloxide-core/src/payloads/edit_message_live_location_inline.rs @@ -2,7 +2,7 @@ use serde::Serialize; -use crate::types::{Message, ReplyMarkup}; +use crate::types::{ReplyMarkup, True}; impl_payload! { /// Use this method to edit live location messages. A location can be edited until its live_period expires or editing is explicitly disabled by a call to [`StopMessageLiveLocation`]. On success, True is returned. @@ -11,7 +11,7 @@ impl_payload! { /// /// [`StopMessageLiveLocation`]: crate::payloads::StopMessageLiveLocation #[derive(Debug, PartialEq, Clone, Serialize)] - pub EditMessageLiveLocationInline (EditMessageLiveLocationInlineSetters) => Message { + pub EditMessageLiveLocationInline (EditMessageLiveLocationInlineSetters) => True { required { /// Identifier of the inline message pub inline_message_id: String [into], diff --git a/crates/teloxide-core/src/payloads/stop_message_live_location.rs b/crates/teloxide-core/src/payloads/stop_message_live_location.rs index 970fc87c..7e2a312c 100644 --- a/crates/teloxide-core/src/payloads/stop_message_live_location.rs +++ b/crates/teloxide-core/src/payloads/stop_message_live_location.rs @@ -11,7 +11,7 @@ impl_payload! { /// /// [`Message`]: crate::types::Message /// [`StopMessageLiveLocation`]: crate::payloads::StopMessageLiveLocation - #[derive(Debug, PartialEq, Clone, Serialize)] + #[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize)] pub StopMessageLiveLocation (StopMessageLiveLocationSetters) => Message { required { /// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) @@ -19,10 +19,6 @@ impl_payload! { /// Identifier of the message to edit #[serde(flatten)] pub message_id: MessageId, - /// Latitude of new location - pub latitude: f64, - /// Longitude of new location - pub longitude: f64, } optional { /// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user. diff --git a/crates/teloxide-core/src/payloads/stop_message_live_location_inline.rs b/crates/teloxide-core/src/payloads/stop_message_live_location_inline.rs index 2191c774..fdc7543c 100644 --- a/crates/teloxide-core/src/payloads/stop_message_live_location_inline.rs +++ b/crates/teloxide-core/src/payloads/stop_message_live_location_inline.rs @@ -2,7 +2,7 @@ use serde::Serialize; -use crate::types::{Message, ReplyMarkup}; +use crate::types::{ReplyMarkup, True}; impl_payload! { /// Use this method to edit live location messages. A location can be edited until its live_period expires or editing is explicitly disabled by a call to [`StopMessageLiveLocation`]. On success, True is returned. @@ -10,15 +10,11 @@ impl_payload! { /// See also: [`StopMessageLiveLocation`](crate::payloads::StopMessageLiveLocation) /// /// [`StopMessageLiveLocation`]: crate::payloads::StopMessageLiveLocation - #[derive(Debug, PartialEq, Clone, Serialize)] - pub StopMessageLiveLocationInline (StopMessageLiveLocationInlineSetters) => Message { + #[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize)] + pub StopMessageLiveLocationInline (StopMessageLiveLocationInlineSetters) => True { required { /// Identifier of the inline message pub inline_message_id: String [into], - /// Latitude of new location - pub latitude: f64, - /// Longitude of new location - pub longitude: f64, } optional { /// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user. diff --git a/crates/teloxide-core/src/requests/requester.rs b/crates/teloxide-core/src/requests/requester.rs index 5c0c64d5..87b9baf1 100644 --- a/crates/teloxide-core/src/requests/requester.rs +++ b/crates/teloxide-core/src/requests/requester.rs @@ -319,8 +319,6 @@ pub trait Requester { &self, chat_id: C, message_id: MessageId, - latitude: f64, - longitude: f64, ) -> Self::StopMessageLiveLocation where C: Into; @@ -334,8 +332,6 @@ pub trait Requester { fn stop_message_live_location_inline( &self, inline_message_id: I, - latitude: f64, - longitude: f64, ) -> Self::StopMessageLiveLocationInline where I: Into;