mirror of
https://github.com/teloxide/teloxide.git
synced 2025-03-20 13:59:00 +01:00
Fix this fucking bullshit
This commit is contained in:
parent
8826263e58
commit
239ff94c0e
3 changed files with 19 additions and 19 deletions
22
README.md
22
README.md
|
@ -102,11 +102,11 @@ async fn main() {
|
||||||
teloxide::enable_logging!();
|
teloxide::enable_logging!();
|
||||||
log::info!("Starting dices_bot...");
|
log::info!("Starting dices_bot...");
|
||||||
|
|
||||||
let bot = Bot::from_env();
|
let bot = Bot::from_env().auto_send();
|
||||||
|
|
||||||
teloxide::repl(bot, |message| async move {
|
teloxide::repl(bot, |message| async move {
|
||||||
message.answer_dice().send().await?;
|
message.answer_dice().await?;
|
||||||
ResponseResult::<()>::Ok(())
|
respond(())
|
||||||
})
|
})
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
@ -143,7 +143,7 @@ enum Command {
|
||||||
UsernameAndAge { username: String, age: u8 },
|
UsernameAndAge { username: String, age: u8 },
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn answer(cx: UpdateWithCx<Message>, command: Command) -> ResponseResult<()> {
|
async fn answer(cx: UpdateWithCx<AutoSend<Bot>, Message>, command: Command) -> ResponseResult<()> {
|
||||||
match command {
|
match command {
|
||||||
Command::Help => cx.answer(Command::descriptions()).send().await?,
|
Command::Help => cx.answer(Command::descriptions()).send().await?,
|
||||||
Command::Username(username) => {
|
Command::Username(username) => {
|
||||||
|
@ -162,7 +162,7 @@ async fn main() {
|
||||||
teloxide::enable_logging!();
|
teloxide::enable_logging!();
|
||||||
log::info!("Starting simple_commands_bot...");
|
log::info!("Starting simple_commands_bot...");
|
||||||
|
|
||||||
let bot = Bot::from_env();
|
let bot = Bot::from_env().auto_send();
|
||||||
|
|
||||||
let bot_name: String = panic!("Your bot's name here");
|
let bot_name: String = panic!("Your bot's name here");
|
||||||
teloxide::commands_repl(bot, bot_name, answer).await;
|
teloxide::commands_repl(bot, bot_name, answer).await;
|
||||||
|
@ -213,7 +213,7 @@ When a user sends a message to our bot and such a dialogue does not exist yet, a
|
||||||
pub struct StartState;
|
pub struct StartState;
|
||||||
|
|
||||||
#[teloxide(subtransition)]
|
#[teloxide(subtransition)]
|
||||||
async fn start(_state: StartState, cx: TransitionIn, _ans: String) -> TransitionOut<Dialogue> {
|
async fn start(_state: StartState, cx: TransitionIn<AutoSend<Bot>>, _ans: String) -> TransitionOut<Dialogue> {
|
||||||
cx.answer_str("Let's start! What's your full name?").await?;
|
cx.answer_str("Let's start! What's your full name?").await?;
|
||||||
next(ReceiveFullNameState)
|
next(ReceiveFullNameState)
|
||||||
}
|
}
|
||||||
|
@ -234,7 +234,7 @@ pub struct ReceiveFullNameState;
|
||||||
#[teloxide(subtransition)]
|
#[teloxide(subtransition)]
|
||||||
async fn receive_full_name(
|
async fn receive_full_name(
|
||||||
state: ReceiveFullNameState,
|
state: ReceiveFullNameState,
|
||||||
cx: TransitionIn,
|
cx: TransitionIn<AutoSend<Bot>>,
|
||||||
ans: String,
|
ans: String,
|
||||||
) -> TransitionOut<Dialogue> {
|
) -> TransitionOut<Dialogue> {
|
||||||
cx.answer_str("How old are you?").await?;
|
cx.answer_str("How old are you?").await?;
|
||||||
|
@ -259,7 +259,7 @@ pub struct ReceiveAgeState {
|
||||||
#[teloxide(subtransition)]
|
#[teloxide(subtransition)]
|
||||||
async fn receive_age_state(
|
async fn receive_age_state(
|
||||||
state: ReceiveAgeState,
|
state: ReceiveAgeState,
|
||||||
cx: TransitionIn,
|
cx: TransitionIn<AutoSend<Bot>>,
|
||||||
ans: String,
|
ans: String,
|
||||||
) -> TransitionOut<Dialogue> {
|
) -> TransitionOut<Dialogue> {
|
||||||
match ans.parse::<u8>() {
|
match ans.parse::<u8>() {
|
||||||
|
@ -293,7 +293,7 @@ pub struct ReceiveLocationState {
|
||||||
#[teloxide(subtransition)]
|
#[teloxide(subtransition)]
|
||||||
async fn receive_location(
|
async fn receive_location(
|
||||||
state: ReceiveLocationState,
|
state: ReceiveLocationState,
|
||||||
cx: TransitionIn,
|
cx: TransitionIn<AutoSend<Bot>>,
|
||||||
ans: String,
|
ans: String,
|
||||||
) -> TransitionOut<Dialogue> {
|
) -> TransitionOut<Dialogue> {
|
||||||
cx.answer_str(format!("Full name: {}\nAge: {}\nLocation: {}", state.full_name, state.age, ans))
|
cx.answer_str(format!("Full name: {}\nAge: {}\nLocation: {}", state.full_name, state.age, ans))
|
||||||
|
@ -317,7 +317,7 @@ async fn main() {
|
||||||
teloxide::enable_logging!();
|
teloxide::enable_logging!();
|
||||||
log::info!("Starting dialogue_bot...");
|
log::info!("Starting dialogue_bot...");
|
||||||
|
|
||||||
let bot = Bot::from_env();
|
let bot = Bot::from_env().auto_send();
|
||||||
|
|
||||||
teloxide::dialogues_repl(bot, |message, dialogue| async move {
|
teloxide::dialogues_repl(bot, |message, dialogue| async move {
|
||||||
handle_message(message, dialogue).await.expect("Something wrong with the bot!")
|
handle_message(message, dialogue).await.expect("Something wrong with the bot!")
|
||||||
|
@ -325,7 +325,7 @@ async fn main() {
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn handle_message(cx: UpdateWithCx<Message>, dialogue: Dialogue) -> TransitionOut<Dialogue> {
|
async fn handle_message(cx: UpdateWithCx<AudoSend<Bot>, Message>, dialogue: Dialogue) -> TransitionOut<Dialogue> {
|
||||||
match cx.update.text_owned() {
|
match cx.update.text_owned() {
|
||||||
None => {
|
None => {
|
||||||
cx.answer_str("Send me a text message.").await?;
|
cx.answer_str("Send me a text message.").await?;
|
||||||
|
|
|
@ -42,17 +42,17 @@
|
||||||
//! type Out = TransitionOut<D, RequestError>;
|
//! type Out = TransitionOut<D, RequestError>;
|
||||||
//!
|
//!
|
||||||
//! #[teloxide(subtransition)]
|
//! #[teloxide(subtransition)]
|
||||||
//! async fn _1_transition(_state: _1State, _cx: TransitionIn) -> Out {
|
//! async fn _1_transition(_state: _1State, _cx: TransitionIn<AutoSend<Bot>>) -> Out {
|
||||||
//! todo!()
|
//! todo!()
|
||||||
//! }
|
//! }
|
||||||
//!
|
//!
|
||||||
//! #[teloxide(subtransition)]
|
//! #[teloxide(subtransition)]
|
||||||
//! async fn _2_transition(_state: _2State, _cx: TransitionIn) -> Out {
|
//! async fn _2_transition(_state: _2State, _cx: TransitionIn<AutoSend<Bot>>) -> Out {
|
||||||
//! todo!()
|
//! todo!()
|
||||||
//! }
|
//! }
|
||||||
//!
|
//!
|
||||||
//! #[teloxide(subtransition)]
|
//! #[teloxide(subtransition)]
|
||||||
//! async fn _3_transition(_state: _3State, _cx: TransitionIn) -> Out {
|
//! async fn _3_transition(_state: _3State, _cx: TransitionIn<AutoSend<Bot>>) -> Out {
|
||||||
//! todo!()
|
//! todo!()
|
||||||
//! }
|
//! }
|
||||||
//!
|
//!
|
||||||
|
@ -69,7 +69,7 @@
|
||||||
//! }
|
//! }
|
||||||
//! }
|
//! }
|
||||||
//!
|
//!
|
||||||
//! type In = DialogueWithCx<Message, D, Infallible>;
|
//! type In = DialogueWithCx<AutoSend<Bot>, Message, D, Infallible>;
|
||||||
//!
|
//!
|
||||||
//! #[tokio::main]
|
//! #[tokio::main]
|
||||||
//! async fn main() {
|
//! async fn main() {
|
||||||
|
@ -80,7 +80,7 @@
|
||||||
//! teloxide::enable_logging!();
|
//! teloxide::enable_logging!();
|
||||||
//! log::info!("Starting dialogue_bot!");
|
//! log::info!("Starting dialogue_bot!");
|
||||||
//!
|
//!
|
||||||
//! let bot = Bot::from_env();
|
//! let bot = Bot::from_env().auto_send();
|
||||||
//!
|
//!
|
||||||
//! Dispatcher::new(bot)
|
//! Dispatcher::new(bot)
|
||||||
//! .messages_handler(DialogueDispatcher::new(
|
//! .messages_handler(DialogueDispatcher::new(
|
||||||
|
|
|
@ -13,11 +13,11 @@
|
||||||
//! teloxide::enable_logging!();
|
//! teloxide::enable_logging!();
|
||||||
//! log::info!("Starting dices_bot...");
|
//! log::info!("Starting dices_bot...");
|
||||||
//!
|
//!
|
||||||
//! let bot = Bot::from_env();
|
//! let bot = Bot::from_env().auto_send();
|
||||||
//!
|
//!
|
||||||
//! teloxide::repl(bot, |message| async move {
|
//! teloxide::repl(bot, |message| async move {
|
||||||
//! message.answer_dice().send().await?;
|
//! message.answer_dice().await?;
|
||||||
//! ResponseResult::<()>::Ok(())
|
//! respond(())
|
||||||
//! })
|
//! })
|
||||||
//! .await;
|
//! .await;
|
||||||
//! # }
|
//! # }
|
||||||
|
|
Loading…
Add table
Reference in a new issue