Trying to use not-lambda function with repl results in runtime rror #734
-
I'm trying to replicate ngrok ping pong bot: teloxide::repl_with_listener(
bot,
|msg: Message, bot: AutoSend<Bot>| async move {
bot.send_message(msg.chat.id, "pong").await?;
respond(())
},
listener,
) but using function instead of a lambda. Here's the function signature: and here's how I use repl: teloxide::repl_with_listener(
bot,
handle_message,
listener
) This compiles but gives runtime error:
What am I doing wrong? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
Does your example work with the lambda function? |
Beta Was this translation helpful? Give feedback.
-
I think the problem isn't the lambda/function, but instead it's that the bot types that you are giving to the repl and then requesting from it don't match:
You either need to make let bot = bot.auto_send(); |
Beta Was this translation helpful? Give feedback.
I think the problem isn't the lambda/function, but instead it's that the bot types that you are giving to the repl and then requesting from it don't match:
You either need to make
bot: Bot
argument or use the auto send adapter: