Merge pull request #854 from teloxide/oopsydaisy

Fix arguments and return types of live location methods
This commit is contained in:
Waffle Maybe 2023-05-23 21:02:54 +00:00 committed by GitHub
commit 11e208e8a2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 26 additions and 65 deletions

View file

@ -18,6 +18,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[pr851]: https://github.com/teloxide/teloxide/pull/851 [pr851]: https://github.com/teloxide/teloxide/pull/851
### Fixed
- Return types of `edit_message_live_location_inline`, `stop_message_live_location_inline`, and `set_game_score_inline`: `Message` => `True` ([#854][pr854])
- Remove `latitude` and `longitude` parameters from `stop_message_live_location` and `stop_message_live_location_inline` ([#854][pr854])
[pr854]: https://github.com/teloxide/teloxide/pull/854
### Changed ### Changed
- Types of `Option<bool>` fields of `KeyboardMarkup`, `KeyboardRemove` and `ForceReply` to `bool` ([#853][pr853]) - Types of `Option<bool>` fields of `KeyboardMarkup`, `KeyboardRemove` and `ForceReply` to `bool` ([#853][pr853])

View file

@ -1314,7 +1314,7 @@ Schema(
), ),
Method( Method(
names: ("editMessageLiveLocationInline", "EditMessageLiveLocationInline", "edit_message_live_location_inline"), names: ("editMessageLiveLocationInline", "EditMessageLiveLocationInline", "edit_message_live_location_inline"),
return_ty: RawTy("Message"), return_ty: True,
doc: Doc( 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: "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"}, md_links: {"stopMessageLiveLocation": "https://core.telegram.org/bots/api#stopmessagelivelocation"},
@ -1389,16 +1389,6 @@ Schema(
ty: RawTy("MessageId"), ty: RawTy("MessageId"),
descr: Doc(md: "Identifier of the message to edit") 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( Param(
name: "reply_markup", name: "reply_markup",
ty: Option(RawTy("ReplyMarkup")), ty: Option(RawTy("ReplyMarkup")),
@ -1415,7 +1405,7 @@ Schema(
), ),
Method( Method(
names: ("stopMessageLiveLocationInline", "StopMessageLiveLocationInline", "stop_message_live_location_inline"), names: ("stopMessageLiveLocationInline", "StopMessageLiveLocationInline", "stop_message_live_location_inline"),
return_ty: RawTy("Message"), return_ty: True,
doc: Doc( 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: "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"}, md_links: {"stopMessageLiveLocation": "https://core.telegram.org/bots/api#stopmessagelivelocation"},
@ -1428,16 +1418,6 @@ Schema(
ty: String, ty: String,
descr: Doc(md: "Identifier of the inline message"), 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( Param(
name: "reply_markup", name: "reply_markup",
ty: Option(RawTy("ReplyMarkup")), ty: Option(RawTy("ReplyMarkup")),
@ -4132,7 +4112,7 @@ Schema(
), ),
Method( Method(
names: ("setGameScoreInline", "SetGameScoreInline", "set_game_score_inline"), names: ("setGameScoreInline", "SetGameScoreInline", "set_game_score_inline"),
return_ty: RawTy("Message"), return_ty: True,
doc: Doc(md: "Use this method to set the score of the specified user in a game. On success, 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."), doc: Doc(md: "Use this method to set the score of the specified user in a game. On success, 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."),
tg_doc: "https://core.telegram.org/bots/api#setgamescore", tg_doc: "https://core.telegram.org/bots/api#setgamescore",
tg_category: "Games", tg_category: "Games",

View file

@ -402,15 +402,11 @@ trait ErasableRequester<'a> {
&self, &self,
chat_id: Recipient, chat_id: Recipient,
message_id: MessageId, message_id: MessageId,
latitude: f64,
longitude: f64,
) -> ErasedRequest<'a, StopMessageLiveLocation, Self::Err>; ) -> ErasedRequest<'a, StopMessageLiveLocation, Self::Err>;
fn stop_message_live_location_inline( fn stop_message_live_location_inline(
&self, &self,
inline_message_id: String, inline_message_id: String,
latitude: f64,
longitude: f64,
) -> ErasedRequest<'a, StopMessageLiveLocationInline, Self::Err>; ) -> ErasedRequest<'a, StopMessageLiveLocationInline, Self::Err>;
fn send_venue( fn send_venue(
@ -1064,21 +1060,15 @@ where
&self, &self,
chat_id: Recipient, chat_id: Recipient,
message_id: MessageId, message_id: MessageId,
latitude: f64,
longitude: f64,
) -> ErasedRequest<'a, StopMessageLiveLocation, Self::Err> { ) -> ErasedRequest<'a, StopMessageLiveLocation, Self::Err> {
Requester::stop_message_live_location(self, chat_id, message_id, latitude, longitude) Requester::stop_message_live_location(self, chat_id, message_id).erase()
.erase()
} }
fn stop_message_live_location_inline( fn stop_message_live_location_inline(
&self, &self,
inline_message_id: String, inline_message_id: String,
latitude: f64,
longitude: f64,
) -> ErasedRequest<'a, StopMessageLiveLocationInline, Self::Err> { ) -> ErasedRequest<'a, StopMessageLiveLocationInline, Self::Err> {
Requester::stop_message_live_location_inline(self, inline_message_id, latitude, longitude) Requester::stop_message_live_location_inline(self, inline_message_id).erase()
.erase()
} }
fn send_venue( fn send_venue(

View file

@ -198,15 +198,13 @@ impl Requester for Bot {
&self, &self,
chat_id: C, chat_id: C,
message_id: MessageId, message_id: MessageId,
latitude: f64,
longitude: f64,
) -> Self::StopMessageLiveLocation ) -> Self::StopMessageLiveLocation
where where
C: Into<Recipient>, C: Into<Recipient>,
{ {
Self::StopMessageLiveLocation::new( Self::StopMessageLiveLocation::new(
self.clone(), 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<I>( fn stop_message_live_location_inline<I>(
&self, &self,
inline_message_id: I, inline_message_id: I,
latitude: f64,
longitude: f64,
) -> Self::StopMessageLiveLocationInline ) -> Self::StopMessageLiveLocationInline
where where
I: Into<String>, I: Into<String>,
{ {
Self::StopMessageLiveLocationInline::new( Self::StopMessageLiveLocationInline::new(
self.clone(), self.clone(),
payloads::StopMessageLiveLocationInline::new(inline_message_id, latitude, longitude), payloads::StopMessageLiveLocationInline::new(inline_message_id),
) )
} }

View file

@ -588,17 +588,17 @@ macro_rules! requester_forward {
(@method stop_message_live_location $body:ident $ty:ident) => { (@method stop_message_live_location $body:ident $ty:ident) => {
type StopMessageLiveLocation = $ty![StopMessageLiveLocation]; type StopMessageLiveLocation = $ty![StopMessageLiveLocation];
fn stop_message_live_location<C>(&self, chat_id: C, message_id: MessageId, latitude: f64, longitude: f64) -> Self::StopMessageLiveLocation where C: Into<Recipient> { fn stop_message_live_location<C>(&self, chat_id: C, message_id: MessageId) -> Self::StopMessageLiveLocation where C: Into<Recipient> {
let this = self; 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) => { (@method stop_message_live_location_inline $body:ident $ty:ident) => {
type StopMessageLiveLocationInline = $ty![StopMessageLiveLocationInline]; type StopMessageLiveLocationInline = $ty![StopMessageLiveLocationInline];
fn stop_message_live_location_inline<I>(&self, inline_message_id: I, latitude: f64, longitude: f64) -> Self::StopMessageLiveLocationInline where I: Into<String> { fn stop_message_live_location_inline<I>(&self, inline_message_id: I) -> Self::StopMessageLiveLocationInline where I: Into<String> {
let this = self; 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) => { (@method send_venue $body:ident $ty:ident) => {

View file

@ -2,7 +2,7 @@
use serde::Serialize; use serde::Serialize;
use crate::types::{Message, ReplyMarkup}; use crate::types::{ReplyMarkup, True};
impl_payload! { 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. /// 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 /// [`StopMessageLiveLocation`]: crate::payloads::StopMessageLiveLocation
#[derive(Debug, PartialEq, Clone, Serialize)] #[derive(Debug, PartialEq, Clone, Serialize)]
pub EditMessageLiveLocationInline (EditMessageLiveLocationInlineSetters) => Message { pub EditMessageLiveLocationInline (EditMessageLiveLocationInlineSetters) => True {
required { required {
/// Identifier of the inline message /// Identifier of the inline message
pub inline_message_id: String [into], pub inline_message_id: String [into],

View file

@ -2,14 +2,14 @@
use serde::Serialize; use serde::Serialize;
use crate::types::{Message, UserId}; use crate::types::{True, UserId};
impl_payload! { impl_payload! {
/// Use this method to set the score of the specified user in a game. On success, 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. /// Use this method to set the score of the specified user in a game. On success, 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.
/// ///
/// See also: [`SetGameScore`](crate::payloads::SetGameScore) /// See also: [`SetGameScore`](crate::payloads::SetGameScore)
#[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize)] #[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize)]
pub SetGameScoreInline (SetGameScoreInlineSetters) => Message { pub SetGameScoreInline (SetGameScoreInlineSetters) => True {
required { required {
/// User identifier /// User identifier
pub user_id: UserId, pub user_id: UserId,

View file

@ -11,7 +11,7 @@ impl_payload! {
/// ///
/// [`Message`]: crate::types::Message /// [`Message`]: crate::types::Message
/// [`StopMessageLiveLocation`]: crate::payloads::StopMessageLiveLocation /// [`StopMessageLiveLocation`]: crate::payloads::StopMessageLiveLocation
#[derive(Debug, PartialEq, Clone, Serialize)] #[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize)]
pub StopMessageLiveLocation (StopMessageLiveLocationSetters) => Message { pub StopMessageLiveLocation (StopMessageLiveLocationSetters) => Message {
required { required {
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) /// 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 /// Identifier of the message to edit
#[serde(flatten)] #[serde(flatten)]
pub message_id: MessageId, pub message_id: MessageId,
/// Latitude of new location
pub latitude: f64,
/// Longitude of new location
pub longitude: f64,
} }
optional { 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. /// 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.

View file

@ -2,7 +2,7 @@
use serde::Serialize; use serde::Serialize;
use crate::types::{Message, ReplyMarkup}; use crate::types::{ReplyMarkup, True};
impl_payload! { 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. /// 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) /// See also: [`StopMessageLiveLocation`](crate::payloads::StopMessageLiveLocation)
/// ///
/// [`StopMessageLiveLocation`]: crate::payloads::StopMessageLiveLocation /// [`StopMessageLiveLocation`]: crate::payloads::StopMessageLiveLocation
#[derive(Debug, PartialEq, Clone, Serialize)] #[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize)]
pub StopMessageLiveLocationInline (StopMessageLiveLocationInlineSetters) => Message { pub StopMessageLiveLocationInline (StopMessageLiveLocationInlineSetters) => True {
required { required {
/// Identifier of the inline message /// Identifier of the inline message
pub inline_message_id: String [into], pub inline_message_id: String [into],
/// Latitude of new location
pub latitude: f64,
/// Longitude of new location
pub longitude: f64,
} }
optional { 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. /// 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.

View file

@ -319,8 +319,6 @@ pub trait Requester {
&self, &self,
chat_id: C, chat_id: C,
message_id: MessageId, message_id: MessageId,
latitude: f64,
longitude: f64,
) -> Self::StopMessageLiveLocation ) -> Self::StopMessageLiveLocation
where where
C: Into<Recipient>; C: Into<Recipient>;
@ -334,8 +332,6 @@ pub trait Requester {
fn stop_message_live_location_inline<I>( fn stop_message_live_location_inline<I>(
&self, &self,
inline_message_id: I, inline_message_id: I,
latitude: f64,
longitude: f64,
) -> Self::StopMessageLiveLocationInline ) -> Self::StopMessageLiveLocationInline
where where
I: Into<String>; I: Into<String>;