telegram: pass data_dir instead of entries_dir to bot_task

This commit is contained in:
Lewis Wynne 2026-04-10 18:25:27 +01:00
parent a5533b684a
commit b85b54c4a7
2 changed files with 7 additions and 5 deletions

View file

@ -29,8 +29,8 @@ async fn main() {
let notify_bot = bot.clone();
tokio::spawn(telegram::notification_task(notify_bot, chat_id, rx));
let cmd_entries_dir = entries_dir.clone();
tokio::spawn(telegram::bot_task(bot, chat_id, cmd_entries_dir));
let cmd_data_dir = config.data_dir.clone();
tokio::spawn(telegram::bot_task(bot, chat_id, cmd_data_dir));
}
_ => {
tracing::info!("telegram not configured, moderation notifications disabled");

View file

@ -41,15 +41,17 @@ pub async fn notification_task(bot: Bot, chat_id: ChatId, mut rx: Receiver<(Entr
}
/// Run the Telegram bot that listens for /allow_ and /deny_ commands.
pub async fn bot_task(bot: Bot, chat_id: ChatId, entries_dir: PathBuf) {
pub async fn bot_task(bot: Bot, chat_id: ChatId, data_dir: PathBuf) {
let handler = Update::filter_message().endpoint(
|bot: Bot, msg: Message, entries_dir: PathBuf, chat_id: ChatId| async move {
|bot: Bot, msg: Message, data_dir: PathBuf, chat_id: ChatId| async move {
let text = msg.text().unwrap_or("");
// Only respond to the configured chat
if msg.chat.id != chat_id {
return respond(());
}
let entries_dir = data_dir.join("entries");
if let Some(id) = text.strip_prefix("/allow_") {
match entries::set_status(&entries_dir, id, Status::Approved) {
Ok(name) => {
@ -77,7 +79,7 @@ pub async fn bot_task(bot: Bot, chat_id: ChatId, entries_dir: PathBuf) {
);
Dispatcher::builder(bot, handler)
.dependencies(dptree::deps![entries_dir, chat_id])
.dependencies(dptree::deps![data_dir, chat_id])
.build()
.dispatch()
.await;