mirror of
https://github.com/teloxide/teloxide.git
synced 2025-01-09 11:43:57 +01:00
Sticker related fixes
- Rename `sticker_type.rs` => `input_sticker.rs` (after the contained type) - Make `create_new_sticker_set` multipart - Replace CreateNewStickerSet::{png,tgs}_sticker with `<_>::sticker` - Fix GetStickerSet return type - Revert some previous InputSticker changes: make the variants tuple structsm remove constructors
This commit is contained in:
parent
53f1c6d4d3
commit
5b328105fa
7 changed files with 20 additions and 38 deletions
|
@ -765,13 +765,14 @@ impl Requester for Bot {
|
|||
)
|
||||
}
|
||||
|
||||
type CreateNewStickerSet = JsonRequest<payloads::CreateNewStickerSet>;
|
||||
type CreateNewStickerSet = MultipartRequest<payloads::CreateNewStickerSet>;
|
||||
|
||||
fn create_new_sticker_set<N, T, E>(
|
||||
&self,
|
||||
user_id: i32,
|
||||
name: N,
|
||||
title: T,
|
||||
sticker: InputSticker,
|
||||
emojis: E,
|
||||
) -> Self::CreateNewStickerSet
|
||||
where
|
||||
|
@ -781,7 +782,7 @@ impl Requester for Bot {
|
|||
{
|
||||
Self::CreateNewStickerSet::new(
|
||||
self.clone(),
|
||||
payloads::CreateNewStickerSet::new(user_id, name, title, emojis),
|
||||
payloads::CreateNewStickerSet::new(user_id, name, title, sticker, emojis),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -924,11 +924,11 @@ macro_rules! requester_forward {
|
|||
(@method create_new_sticker_set $body:ident $ty:ident) => {
|
||||
type CreateNewStickerSet = $ty![CreateNewStickerSet];
|
||||
|
||||
fn create_new_sticker_set<N, T, E>(&self, user_id: i32, name: N, title: T, emojis: E) -> Self::CreateNewStickerSet where N: Into<String>,
|
||||
fn create_new_sticker_set<N, T, E>(&self, user_id: i32, name: N, title: T, sticker: InputSticker, emojis: E) -> Self::CreateNewStickerSet where N: Into<String>,
|
||||
T: Into<String>,
|
||||
E: Into<String> {
|
||||
let this = self;
|
||||
$body!(create_new_sticker_set this (user_id: i32, name: N, title: T, emojis: E))
|
||||
$body!(create_new_sticker_set this (user_id: i32, name: N, title: T, sticker: InputSticker, emojis: E))
|
||||
}
|
||||
};
|
||||
(@method add_sticker_to_set $body:ident $ty:ident) => {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
// edit `cg` instead.
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{InputFile, MaskPosition, True};
|
||||
use crate::types::{InputSticker, MaskPosition, True};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to create a new sticker set owned by a user. The bot will be able to edit the sticker set thus created. You must use exactly one of the fields _png\_sticker_ or _tgs\_sticker_. Returns _True_ on success.
|
||||
|
@ -16,16 +16,15 @@ impl_payload! {
|
|||
pub name: String [into],
|
||||
/// Sticker set title, 1-64 characters
|
||||
pub title: String [into],
|
||||
/// **PNG** or **TGS** image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. Pass a _file\_id_ as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. [More info on Sending Files »]
|
||||
///
|
||||
/// [More info on Sending Files »]: crate::types::InputFile
|
||||
#[serde(flatten)]
|
||||
pub sticker: InputSticker,
|
||||
/// One or more emoji corresponding to the sticker
|
||||
pub emojis: String [into],
|
||||
}
|
||||
optional {
|
||||
/// **PNG** image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. Pass a _file\_id_ as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. [More info on Sending Files »]
|
||||
///
|
||||
/// [More info on Sending Files »]: crate::types::InputFile
|
||||
pub png_sticker: InputFile,
|
||||
/// **TGS** animation with the sticker, uploaded using multipart/form-data. See https://core.telegram.org/animated_stickers#technical-requirements for technical requirements
|
||||
pub tgs_sticker: InputFile,
|
||||
/// Pass _True_, if a set of mask stickers should be created
|
||||
pub contains_masks: bool,
|
||||
/// A JSON-serialized object for position where the mask should be placed on faces
|
||||
|
|
|
@ -3,12 +3,12 @@
|
|||
// edit `cg` instead.
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::True;
|
||||
use crate::types::StickerSet;
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to get a sticker set. On success, a StickerSet object is returned.
|
||||
#[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize)]
|
||||
pub GetStickerSet (GetStickerSetSetters) => True {
|
||||
pub GetStickerSet (GetStickerSetSetters) => StickerSet {
|
||||
required {
|
||||
/// Name of the sticker set
|
||||
pub name: String [into],
|
||||
|
|
|
@ -617,6 +617,7 @@ pub trait Requester {
|
|||
user_id: i32,
|
||||
name: N,
|
||||
title: T,
|
||||
sticker: InputSticker,
|
||||
emojis: E,
|
||||
) -> Self::CreateNewStickerSet
|
||||
where
|
||||
|
|
|
@ -50,6 +50,7 @@ pub use inline_query_result_voice::*;
|
|||
pub use input_file::*;
|
||||
pub use input_media::*;
|
||||
pub use input_message_content::*;
|
||||
pub use input_sticker::*;
|
||||
pub use invoice::*;
|
||||
pub use keyboard_button::*;
|
||||
pub use keyboard_button_poll_type::*;
|
||||
|
@ -80,7 +81,6 @@ pub use shipping_option::*;
|
|||
pub use shipping_query::*;
|
||||
pub use sticker::*;
|
||||
pub use sticker_set::*;
|
||||
pub use sticker_type::*;
|
||||
pub use successful_payment::*;
|
||||
pub use target_message::*;
|
||||
pub use unit_false::*;
|
||||
|
@ -120,6 +120,7 @@ mod inline_keyboard_markup;
|
|||
mod input_file;
|
||||
mod input_media;
|
||||
mod input_message_content;
|
||||
mod input_sticker;
|
||||
mod invoice;
|
||||
mod keyboard_button;
|
||||
mod keyboard_button_poll_type;
|
||||
|
@ -147,7 +148,6 @@ mod shipping_option;
|
|||
mod shipping_query;
|
||||
mod sticker;
|
||||
mod sticker_set;
|
||||
mod sticker_type;
|
||||
mod successful_payment;
|
||||
mod target_message;
|
||||
mod unit_false;
|
||||
|
|
|
@ -4,7 +4,6 @@ use crate::types::InputFile;
|
|||
|
||||
/// Sticker file that may be uploaded to telegram.
|
||||
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum InputSticker {
|
||||
/// PNG image with the sticker, must be up to 512 kilobytes in size,
|
||||
/// dimensions must not exceed 512px, and either width or height must be
|
||||
|
@ -20,30 +19,12 @@ pub enum InputSticker {
|
|||
/// [`InputFile::FileId`]: crate::types::InputFile::FileId
|
||||
///
|
||||
/// [More info on Sending Files »]: https://core.telegram.org/bots/api#sending-files
|
||||
Png { png_sticker: InputFile },
|
||||
#[serde(rename = "png_sticker")]
|
||||
Png(InputFile),
|
||||
|
||||
/// TGS animation with the sticker, uploaded using multipart/form-data.
|
||||
///
|
||||
/// See https://core.telegram.org/animated_stickers#technical-requirements for technical requirements
|
||||
Tgs { tgs_sticker: InputFile },
|
||||
}
|
||||
|
||||
impl InputSticker {
|
||||
/// Create png-`InputSticker`.
|
||||
///
|
||||
/// See [`InputSticker::Png`] for more
|
||||
///
|
||||
/// [`InputSticker::Png`]: crate::types::InputSticker::Png
|
||||
pub fn png(png_sticker: InputFile) -> Self {
|
||||
Self::Png { png_sticker }
|
||||
}
|
||||
|
||||
/// Create tgs-`InputSticker`.
|
||||
///
|
||||
/// See [`InputSticker::Tgs`] for more
|
||||
///
|
||||
/// [`InputSticker::Tgs`]: crate::types::InputSticker::Tgs
|
||||
pub fn tgs(tgs_sticker: InputFile) -> Self {
|
||||
Self::Tgs { tgs_sticker }
|
||||
}
|
||||
#[serde(rename = "tgs_sticker")]
|
||||
Tgs(InputFile),
|
||||
}
|
Loading…
Reference in a new issue