Use struct for passing module arguments: telegram

This commit is contained in:
George Kaklamanos 2023-11-21 21:22:32 +02:00
parent f09de29ee4
commit ee3a9c41ba
Signed by: gkaklas
GPG key ID: C0CAB8A6BDC9399D
3 changed files with 24 additions and 4 deletions

View file

@ -1,5 +1,9 @@
use teloxide::{prelude::*, utils::command::BotCommands};
pub struct TelegramArgs {
pub token: String,
}
#[derive(BotCommands, Clone)]
#[command(
rename_rule = "lowercase",
@ -42,7 +46,7 @@ async fn answer(bot: Bot, message: Message, command: Command) -> ResponseResult<
}
#[tokio::main]
pub async fn telegram(token: String) {
let bot = Bot::new(token);
pub async fn telegram(args: TelegramArgs) {
let bot = Bot::new(args.token);
Command::repl(bot, answer).await;
}