changed the way we set the markup in alter_message

This commit is contained in:
StNicolay 2023-08-07 01:21:15 +03:00
parent 3bc97d7bbc
commit 1cc486bdc5
Signed by: StNicolay
GPG Key ID: 9693D04DCD962B0D

View File

@ -32,11 +32,7 @@ impl MessageIds {
) -> crate::Result<()> {
let mut edit = bot.edit_message_text(self.0, self.1, text);
edit.parse_mode = parse_mode.into();
let mut markup = markup.into();
if let Some(markup) = markup {
edit = edit.reply_markup(markup)
}
edit.reply_markup = markup.into();
match edit.send_ref().await {
Ok(_) => return Ok(()),
@ -44,14 +40,10 @@ impl MessageIds {
Err(err) => return Err(err.into()),
};
let text = mem::take(&mut edit.text);
markup = mem::take(&mut edit.reply_markup);
let mut send = bot.send_message(self.0, text);
send.payload_mut().parse_mode = parse_mode.into();
if let Some(markup) = markup {
send = send.reply_markup(markup);
}
let mut send = bot.send_message(self.0, mem::take(&mut edit.text));
let payload = send.payload_mut();
payload.parse_mode = edit.parse_mode;
payload.reply_markup = mem::take(&mut edit.reply_markup).map(Into::into);
let msg = join!(self.delete(bot), send.send()).1?;
*self = Self::from(&msg);