Skip to content

Commit

Permalink
Rename Add States
Browse files Browse the repository at this point in the history
This is a hack until I figure out how to namespace them
  • Loading branch information
will-lynas committed Oct 15, 2024
1 parent f9695dd commit ae94015
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ enum Command {
#[derive(Clone, Default)]
pub enum State {
#[default]
Start,
ReceiveAmount,
ReceiveTitle {
AddStart,
AddReceiveAmount,
AddReciveTitle {
amount: f64,
},
}
Expand Down Expand Up @@ -91,7 +91,7 @@ async fn main() {

fn schema() -> UpdateHandler<Box<dyn std::error::Error + Send + Sync + 'static>> {
let command_handler = teloxide::filter_command::<Command, _>().branch(
case![State::Start]
case![State::AddStart]
.branch(case![Command::Help].endpoint(help))
.branch(case![Command::Display].endpoint(display))
.branch(case![Command::Reset].endpoint(reset))
Expand All @@ -100,8 +100,8 @@ fn schema() -> UpdateHandler<Box<dyn std::error::Error + Send + Sync + 'static>>

let message_handler = Update::filter_message()
.branch(command_handler)
.branch(case![State::ReceiveAmount].endpoint(receive_amount))
.branch(case![State::ReceiveTitle { amount }].endpoint(receive_title));
.branch(case![State::AddReceiveAmount].endpoint(receive_amount))
.branch(case![State::AddReciveTitle { amount }].endpoint(receive_title));

let update_user_handler =
Update::filter_message().map_async(|msg: Message, pool: SqlitePool| async move {
Expand Down Expand Up @@ -176,7 +176,7 @@ async fn reset(bot: Bot, msg: Message, pool: SqlitePool) -> HandlerResult {

async fn start_add_dialogue(bot: Bot, dialogue: MyDialogue, msg: Message) -> HandlerResult {
bot.send_message(msg.chat.id, "Enter amount:").await?;
dialogue.update(State::ReceiveAmount).await.unwrap();
dialogue.update(State::AddReceiveAmount).await.unwrap();
Ok(())
}

Expand All @@ -185,7 +185,7 @@ async fn receive_amount(bot: Bot, dialogue: MyDialogue, msg: Message) -> Handler
Some(Ok(amount)) => {
bot.send_message(msg.chat.id, "Enter title:").await?;
dialogue
.update(State::ReceiveTitle { amount })
.update(State::AddReciveTitle { amount })
.await
.unwrap();
}
Expand Down

0 comments on commit ae94015

Please sign in to comment.